Search code examples
bashconfigfish

Bash equivalent .bash_logout for FISH shell


Generally I write my exit scripts for bash shell in .bash_logout. I recently started using fish shell. The .bashrc equivalent of fish is located in ~/.config/fish/config.fish but where do I find the equivalent for .bash_logout?


Solution

  • Instead of sourcing a specific file, you define an event handler that runs when the shell exists.

    From http://fishshell.com/docs/current/index.html#initialization:

    If you want to run a set of commands when fish exits, use an event handler that is triggered by the exit of the shell:

    function on_exit --on-process %self
        echo fish is now exiting
    end