mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Add bash completion
This commit is contained in:
parent
c071a97808
commit
0ed957b59e
@ -16,9 +16,11 @@ Depending on your OS, run the following
|
|||||||
```bash
|
```bash
|
||||||
# For Ubuntu or other linux distros
|
# For Ubuntu or other linux distros
|
||||||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
|
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
|
||||||
|
echo '. $HOME/.asdf/completions/asdf.bash >> ~/.bashrc'
|
||||||
|
|
||||||
# OR for Max OSX
|
# OR for Max OSX
|
||||||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
|
echo '. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
|
||||||
|
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.
|
||||||
|
43
completions/asdf.bash
Normal file
43
completions/asdf.bash
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
_asdf () {
|
||||||
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
local cmd=${COMP_WORDS[1]}
|
||||||
|
local prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
local plugins=$(asdf plugin-list | tr '\n' ' ')
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
plugin-update)
|
||||||
|
COMPREPLY=($(compgen -W "$plugins --all" -- $cur))
|
||||||
|
;;
|
||||||
|
plugin-remove|which|list|list-all)
|
||||||
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
||||||
|
;;
|
||||||
|
install)
|
||||||
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
||||||
|
local versions=$(asdf list-all $prev)
|
||||||
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
uninstall|where|reshim)
|
||||||
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
||||||
|
local versions=$(asdf list $prev)
|
||||||
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall which where list list-all reshim'
|
||||||
|
COMPREPLY=($(compgen -W "$cmds" -- $cur))
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _asdf asdf
|
Loading…
Reference in New Issue
Block a user