5a729f66672d84f63c9f295008387d675a87b795

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

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.

Diff

 1diff --git a/lib/history.zsh b/lib/history.zsh
 2index 62e02648b50216e59eb0ba1fb03d00b3bdf8025c..d8bbd41c448563b7ad67cc1741c90eec9c121165 100644
 3--- a/lib/history.zsh
 4+++ b/lib/history.zsh
 5@@ -1,7 +1,6 @@
 6 ## History wrapper
 7 function omz_history {
 8-  # Delete the history file if `-c' argument provided.
 9-  # This won't affect the `history' command output until the next login.
10+  local clear list
11   zparseopts -E c=clear l=list
12 
13   if [[ -n "$clear" ]]; then
14@@ -12,9 +11,8 @@ function omz_history {
15     # if -l provided, run as if calling `fc' directly
16     builtin fc "$@"
17   else
18-    # otherwise, call `fc -l 1` to show all available
19-    # history (and pass additional parameters)
20-    builtin fc "$@" -l 1
21+    # unless a number is provided, show all history events (starting from 1)
22+    [[ ${@[-1]} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
23   fi
24 }
25