diff options
author | Marc Cornellà <marc.cornella@live.com> | 2014-12-18 21:56:49 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2018-04-22 15:33:10 +0200 |
commit | 20d63be655bfed2104858dc87052a310f9c45224 (patch) | |
tree | 50f2e576a1fdcc609598c2bebb62e0930c867009 /lib/history.zsh | |
parent | f8180c3a64754057d696a4fb1cf3639c394377b9 (diff) | |
download | zsh-20d63be655bfed2104858dc87052a310f9c45224.tar.gz zsh-20d63be655bfed2104858dc87052a310f9c45224.tar.bz2 zsh-20d63be655bfed2104858dc87052a310f9c45224.zip |
Use zparseopts to get passed arguments
Diffstat (limited to 'lib/history.zsh')
-rw-r--r-- | lib/history.zsh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/history.zsh b/lib/history.zsh index e6c94fcc0..23e96c9db 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -2,12 +2,18 @@ function omz_history { # Delete the history file if `-c' argument provided. # This won't affect the `history' command output until the next login. - if [[ "${@[(i)-c]}" -le $# ]]; then + zparseopts -E c=clear l=list + + if [[ -n "$clear" ]]; then + # if -c provided, clobber the history file echo -n >| "$HISTFILE" echo >&2 History file deleted. Reload the session to see its effects. - elif [[ "${@[(i)-l]}" -le $# ]]; then + elif [[ -n "$list" ]]; then + # 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 fi } |