fork/fish-shell

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

Johannes AltmanningerMerge branch 'completions-to-use-expanded-tokens'a9618477e

master
4.5 KiB125 linesraw
1# fish completion for rbenv
2
3function __fish_rbenv_needs_command
4    set -l cmd (commandline -xpc)
5    if test (count $cmd) -eq 1
6        return 0
7    end
8
9    return 1
10end
11
12function __fish_rbenv_using_command
13    set -l cmd (commandline -xpc)
14    if test (count $cmd) -gt 1
15        if test $argv[1] = $cmd[2]
16            return 0
17        end
18    end
19    return 1
20end
21
22function __fish_rbenv_executables
23    rbenv exec --complete
24end
25
26function __fish_rbenv_installed_rubies
27    rbenv versions --bare
28end
29
30function __fish_rbenv_official_rubies
31    if command -sq ruby-build
32        ruby-build --definitions
33    else
34        # Remove trailing spaces, otherwise completion options appear like
35        # "\ \ option"
36        rbenv install --list | sed "s/^[[:space:]]*//"
37    end
38end
39
40function __fish_rbenv_prefixes
41    rbenv prefix --complete
42end
43
44### commands
45complete -f -c rbenv -n __fish_rbenv_needs_command -a commands -d 'List all available rbenv commands'
46complete -f -c rbenv -n '__fish_rbenv_using_command commands' -a '--sh --no-sh'
47
48### completions
49complete -f -c rbenv -n __fish_rbenv_needs_command -a completions
50
51### exec
52complete -f -c rbenv -n __fish_rbenv_needs_command -a exec
53complete -f -c rbenv -n '__fish_rbenv_using_command exec' -a '(__fish_rbenv_executables)'
54
55### global
56complete -f -c rbenv -n __fish_rbenv_needs_command -a global -d 'Set or show the global Ruby version'
57complete -f -c rbenv -n '__fish_rbenv_using_command global' -a '(__fish_rbenv_installed_rubies)'
58
59### help
60complete -f -c rbenv -n __fish_rbenv_needs_command -a help
61
62### hooks
63complete -f -c rbenv -n __fish_rbenv_needs_command -a hooks -d 'List hook scripts for a given rbenv command'
64
65### init
66complete -f -c rbenv -n __fish_rbenv_needs_command -a init -d 'Configure the shell environment for rbenv'
67
68### install
69complete -f -c rbenv -n __fish_rbenv_needs_command -a install -d 'Install a Ruby version'
70complete -f -c rbenv -n '__fish_rbenv_using_command install' -a '(__fish_rbenv_official_rubies)'
71
72### uninstall
73complete -f -c rbenv -n __fish_rbenv_needs_command -a uninstall -d 'Uninstall a Ruby version'
74complete -f -c rbenv -n '__fish_rbenv_using_command uninstall' -a '(__fish_rbenv_installed_rubies)'
75
76### local
77complete -f -c rbenv -n __fish_rbenv_needs_command -a local -d 'Set or show the local application-specific Ruby version'
78complete -f -c rbenv -n '__fish_rbenv_using_command local' -a '(__fish_rbenv_installed_rubies)'
79
80### prefix
81complete -f -c rbenv -n __fish_rbenv_needs_command -a prefix -d 'Display the directory where a Ruby version is installed'
82complete -f -c rbenv -n '__fish_rbenv_using_command prefix' -a '(__fish_rbenv_prefixes)'
83
84### rehash
85complete -f -c rbenv -n __fish_rbenv_needs_command -a rehash -d 'Rehash rbenv shims (run this after installing executables)'
86
87### root
88complete -f -c rbenv -n __fish_rbenv_needs_command -a root -d 'Display the root directory where versions and shims are kept'
89
90### shell
91complete -f -c rbenv -n __fish_rbenv_needs_command -a shell -d 'Set or show the shell-specific Ruby version'
92complete -f -c rbenv -n '__fish_rbenv_using_command shell' -a '--unset (__fish_rbenv_installed_rubies)'
93
94### shims
95complete -f -c rbenv -n __fish_rbenv_needs_command -a shims -d 'List existing rbenv shims'
96complete -f -c rbenv -n '__fish_rbenv_using_command shims' -a --short
97
98### version
99complete -f -c rbenv -n __fish_rbenv_needs_command -a version -d 'Show the current Ruby version & how it was selected'
100
101### version-file
102complete -f -c rbenv -n __fish_rbenv_needs_command -a version-file -d 'Detect the file that sets the current rbenv version'
103
104### version-file-read
105complete -f -c rbenv -n __fish_rbenv_needs_command -a version-file-read
106
107### version-file-write
108complete -f -c rbenv -n __fish_rbenv_needs_command -a version-file-write
109
110### version-name
111complete -f -c rbenv -n __fish_rbenv_needs_command -a version-name -d 'Show the current Ruby version'
112
113### version-origin
114complete -f -c rbenv -n __fish_rbenv_needs_command -a version-origin -d 'Explain how the current Ruby version is set'
115
116### versions
117complete -f -c rbenv -n __fish_rbenv_needs_command -a versions -d 'List all Ruby versions known by rbenv'
118
119### whence
120complete -f -c rbenv -n __fish_rbenv_needs_command -a whence -d 'List all Ruby versions that contain the given executable'
121complete -f -c rbenv -n '__fish_rbenv_using_command whence' -a --path
122
123### which
124complete -f -c rbenv -n __fish_rbenv_needs_command -a which -d 'Show the full path for the given Ruby executable'
125complete -f -c rbenv -n '__fish_rbenv_using_command which' -a '(__fish_rbenv_executables)'