Re: Short handy trick for .bash_history file
Reply #3 –
You could probably use aliases in .bashrc for frequently used commands, or scripts in /usr/local/bin as an alternative. Many of the problems you describe can be resolved if you look at the man page for "bash", then (assuming you are using less as the man pager) press / then type history as the search term and enter to search, press n for next one. It has all manner of built in features to control and search the history, using ag is a kludge because it's easier than memorizing all the bash history key combos! You can set things in your ~/.bashrc like HISTFILESIZE=100000 to allow a big history file, but stop it growing too big. Don't set the other HISTSIZE variable though, otherwise instead of the file being truncated to the right length, it is deleted when full and a new empty one started. There are some defaults if nothing is set so it should be limited even in standard trim.
These commands turn history on and off temporarily in the shell they are issued in, perhaps helpful for the situation you describe for your root shell, or if you are saving history but need to enter some secret codes etc.:
Turn Off
set +o history
Turn on
set -o history