Shell history not long enough? Try this

Our current CI-setup adds some noise to the bash history file. This is like 50-100 extra commands a day (automated)

Our current CI-setup adds some noise to the bash history file. This is like 200 extra commands a day (automated) but this flushes a part of the history. Normally the history is only 1000 records long. The problem with the extra 200 commands a day is that i only keep around 5 days of history. This annoys me. On OSX Catalina this is even worse since the new zsh shell is only keeping track of the last 15 or so. I upped it to 10k because thats what I needed, use accordingly.

Here are some guidelines to fix this issue.

In Linux edit ~/.bashrc and add the following lines.


HISTSIZE=10000
HISTFILESIZE=10000

In MacOS before Catalina edit ~/.bash_profile and add the following lines.


HISTSIZE=10000
HISTFILESIZE=10000

MacOS Catalina uses zsh so please edit ~/.zshrc


HISTSIZE=100000
HISTFILESIZE=10000

Please restart your shell after this, and use the following commands to see the results.


echo $HISTSIZE $HISTFILESIZE $HISTFILE

Output should be something like this on OSX:


10000 10000 /Users/xxx/.bash_sessions/sessionID.historynew

Happy history-ing!

Created by Daniel on 11/22/2024

Copyright © DanielKnows.com 2019 - 2024 - Built with NuxtJS

Subscribe for Tech Tips!

Stay updated with the latest tech insights and tips. Subscribe now!

{}