aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions/pushd.fish
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2015-10-05 15:23:05 +0200
committerGravatar Fabian Homborg <FHomborg@gmail.com>2015-10-05 15:23:05 +0200
commitec74479d447b7f54e59896e786243d98b6925728 (patch)
tree6dca6aa2eea1d9c9fec8d48ffcce6c79ea5929a3 /share/completions/pushd.fish
parente75108fc4cfc5f0a4ec5361f0194ddb21a9468c1 (diff)
Add pushd -n to completions, use `string`
Also indent with fish_indent
Diffstat (limited to 'share/completions/pushd.fish')
-rw-r--r--share/completions/pushd.fish32
1 files changed, 19 insertions, 13 deletions
diff --git a/share/completions/pushd.fish b/share/completions/pushd.fish
index 9c64c5f1..9e465fa0 100644
--- a/share/completions/pushd.fish
+++ b/share/completions/pushd.fish
@@ -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_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|~|")
+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
+ # 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)'