mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge 172008ee26 into 1120f97305
This commit is contained in:
commit
e39b3a4d8b
6 changed files with 145 additions and 2 deletions
37
bin/omz.sh
Executable file
37
bin/omz.sh
Executable 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
|
||||||
|
|
@ -7,7 +7,7 @@ fi
|
||||||
# Initializes Oh My Zsh
|
# Initializes Oh My Zsh
|
||||||
|
|
||||||
# add a function path
|
# 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
|
# 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
|
# TIP: Add files you don't want in git to .gitignore
|
||||||
|
|
@ -74,3 +74,6 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Add omz command line tool
|
||||||
|
export PATH="$ZSH/bin:$PATH"
|
||||||
|
alias omz="source omz.sh"
|
||||||
|
|
|
||||||
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: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
56
tools/plugin.sh
Executable 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
|
||||||
9
tools/uninstall.sh
Normal file → Executable file
9
tools/uninstall.sh
Normal file → Executable 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"
|
echo "Removing ~/.oh-my-zsh"
|
||||||
if [[ -d ~/.oh-my-zsh ]]
|
if [[ -d ~/.oh-my-zsh ]]
|
||||||
then
|
then
|
||||||
|
|
|
||||||
0
tools/upgrade.sh
Normal file → Executable file
0
tools/upgrade.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue