fix(history): fix edge cases, add comments

This commit is contained in:
Marc Cornellà 2024-04-16 19:34:54 +02:00
commit b0bf6bcfb3
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,5 +1,6 @@
## History wrapper ## History wrapper
function omz_history { function omz_history {
# parse arguments and remove from $@
local clear list stamp local clear list stamp
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp
@ -9,14 +10,14 @@ function omz_history {
elif [[ -n "$clear" ]]; then elif [[ -n "$clear" ]]; then
# if -c provided, clobber the history file # if -c provided, clobber the history file
echo -n >| "$HISTFILE" echo -n >| "$HISTFILE"
fc $stamp -p "$HISTFILE" fc -p "$HISTFILE"
echo >&2 History file deleted. echo >&2 History file deleted.
elif [[ -n "$list" ]]; then elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly # if -l provided, run as if calling `fc' directly
builtin fc $stamp "$@" builtin fc $stamp -l "$@"
else else
# otherwise, run `fc -l` with a custom format # otherwise, run `fc -l` with a custom format
builtin fc -l "$@" builtin fc $stamp -l "$@"
fi fi
} }