Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4104

Raspberry Pi Connect • Re: cli commands not saved to $HOME/.bash_history

$
0
0
The short (and not very nice) answer is "Don't do that!". Get in the habit of exiting the shell via ^D (4 fewer keystrokes than e x i t <enter>). Note that the "superuser" page linked to by a previous responder is kinda funny in that the OP (on that page) says "I like to just click the X" (to get out of a shell) - which puts it in the "Doctor, it hurts when I do this" category.

That said, I do think that this is an area that is not handled by the shell (bash) as well as it could/should be. I personally think that if you "click the X" (say, from a "Raspberry Pi Connect" connection, it *should* save the history (just as if you had exited normally). The point is that the shell gets killed by a HUP signal; it should catch the HUP and write out the history before exiting. Think of it this way, in the old days, the HUP signal came when your modem (phone) connection was unexpectedly broken. Certainly, if/when that happens, you'd want your history to be saved, wouldn't you?

This issue, incidentally, combines with the long-standing problem of when you have multiple shells (terminal windows) open and say you exit one of them, saving the history file, then later on you exit from another one, and it overwrites the changes made in the first shell. What is needed is a way for each terminal window to have its own, uniquely named, history file.

P.S. The canonical way to write out the history file is: history -w
I do that every once in a while, just to make sure that whatever brilliant thing I just did is saved, just in case the machine crashes or something like that...

Statistics: Posted by BigRedMailbox — Fri Dec 20, 2024 6:09 pm



Viewing all articles
Browse latest Browse all 4104

Trending Articles