Skip to content

Commit

Permalink
lib: fix history wrapper when passing numbers
Browse files Browse the repository at this point in the history
If a number is passed without explicitly passing `-l`, it will now behave
as if using the history builtin, instead of throwing an error.
  • Loading branch information
mcornella committed Sep 15, 2018
1 parent 315eb77 commit 5a729f6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/history.zsh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 5a729f6

Please sign in to comment.