Which file is read and executed when interactive non-login bash session exits? For example interactive login bash executes ~/.bash_logout if it exits.



To have the interactive non-login shell source a file upon exiting, set a trap in .bashrc:

shopt -q login_shell || trap '. "$HOME/.bash_non-login_logout"' EXIT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.