add history append subcommand

This commit is contained in:
Anurag Singh
2024-04-13 18:21:51 +08:00
committed by Johannes Altmanninger
parent 6f408211a1
commit c044d5e3f0
7 changed files with 30 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
# Note that when a completion file is sourced a new block scope is created so `set -l` works.
set -l __fish_history_all_commands search delete save merge clear clear-session
set -l __fish_history_all_commands search delete save merge clear clear-session append
complete -c history -s h -l help -d "Display help and exit"
@@ -35,3 +35,5 @@ complete -f -c history -n "not __fish_seen_subcommand_from $__fish_history_all_c
-a clear -d "Clears history file"
complete -f -c history -n "not __fish_seen_subcommand_from $__fish_history_all_commands" \
-a clear-session -d "Clears all history from the current session"
complete -f -c history -n "not __fish_seen_subcommand_from $__fish_history_all_commands" \
-a append -d "Appends commands to the history without needing to execute them"

View File

@@ -70,7 +70,7 @@ function history --description "display or manipulate interactive command histor
# command. This allows the flags to appear before or after the subcommand.
if not set -q hist_cmd[1]
and set -q argv[1]
if contains $argv[1] search delete merge save clear clear-session
if contains $argv[1] search delete merge save clear clear-session append
set hist_cmd $argv[1]
set -e argv[1]
end
@@ -226,6 +226,13 @@ function history --description "display or manipulate interactive command histor
builtin history clear-session -- $argv
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
case '*'
printf "%ls: unexpected subcommand '%ls'\n" $cmd $hist_cmd
return 2