This commit is contained in:
GitHub Merge Button 2012-04-18 08:29:58 -07:00
commit e39b3a4d8b
6 changed files with 145 additions and 2 deletions

37
bin/omz.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/zsh
function omz_usage() {
echo "Oh My Zsh command line tool. Available commands:"
echo " plugin Manage plugins"
echo " theme_chooser Preview themes"
echo " upgrade Upgrade Oh My Zsh"
echo " uninstall Remove Oh My Zsh :("
echo " help Show this help"
}
OMZ_COMMAND=$1
case $OMZ_COMMAND in
'' | help )
omz_usage
;;
plugin )
shift 1
source $ZSH/tools/$OMZ_COMMAND.sh $@
;;
* )
shift 1
if [ -x $ZSH/tools/$OMZ_COMMAND.sh ]; then
zsh $ZSH/tools/$OMZ_COMMAND.sh $@
else
omz_usage
fi
;;
esac
# Clean global vars
unfunction omz_usage
unset OMZ_COMMAND

View file

@ -7,7 +7,7 @@ fi
# Initializes Oh My Zsh
# add a function path
fpath=($ZSH/functions $ZSH/completions $fpath)
fpath=($ZSH/tools $fpath)
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
@ -74,3 +74,6 @@ else
fi
fi
# Add omz command line tool
export PATH="$ZSH/bin:$PATH"
alias omz="source omz.sh"

38
tools/_omz.sh Normal file
View file

@ -0,0 +1,38 @@
#compdef omz.sh
#autoload
_omz_all_plugins() {
plugins=(`ls $ZSH/plugins`)
}
local -a _1st_arguments
_1st_arguments=(
'plugin:Manage plugins'
'theme_chooser:Preview themes'
'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

56
tools/plugin.sh Executable file
View file

@ -0,0 +1,56 @@
#!/bin/zsh
function omz_plugin_usage() {
echo "Usage: omz plugin [options] [plugin]"
echo "Enable [plugin] in current session"
echo
echo "Options"
echo " -l List available plugins"
echo " -h Show this help message"
}
function omz_plugin_exit_clean() {
unset OMZ_OPTION
unset OMZ_PLUGIN
unfunction omz_plugin_usage
unfunction omz_plugin_exit_clean
return
}
OPTIND=0
while getopts "lh" OMZ_OPTION
do
case $OMZ_OPTION in
l ) ls $ZSH/plugins
omz_plugin_exit_clean
return ;;
* ) omz_plugin_usage
omz_plugin_exit_clean
return ;;
esac
done
if [ -n "$1" ]; then
OMZ_PLUGIN="$ZSH/plugins/$1"
if [ -d $OMZ_PLUGIN ]; then
fpath=($OMZ_PLUGIN $fpath)
autoload -U compinit
compinit -i
if [ -e $OMZ_PLUGIN/$1.plugin.zsh ]; then
source $OMZ_PLUGIN/$1.plugin.zsh
fi
echo "\033[0;32mPlugin $1 enabled"
else
echo "\033[1;31mPlugin $1 not found"
fi
else
omz_plugin_usage
fi
# Clean global vars
omz_plugin_exit_clean
return

11
tools/uninstall.sh Normal file → Executable file
View file

@ -1,3 +1,12 @@
#!/bin/zsh
### Better prompt the user!
echo -n "\033[0;33mAre you sure to completely remove Oh My Zsh?\033[0m"
read "a? [type 'yes' to continue] "
if [[ $a != "yes" ]]; then
return 0
fi
echo "Removing ~/.oh-my-zsh"
if [[ -d ~/.oh-my-zsh ]]
then
@ -17,4 +26,4 @@ else
source /etc/profile
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."

0
tools/upgrade.sh Normal file → Executable file
View file