1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-15 18:30:08 +00:00

fix(history): fix edge cases introduced in #12341 (#12357)

This commit is contained in:
Martin Hans 2024-04-16 19:38:58 +02:00 committed by GitHub
parent b26000d168
commit efa8de0b52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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