mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-06-05 05:03:16 +02:00
Merge 444b3ecc99 into c99844d848
This commit is contained in:
commit
d76fe51d54
1 changed files with 57 additions and 0 deletions
57
plugins/jabba/jabba.plugin.zsh
Normal file
57
plugins/jabba/jabba.plugin.zsh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# zsh integration and autocompletions for https://github.com/shyiko/jabba"
|
||||
|
||||
jabba() {
|
||||
local fd3=$(mktemp /tmp/jabba-fd3.XXXXXX)
|
||||
(JABBA_SHELL_INTEGRATION=ON /usr/bin/jabba "$@" 3>| ${fd3})
|
||||
local exit_code=$?
|
||||
eval $(cat ${fd3})
|
||||
rm -f ${fd3}
|
||||
return ${exit_code}
|
||||
}
|
||||
|
||||
_jabba_get_command_list () {
|
||||
$_comp_command1 2>/dev/null | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
}
|
||||
|
||||
_jabba_get_installed_list () {
|
||||
$_comp_command1 ls
|
||||
}
|
||||
|
||||
_jabba_get_available_list () {
|
||||
$_comp_command1 ls-remote
|
||||
}
|
||||
|
||||
_jabba () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
':subcommand:->subcommand'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd $(_jabba_get_command_list)
|
||||
;;
|
||||
subcommand)
|
||||
case $words[2] in
|
||||
use)
|
||||
compadd $(_jabba_get_installed_list)
|
||||
;;
|
||||
install)
|
||||
compadd $(_jabba_get_available_list)
|
||||
;;
|
||||
uninstall)
|
||||
compadd $(_jabba_get_installed_list)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compdef _jabba jabba
|
||||
|
||||
# switch to default upon terminal startup
|
||||
if [ ! -z "$(jabba alias default)" ]; then
|
||||
jabba use default
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue