summaryrefslogtreecommitdiff
path: root/lib/history.zsh
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2018-09-15 22:56:12 +0200
committerMarc Cornellà <marc.cornella@live.com>2018-09-15 22:56:12 +0200
commit5a729f66672d84f63c9f295008387d675a87b795 (patch)
treeb5322be94512bc89b7d1153ae4d73b24ca7e9b84 /lib/history.zsh
parent315eb77336919d907adf1296ce234d8bc778c005 (diff)
downloadzsh-5a729f66672d84f63c9f295008387d675a87b795.tar.gz
zsh-5a729f66672d84f63c9f295008387d675a87b795.tar.bz2
zsh-5a729f66672d84f63c9f295008387d675a87b795.zip
lib: fix history wrapper when passing numbers
If a number is passed without explicitly passing `-l`, it will now behave as if using the history builtin, instead of throwing an error.
Diffstat (limited to 'lib/history.zsh')
-rw-r--r--lib/history.zsh8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/history.zsh b/lib/history.zsh
index 62e02648b..d8bbd41c4 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -1,7 +1,6 @@
## History wrapper
function omz_history {
- # Delete the history file if `-c' argument provided.
- # This won't affect the `history' command output until the next login.
+ local clear list
zparseopts -E c=clear l=list
if [[ -n "$clear" ]]; then
@@ -12,9 +11,8 @@ function omz_history {
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
else
- # otherwise, call `fc -l 1` to show all available
- # history (and pass additional parameters)
- builtin fc "$@" -l 1
+ # unless a number is provided, show all history events (starting from 1)
+ [[ ${@[-1]} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
fi
}