20d63be655bfed2104858dc87052a310f9c45224

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

Message

Use zparseopts to get passed arguments

Diff

 1diff --git a/lib/history.zsh b/lib/history.zsh
 2index e6c94fcc08df8a49e481268bb13491327fddc882..23e96c9dbba2be36f5e789628fd8e62bc539d695 100644
 3--- a/lib/history.zsh
 4+++ b/lib/history.zsh
 5@@ -2,12 +2,18 @@
 6 function omz_history {
 7   # Delete the history file if `-c' argument provided.
 8   # This won't affect the `history' command output until the next login.
 9-  if [[ "${@[(i)-c]}" -le $# ]]; then
10+  zparseopts -E c=clear l=list
11+
12+  if [[ -n "$clear" ]]; then
13+    # if -c provided, clobber the history file
14     echo -n >| "$HISTFILE"
15     echo >&2 History file deleted. Reload the session to see its effects.
16-  elif [[ "${@[(i)-l]}" -le $# ]]; then
17+  elif [[ -n "$list" ]]; then
18+    # if -l provided, run as if calling `fc' directly
19     builtin fc "$@"
20   else
21+    # otherwise, call `fc -l 1` to show all available
22+    # history (and pass additional parameters)
23     builtin fc "$@" -l 1
24   fi
25 }