Bash 相当于 .bash_logout 用于 FISH shell

Bash equivalent .bash_logout for FISH shell

通常我在 .bash_logout 中为 bash shell 编写退出脚本。我最近开始使用 fish shell。 fish.bashrc 等价物位于 ~/.config/fish/config.fish 但我在哪里可以找到 .bash_logout 的等价物?

您无需获取特定文件,而是定义一个在 shell 存在时运行的事件处理程序。

来自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

您可以关注@chepner 的回答。 但是,您也可以覆盖 exitlogout 函数而不是事件侦听器!

function exit
    echo exiting...
    kill %self
end

Do the same to logout

而且,它有效