2015-09-26 10:39:01 +08:00
|
|
|
function __fish_complete_pushd_plus
|
2015-10-05 21:23:05 +08:00
|
|
|
if count $dirstack > /dev/null
|
|
|
|
# print each member of the stack, replace $HOME with ~
|
|
|
|
for i in (seq (count $dirstack))
|
2015-10-07 16:26:27 +08:00
|
|
|
printf "+%s\t%s\n" $i "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[$i])
|
2015-09-26 10:39:01 +08:00
|
|
|
end
|
2015-10-05 21:23:05 +08:00
|
|
|
end
|
2015-09-26 10:39:01 +08:00
|
|
|
end
|
|
|
|
|
2015-10-05 21:23:05 +08:00
|
|
|
function __fish_complete_pushd_minus
|
|
|
|
if count $dirstack > /dev/null
|
|
|
|
# print each member of the stack, replace $HOME with ~
|
2015-10-10 02:02:28 +08:00
|
|
|
# Negative arguments are expected to start at "-0"
|
2015-10-05 21:23:05 +08:00
|
|
|
for i in (seq (count $dirstack) -1 1)
|
2017-08-25 03:38:10 +08:00
|
|
|
printf "%s\t%s\n" -(math i - 1) "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[(math -i)])
|
2015-09-26 10:39:01 +08:00
|
|
|
end
|
2015-10-05 21:23:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_pushd_swap
|
|
|
|
if count $dirstack > /dev/null
|
|
|
|
# replace $HOME with ~
|
2015-10-07 16:26:27 +08:00
|
|
|
printf "\t%s\n" "Swap with "(string replace -r "^$HOME" "~" -- $dirstack[1])
|
2015-10-05 21:23:05 +08:00
|
|
|
end
|
2015-09-26 10:39:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# support pushd <dir>
|
|
|
|
complete -c pushd -a "(__fish_complete_cd)"
|
|
|
|
|
|
|
|
# support pushd <>
|
|
|
|
complete -c pushd -a '(__fish_complete_pushd_swap)'
|
|
|
|
|
|
|
|
# support pushd <+n>
|
|
|
|
complete -c pushd -a '(__fish_complete_pushd_plus)'
|
2015-10-05 21:23:05 +08:00
|
|
|
complete -c pushd -a '(__fish_complete_pushd_minus)'
|