1

Searching fails me.

I noticed that some terminal emulators (gnome-terminal, terminator, maybe others) do not execute my logout file. Works well enough in a virtual terminal, but not through the emulators.

I looked at the man pages (of the emulators), but there seems to be no option to force the execution of a logout file.

Is it possible?

2
  • 1
    These files are not for terminals or terminal emulators. They are for shells. Please read What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'? The difference you observed is because terminal emulators tend to run non-logins shells because you're already logged in (to Gnome, KDE or whatever), while in tty2 you do log in. What are you trying to achieve with .logout? Please make sure there is no XY problem here. Commented Jan 30, 2020 at 16:54
  • Yes, you're quite right about all that. In my situation I rarely log out of X, and my terminal sessions all have timeouts. My logout process simply runs ponysay; I just like to see the art before deciding what to do with the terminal. :D
    – Pom
    Commented Jan 30, 2020 at 17:44

1 Answer 1

1

According to the bash manual:

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

So bash_logout executes when a login shell exits. It may be the case that the emulators are not opening a login shell, there could be configurations you can change on the client to make sure it loads a login shell everytime.

Alternatively you can open a new shell with -l or --login and that will load a login shell for you.

1
  • I totally forgot about the option of "Run command as a login shell" or passing those sort of arguments over, ie for terminator --execute bash -l. Thanks for the reminder!
    – Pom
    Commented Jan 30, 2020 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .