Bash equivalent .bash_logout for FISH shell

纵然是瞬间 提交于 2019-12-25 08:29:48

问题


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?


回答1:


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



回答2:


You may follow @chepner 's answer. But, you can also override exit and logout function instead of a event listener!

function exit
    echo exiting...
    kill %self
end

Do the same to logout

And, it works



来源:https://stackoverflow.com/questions/39728790/bash-equivalent-bash-logout-for-fish-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!