mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
omz tool to dynamically load plugins
This commit is contained in:
parent
42d1ae029c
commit
b326820004
5 changed files with 100 additions and 41 deletions
38
tools/_omz.sh
Normal file
38
tools/_omz.sh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#compdef omz.sh
|
||||
#autoload
|
||||
|
||||
_omz_all_plugins() {
|
||||
plugins=(`ls $ZSH/plugins`)
|
||||
}
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'plugin:Enable plugin'
|
||||
'theme:Choose theme'
|
||||
'upgrade:Upgrade OH MY ZSH!'
|
||||
'uninstall:Remove OH MY ZSH! :('
|
||||
)
|
||||
|
||||
local expl
|
||||
local -a plugins all_plugins
|
||||
|
||||
_arguments \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "omz.sh subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
plugin )
|
||||
_arguments \
|
||||
'1: :->name' && return 0
|
||||
|
||||
if [[ "$state" == name ]]; then
|
||||
_omz_all_plugins
|
||||
_wanted plugins expl 'all plugins' compadd -a plugins
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
19
tools/omz-plugin.sh
Executable file
19
tools/omz-plugin.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
# Load plugin passed as first arg
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
PLUGIN="$ZSH/plugins/$1"
|
||||
|
||||
if [ -d $PLUGIN ]; then
|
||||
fpath=($PLUGIN $fpath)
|
||||
source $PLUGIN/*.plugin.zsh
|
||||
autoload -U compinit
|
||||
compinit -i
|
||||
echo "$1 enabled!"
|
||||
else
|
||||
echo "Plugin '$1' not found!"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "Please specify a plugin"
|
||||
return 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue