mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
fish_indent did something surprising.
This commit is contained in:
parent
e3187b2361
commit
fb3c839a15
1 changed files with 89 additions and 90 deletions
|
@ -45,98 +45,97 @@ function history --shadow-builtin --description "display or manipulate interacti
|
|||
switch $cmd
|
||||
case search
|
||||
if set -q argv[1]
|
||||
or begin
|
||||
test -n $time_args
|
||||
and contains $search_mode none
|
||||
set -l pager less
|
||||
set -q PAGER
|
||||
and set pager $PAGER
|
||||
builtin history $time_args | eval $pager
|
||||
else
|
||||
builtin history $time_args $argv
|
||||
end
|
||||
return
|
||||
|
||||
|
||||
case delete
|
||||
# Interactively delete history
|
||||
set -l found_items ""
|
||||
switch $search_mode
|
||||
case prefix:
|
||||
set found_items (builtin history --search --prefix $prefix_args)
|
||||
case contains
|
||||
set found_items (builtin history --search --contains $contains_args)
|
||||
case none
|
||||
builtin history $argv
|
||||
# Save changes after deleting item.
|
||||
builtin history --save
|
||||
return 0
|
||||
end
|
||||
|
||||
set found_items_count (count $found_items)
|
||||
if test $found_items_count -gt 0
|
||||
echo "[0] cancel"
|
||||
echo "[1] all"
|
||||
echo
|
||||
|
||||
for i in (seq $found_items_count)
|
||||
printf "[%s] %s \n" (math $i + 1) $found_items[$i]
|
||||
end
|
||||
|
||||
read --local --prompt "echo 'Delete which entries? > '" choice
|
||||
set choice (string split " " -- $choice)
|
||||
|
||||
for i in $choice
|
||||
|
||||
# Skip empty input, for example, if the user just hits return
|
||||
if test -z $i
|
||||
continue
|
||||
end
|
||||
|
||||
# Following two validations could be embedded with "and" but I find the syntax
|
||||
# kind of weird.
|
||||
if not string match -qr '^[0-9]+$' $i
|
||||
printf "Invalid input: %s\n" $i
|
||||
continue
|
||||
end
|
||||
|
||||
if test $i -gt (math $found_items_count + 1)
|
||||
printf "Invalid input : %s\n" $i
|
||||
continue
|
||||
end
|
||||
|
||||
if test $i = "0"
|
||||
printf "Cancel\n"
|
||||
return
|
||||
else
|
||||
if test $i = "1"
|
||||
for item in $found_items
|
||||
builtin history --delete $item
|
||||
end
|
||||
printf "Deleted all!\n"
|
||||
or test -n $time_args
|
||||
and contains $search_mode none
|
||||
set -l pager less
|
||||
set -q PAGER
|
||||
and set pager $PAGER
|
||||
builtin history $time_args | eval $pager
|
||||
else
|
||||
builtin history --delete $found_items[(math $i - 1)]
|
||||
builtin history $time_args $argv
|
||||
end
|
||||
return
|
||||
|
||||
|
||||
case delete
|
||||
# Interactively delete history
|
||||
set -l found_items ""
|
||||
switch $search_mode
|
||||
case prefix:
|
||||
set found_items (builtin history --search --prefix $prefix_args)
|
||||
case contains
|
||||
set found_items (builtin history --search --contains $contains_args)
|
||||
case none
|
||||
builtin history $argv
|
||||
# Save changes after deleting item.
|
||||
builtin history --save
|
||||
return 0
|
||||
end
|
||||
|
||||
end
|
||||
set found_items_count (count $found_items)
|
||||
if test $found_items_count -gt 0
|
||||
echo "[0] cancel"
|
||||
echo "[1] all"
|
||||
echo
|
||||
|
||||
for i in (seq $found_items_count)
|
||||
printf "[%s] %s \n" (math $i + 1) $found_items[$i]
|
||||
end
|
||||
|
||||
read --local --prompt "echo 'Delete which entries? > '" choice
|
||||
set choice (string split " " -- $choice)
|
||||
|
||||
for i in $choice
|
||||
|
||||
# Skip empty input, for example, if the user just hits return
|
||||
if test -z $i
|
||||
continue
|
||||
end
|
||||
|
||||
# Following two validations could be embedded with "and" but I find the syntax
|
||||
# kind of weird.
|
||||
if not string match -qr '^[0-9]+$' $i
|
||||
printf "Invalid input: %s\n" $i
|
||||
continue
|
||||
end
|
||||
|
||||
if test $i -gt (math $found_items_count + 1)
|
||||
printf "Invalid input : %s\n" $i
|
||||
continue
|
||||
end
|
||||
|
||||
if test $i = "0"
|
||||
printf "Cancel\n"
|
||||
return
|
||||
else
|
||||
if test $i = "1"
|
||||
for item in $found_items
|
||||
builtin history --delete $item
|
||||
end
|
||||
printf "Deleted all!\n"
|
||||
else
|
||||
builtin history --delete $found_items[(math $i - 1)]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
# Save changes after deleting item(s).
|
||||
builtin history --save
|
||||
end
|
||||
case save
|
||||
# Save changes to history file.
|
||||
builtin history $argv
|
||||
case merge
|
||||
builtin history --merge
|
||||
case help
|
||||
builtin history --help
|
||||
case clear
|
||||
# Erase the entire history.
|
||||
echo "Are you sure you want to clear history ? (y/n)"
|
||||
read ch
|
||||
if test $ch = "y"
|
||||
builtin history $argv
|
||||
echo "History cleared!"
|
||||
end
|
||||
end
|
||||
# Save changes after deleting item(s).
|
||||
builtin history --save
|
||||
end
|
||||
case save
|
||||
# Save changes to history file.
|
||||
builtin history $argv
|
||||
case merge
|
||||
builtin history --merge
|
||||
case help
|
||||
builtin history --help
|
||||
case clear
|
||||
# Erase the entire history.
|
||||
echo "Are you sure you want to clear history ? (y/n)"
|
||||
read ch
|
||||
if test $ch = "y"
|
||||
builtin history $argv
|
||||
echo "History cleared!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue