Ask / Submit
1

How to change shell history properties (in Terminal)

asked 2019-04-04 00:35:53 +0300

Levone1 gravatar image

updated 2019-04-04 19:12:36 +0300

Maus gravatar image

Maybe just another 'minor-bug-you-have-to-live-with' for now, but maybe there's something I'm missing ... You know how if you click up arrow in terminal it auto fills the last command you entered, and respective previous ones, the more you tap it? I've noticed (and much appreciated) that that history remains even after closing the app or even rebooting. But, not all the time... Sometimes, it's like the space for historical items runs out or something, and, even though there have been several other commands entered after the first one that gets auto-filled, still, I can't get it to show anything more recent. Any ideas?

edit retag flag offensive close delete

Comments

3

Small note: bash saves history only when exiting (exitor Ctrl+D). It won't save if it is forcefully terminated.

So if you reboot your phone while bash is still running, that last part won't get written into the history.

DrYak ( 2019-04-04 13:38:56 +0300 )edit

another thing I wondered about... I tried exiting and closing different ways to test, but hadn't discovered anything conclusive yet. I don't recall using exit command very often, so I wonder if using reboot from the reboot menu does that automatically, since my history is usually saved, (I've just experienced the above issue a couple of times).

Levone1 ( 2019-04-04 15:58:41 +0300 )edit

1 Answer

Sort by » oldest newest most voted
7

answered 2019-04-04 08:11:14 +0300

Maus gravatar image

updated 2019-04-04 19:15:33 +0300

This is not a bug. It's a setting, specifically a setting of your shell and you can look up usage of the HIST* variables in the man page. In your terminal, enter this command to find variables that configure the current behaviour:

set | grep HIST

If you want to change these settings, use the file .bashrc to set them permanently.

As @DrYak pointed out, for the shell to actually save the history to a file, you have to quit the shell in a proper way. That is, exiting via Ctrl-D, logout or exit. If you just quit the Terminal app, the shell process will most likely not save its history file.

edit flag offensive delete publish link more

Comments

1

Nice, thanks... I modded bash.rc to double histsize and histfilesize. Maybe that will take care of it...

Levone1 ( 2019-04-04 11:55:59 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2019-04-04 00:35:53 +0300

Seen: 212 times

Last updated: Apr 05