> On 13 Apr 2023, at 16:13, Barry <barry@xxxxxxxxxxxxxxxx> wrote: > > > >>> On 12 Apr 2023, at 16:40, stan via devel <devel@xxxxxxxxxxxxxxxxxxxxxxx> wrote: >>> >>> On Wed, 12 Apr 2023 10:39:44 +0200 >>> Vít Ondruch <vondruch@xxxxxxxxxx> wrote: >>> >>> Dne 11. 04. 23 v 18:02 stan via devel napsal(a): >>>> >>>> I have the following defined in .bashrc: >>>> >>>> # this logs the history explicitly before exiting a shell >>>> hx () >>>> { >>>> history -a; >>>> exit; >>>> } >>>> >>>> It means that I have to exit using the command hx when closing a >>>> terminal. >>> >>> >>> What about using `~/.bash_logout` to avoid the need of `hx`? >> >> I had to do some research to even understand what you were asking. >> With that caveat, it seems that a .bash_logout only executes on login >> shells. So, it would not save the history of terminals in X when they >> were closed. Am I misunderstanding? > > For lots of reasons it became recommended that all gui terminal sessions should be login sessions. One reason being that .bash_profile may not be run in a sub process. /sub/parent/ > > Barry > > > >> >> I did find something that might work in that case, at this link. >> >> https://superuser.com/questions/410525/explain-why-bash-logout-wont-run-commands/410534#410534 >> >> """ >> ~/.bash_logout is only run if it you explicitly exit the shell with >> exit or logout, or by typing Control-D to enter an end-of-file at the >> command prompt. If you close the terminal emulator, processes are sent >> SIGHUP, and bash doesn’t run ~/.bash_logout in that case. >> >> If you want to perform work any time bash exits (and whether it’s a >> login shell or not), use trap foo EXIT. The most convenient way to do >> this is to put your code in a shell function, e.g.,: >> >> print_goodbye () { echo Goodbye; } >> trap print_goodbye EXIT >> """ >> >> Typing exit or logout is more keystrokes than hx, so .bash_logout is not >> really compelling. The trap looks promising, I assume that I would put >> save_history_on_exit () {history -a;} >> trap save_history_on_exit EXIT >> in .bashrc. Basically, running a .bash_logout in a different way. >> >> Thanks. >> _______________________________________________ >> devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx >> To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx >> Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ >> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines >> List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx >> Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue _______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue