mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-22 04:11:58 +00:00
Use zparseopts to get passed arguments
This commit is contained in:
parent
f8180c3a64
commit
20d63be655
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue