Built-in Commands
history
By default:
- zsh:
historylists only the 15 most recent history entrieshistory 1lists all entries (see below)
- bash:
historylists all history entries
With numbers:
- zsh:
history <n>shows all entries starting with<n>, therefore
history 1shows all entrieshistory -<n>(note the-) shows the<n>most recent entries
(default behavior is effectivelyhistory -15)
- bash:
history <n>shows the<n>most recent entries- Bash does not support listing history from an entry number directly
(fc -l <n>requires the entry<n>to exist)
Optional background info:
- In zsh,
historyis effectively (not literally) an alias forfc -l- See:
man zshbuiltins - For advanced features:
man zshall
- See:
- In bash,
historyis its own command with syntax different fromfc -l- See:
man bash
- See:
- Both shells support:
fc -l <fromNum> [<toNum>]to list a given range of history entries:- bash:
must exist - zsh: works as long as at least one entry is in range
- Result: fc -l 1 works in zsh (lists all), but usually not in bash
- bash:
References
blog comments powered by Disqus