Understanding Shell History: ZSH vs Bash vs Fish

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

FeatureBashZSHFish
History commandhistoryhistoryfc -lhistory
History file~/.bash_history~/.zsh_history~/.local/share/fish/fish_history
In-memory sizeHISTSIZE=1000HISTSIZE=30 (default)Unlimited (by default)
Duplicate handlingAllowedOften deduplicatedDeduplicated

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.

Leave a Reply

Your email address will not be published. Required fields are marked *