fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian HomborgReformat completion scriptsce245704d

master
1.1 KiB35 linesraw
1function __fish_complete_pushd_plus
2    if count $dirstack >/dev/null
3        # print each member of the stack, replace $HOME with ~
4        for i in (seq (count $dirstack))
5            printf "+%s\t%s\n" $i "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[$i])
6        end
7    end
8end
9
10function __fish_complete_pushd_minus
11    if count $dirstack >/dev/null
12        # print each member of the stack, replace $HOME with ~
13        # Negative arguments are expected to start at "-0"
14        for i in (seq (count $dirstack) -1 1)
15            printf "%s\t%s\n" -(math $i - 1) "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[(math -$i)])
16        end
17    end
18end
19
20function __fish_complete_pushd_swap
21    if count $dirstack >/dev/null
22        # replace $HOME with ~
23        printf "\t%s\n" "Swap with "(string replace -r "^$HOME" "~" -- $dirstack[1])
24    end
25end
26
27# support pushd <dir>
28complete -c pushd -a "(__fish_complete_cd)"
29
30# support pushd <>
31complete -c pushd -a '(__fish_complete_pushd_swap)'
32
33# support pushd <+n>
34complete -c pushd -a '(__fish_complete_pushd_plus)'
35complete -c pushd -a '(__fish_complete_pushd_minus)'