mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-12 23:01:16 -03:00
Add pushd -n to completions, use string
Also indent with fish_indent
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
function __fish_complete_pushd_plus
|
||||
if count $dirstack > /dev/null
|
||||
# TODO: Shift to using string replace when released
|
||||
#
|
||||
# print each member of the stack, replace $HOME with ~
|
||||
for i in (seq (count $dirstack))
|
||||
echo +$i\tRotate to (echo $dirstack[$i] | sed -e "s|^$HOME|~|")
|
||||
end
|
||||
if count $dirstack > /dev/null
|
||||
# print each member of the stack, replace $HOME with ~
|
||||
for i in (seq (count $dirstack))
|
||||
printf "+%s\t%s" $i "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[$i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_pushd_minus
|
||||
if count $dirstack > /dev/null
|
||||
# print each member of the stack, replace $HOME with ~
|
||||
for i in (seq (count $dirstack) -1 1)
|
||||
printf "-%s\t%s" $i "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[$i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_pushd_swap
|
||||
if count $dirstack > /dev/null
|
||||
# TODO: Shift to using string replace when released
|
||||
#
|
||||
# replace $HOME with ~
|
||||
echo ''\tSwap with (echo $dirstack[1] | sed -e "s|^$HOME|~|")
|
||||
end
|
||||
if count $dirstack > /dev/null
|
||||
# replace $HOME with ~
|
||||
printf "\t%s" "Swap with "(string replace -r "^$HOME" "~" -- $dirstack[1])
|
||||
end
|
||||
end
|
||||
|
||||
# support pushd <dir>
|
||||
@@ -26,3 +31,4 @@ complete -c pushd -a '(__fish_complete_pushd_swap)'
|
||||
|
||||
# support pushd <+n>
|
||||
complete -c pushd -a '(__fish_complete_pushd_plus)'
|
||||
complete -c pushd -a '(__fish_complete_pushd_minus)'
|
||||
|
||||
Reference in New Issue
Block a user