- Edited
Great question! On macOS (using Zsh by default), your shell command history might be limited to the last 500 commands, but you can easily increase that limit.
Letβs walk through how to store and recall more commands in your Terminal history.
Step-by-Step: Increase Zsh History Limit
1. Open Terminal
2. Edit your Zsh configuration file
Run this command:
nano ~/.zshrc
3. Add or Update These Settings
Paste or update the following lines in your .zshrc
file:
# Increase the number of lines saved in history
HISTSIZE=10000 # Number of commands to remember in memory (in-session)
SAVEHIST=10000 # Number of commands to save to the history file
HISTFILE=~/.zsh_history # File where history is stored
alias history='history 1'
You can increase
10000
to even more (like 50000) if needed.
4. Save and Exit
- Press
Control + X
, thenY
, thenEnter
to save and exit.
5. Apply the Changes
Run:
source ~/.zshrc
Done! Now your Terminal will:
- Keep up to 10,000 commands in session.
- Save them in
~/.zsh_history
across reboots.
Want to Check Current Limits?
Run this in Terminal:
echo $HISTSIZE
echo $SAVEHIST
For Bash Users (if you're using bash instead of zsh)
Edit your ~/.bash_profile
or ~/.bashrc
:
nano ~/.bash_profile
Add:
HISTSIZE=10000
HISTFILESIZE=20000
Then save and source ~/.bash_profile
.
Let me know if you'd also like to enable timestamped history or search history by keywords!