mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
functions/history: Put back some checks for clear{,-session}
Mostly we pass on the options - otherwise they would be ignored. For `clear`, we do need the full checks, because that will prompt *before* running the builtin. But this makes it easier to eventually move that logic into the builtin
This commit is contained in:
parent
212dd6ec37
commit
8dcde27e0b
1 changed files with 16 additions and 6 deletions
|
@ -176,28 +176,38 @@ function history --description "display or manipulate interactive command histor
|
|||
end
|
||||
|
||||
case save # save our interactive command history to the persistent history
|
||||
builtin history save -- $argv
|
||||
builtin history save $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $argv
|
||||
case merge # merge the persistent interactive command history with our history
|
||||
builtin history merge -- $argv
|
||||
builtin history merge $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $argv
|
||||
case clear # clear the interactive command history
|
||||
if test -n "$search_mode"
|
||||
or set -q show_time[1]
|
||||
printf (_ "%ls: %ls: subcommand takes no options\n") history $hist_cmd >&2
|
||||
return 1
|
||||
end
|
||||
if set -q argv[1]
|
||||
printf (_ "%ls: %ls: expected %d arguments; got %d\n") history $hist_cmd 0 (count $argv) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
printf (_ "If you enter 'yes' your entire interactive command history will be erased\n")
|
||||
read --local --prompt "echo 'Are you sure you want to clear history? (yes/no) '" choice
|
||||
if test "$choice" = yes
|
||||
builtin history clear -- $argv
|
||||
builtin history clear $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $argv
|
||||
and printf (_ "Command history cleared!\n")
|
||||
else
|
||||
printf (_ "You did not say 'yes' so I will not clear your command history\n")
|
||||
end
|
||||
case clear-session # clears only session
|
||||
builtin history clear-session -- $argv
|
||||
printf (_ "Command history for session cleared!\n")
|
||||
builtin history clear-session $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $argv
|
||||
and printf (_ "Command history for session cleared!\n")
|
||||
case append
|
||||
set -l newitem $argv
|
||||
if not set -q argv[1]
|
||||
read -P "Command: " newitem
|
||||
end
|
||||
|
||||
builtin history append -- $newitem
|
||||
builtin history append $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $newitem
|
||||
case '*'
|
||||
printf "%ls: unexpected subcommand '%ls'\n" $cmd $hist_cmd
|
||||
return 2
|
||||
|
|
Loading…
Reference in a new issue