Explore how shell history works in Bash, ZSH, and Fish. With practical ZSH (my favorite) examples, config tips, and insights into customizing your terminal workflow for maximum productivity.
How History Works in Different Shells
| Feature | Bash | ZSH | Fish |
|---|---|---|---|
| History command | history | history, fc -l | history |
| History file | ~/.bash_history | ~/.zsh_history | ~/.local/share/fish/fish_history |
| In-memory size | HISTSIZE=1000 | HISTSIZE=30 (default) | Unlimited (by default) |
| Duplicate handling | Allowed | Often deduplicated | Deduplicated |
Useful History Commands
history # Show recent commands
!42 # Re-run command number 42
!! # Re-run the last command
!git # Re-run the last command that started with 'git'
Final Thoughts
Each shell handles history differently. Bash is simple, ZSH is customizable, and Fish is intuitive. If you’re transitioning to ZSH, a few tweaks can make it feel just as powerful (or more so) than Bash.