Add fish support.

This commit is contained in:
Daniel Perez 2016-04-18 16:33:14 +09:00
parent cf942c8642
commit 3d388ec0a2
3 changed files with 98 additions and 0 deletions

View File

@ -25,6 +25,13 @@ echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile
If you use zsh or any other shell, replace `.bashrc` with the config file for the respective shell. If you use zsh or any other shell, replace `.bashrc` with the config file for the respective shell.
For fish, you can use the following:
```
echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
```
> For most plugins, it is good if you have installed the following packages OR their equivalent on you OS > For most plugins, it is good if you have installed the following packages OR their equivalent on you OS
> * **OS X**: Install these via homebrew `automake autoconf openssl libyaml readline libxslt libtool unixodbc` > * **OS X**: Install these via homebrew `automake autoconf openssl libyaml readline libxslt libtool unixodbc`

8
asdf.fish Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env fish
set -l asdf_dir (dirname (status -f))
# we get an ugly warning when setting the path if shims does not exist
mkdir -p $asdf_dir/shims
set -xg PATH $asdf_dir/bin $asdf_dir/shims $PATH

83
completions/asdf.fish Normal file
View File

@ -0,0 +1,83 @@
function __fish_asdf_needs_command
set -l cmd (commandline -opc)
if test (count $cmd) -eq 1
return 0
end
return 1
end
function __fish_asdf_using_command -a current_command
set -l cmd (commandline -opc)
if test (count $cmd) -gt 1
if test $current_command = $cmd[2]
return 0
end
end
return 1
end
function __fish_asdf_arg_number -a number
set -l cmd (commandline -opc)
test (count $cmd) -eq $number
end
function __fish_asdf_arg_at -a number
set -l cmd (commandline -opc)
echo $cmd[$number]
end
set -l official_plugins ruby erlang nodejs elixir
# plugin-add completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-add -d "Add git repo as plugin"
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 2' -a (echo $official_plugins)
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 3' -a '(echo https://github.com/asdf-vm/asdf-(__fish_asdf_arg_at 3).git)'
# plugin-list completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-list -d "List installed plugins"
# plugin-remove completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-remove -d "Remove plugin and package versions"
complete -f -c asdf -n '__fish_asdf_using_command plugin-remove; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)' -A
# plugin-update completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-update -d "Update plugin"
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)' -A
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a --all -A
# install completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a install -d "Install a specific version of a package"
complete -f -c asdf -n '__fish_asdf_using_command install; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
complete -f -c asdf -n '__fish_asdf_using_command install; and __fish_asdf_arg_number 3' -a '(asdf list-all (__fish_asdf_arg_at 3))'
# uninstall completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a uninstall -d "Remove a specific version of a package"
complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 3' -a '(asdf list (__fish_asdf_arg_at 3))'
# which completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a which -d "Display version set or being used for package"
complete -f -c asdf -n '__fish_asdf_using_command which; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
# where completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a where -d "Display install path for an installed version"
complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 3' -a '(asdf list (__fish_asdf_arg_at 3))'
# list completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a list -d "List installed versions of a package"
complete -f -c asdf -n '__fish_asdf_using_command list; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
# list-all completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a list-all -d "List all versions of a package"
complete -f -c asdf -n '__fish_asdf_using_command list-all; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
# reshim completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a reshim -d "Recreate shims for version of a package"
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 2' -a '(asdf plugin-list)'
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 3' -a '(asdf list (__fish_asdf_arg_at 3))'
# misc
complete -f -c asdf -n '__fish_asdf_needs_command' -l "help" -d "Displays help"
complete -f -c asdf -n '__fish_asdf_needs_command' -l "version" -d "Displays asdf version"