mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
version 0.1 from current upstream project https://github.com/mbauhardt/oh-my-zsh-bootstrap
This commit is contained in:
parent
c79e5a97a9
commit
a51a305d18
5 changed files with 215 additions and 0 deletions
7
plugins/oh-my-zsh-bootstrap/README.md
Normal file
7
plugins/oh-my-zsh-bootstrap/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Oh My Zsh Bootstrap
|
||||
|
||||
_Oh My Zsh Bootstrap_ is a plugin for [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
|
||||
|
||||
See current upstream project https://github.com/mbauhardt/oh-my-zsh-bootstrap for more information.
|
||||
|
||||
|
||||
22
plugins/oh-my-zsh-bootstrap/lib/download.zsh
Normal file
22
plugins/oh-my-zsh-bootstrap/lib/download.zsh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
_clone_git() {
|
||||
local url=$1
|
||||
local folder=$2
|
||||
if [[ ! -d "$folder" ]]; then
|
||||
git clone $url $folder
|
||||
fi
|
||||
}
|
||||
|
||||
_download_plugin() {
|
||||
[[ "$#" != 2 ]] && return 1
|
||||
local url=$1; local name=$2;
|
||||
_clone_git $url $ZSH_CUSTOM/plugins/$name
|
||||
_map_put plugins $name enabled
|
||||
}
|
||||
|
||||
_download_theme() {
|
||||
[[ "$#" != 2 ]] && return 1
|
||||
local url=$1; local theme=$2;
|
||||
_clone_git $url $ZSH_CUSTOM/themes/$theme
|
||||
ln -s $ZSH_CUSTOM/themes/$theme/$theme.zsh-theme $ZSH_CUSTOM/$theme.zsh-theme
|
||||
_map_put themes theme $theme
|
||||
}
|
||||
40
plugins/oh-my-zsh-bootstrap/lib/map.zsh
Normal file
40
plugins/oh-my-zsh-bootstrap/lib/map.zsh
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
mapdir=$ZSH_BOOTSTRAP/data
|
||||
|
||||
_map_init() {
|
||||
mkdir -p $mapdir
|
||||
}
|
||||
|
||||
_map_put() {
|
||||
[[ "$#" != 3 ]] && return 1
|
||||
mapname=$1; key=$2; value=$3
|
||||
[[ -d "${mapdir}/${mapname}" ]] || mkdir "${mapdir}/${mapname}"
|
||||
echo $value >"${mapdir}/${mapname}/${key}"
|
||||
}
|
||||
|
||||
_map_get() {
|
||||
[[ "$#" != 2 ]] && return 1
|
||||
mapname=$1; key=$2
|
||||
cat "${mapdir}/${mapname}/${key}"
|
||||
}
|
||||
|
||||
_map_keys() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
mapname=$1
|
||||
for key ($mapdir/$mapname/*); do
|
||||
basename $key
|
||||
done
|
||||
}
|
||||
|
||||
_map_exists() {
|
||||
[[ "$#" != 2 ]] && return 1
|
||||
mapname=$1; key=$2
|
||||
[[ -f "${mapdir}/${mapname}/${key}" ]] && return 0
|
||||
}
|
||||
|
||||
_map_remove() {
|
||||
[[ "$#" != 2 ]] && return 1
|
||||
mapname=$1; key=$2
|
||||
rm "${mapdir}/${mapname}/${key}"
|
||||
}
|
||||
_map_init
|
||||
|
||||
125
plugins/oh-my-zsh-bootstrap/lib/repository.zsh
Normal file
125
plugins/oh-my-zsh-bootstrap/lib/repository.zsh
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
_init_theme() {
|
||||
_map_exists themes theme
|
||||
[[ $? -ne 0 ]] && _map_put themes theme robbyrussell
|
||||
}
|
||||
|
||||
_pre_enable_plugins() {
|
||||
for plugin ($plugins); do
|
||||
_map_put plugins $plugin pre_enabled
|
||||
done
|
||||
}
|
||||
|
||||
_list_plugins() {
|
||||
for plugin ($ZSH/plugins/* $ZSH_CUSTOM/plugins/*(N)); do
|
||||
local plugin_name=$(basename $plugin)
|
||||
local enabled=disabled
|
||||
_map_exists plugins $plugin_name
|
||||
if [[ $? -eq 0 ]]; then
|
||||
enabled=$(_map_get plugins $plugin_name)
|
||||
fi
|
||||
if [[ $enabled = "pre_enabled" || $enabled = "enabled" ]]; then
|
||||
printf "%-30s \033[0;32m%-10s\033[0m\n" $plugin_name $enabled
|
||||
else
|
||||
printf "%-30s \033[0;30m%-10s\033[0m\n" $plugin_name $enabled
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_list_themes() {
|
||||
for theme ($ZSH/themes/*zsh-theme $ZSH_CUSTOM/*zsh-theme(N)); do
|
||||
local theme_name=$(basename $theme | awk -F '.' '{print $1}')
|
||||
local selected_theme=$(_map_get themes theme)
|
||||
if [[ $selected_theme = $theme_name ]]; then
|
||||
printf "%-30s \033[0;32m%-10s\033[0m\n" $theme_name enabled
|
||||
else
|
||||
printf "%-30s \033[0;30m%-10s\033[0m\n" $theme_name disabled
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_list_pre_enabled_enabled_plugins() {
|
||||
for plugin ($(_map_keys plugins)); do
|
||||
local enabled=$(_map_get plugins $plugin)
|
||||
if [[ $enabled = "enabled" ]]; then
|
||||
printf "%s " $plugin
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_list_enabled_plugins() {
|
||||
for plugin ($(_map_keys plugins)); do
|
||||
local enabled=$(_map_get plugins $plugin)
|
||||
if [[ $enabled = "pre_enabled" || $enabled = "enabled" ]]; then
|
||||
printf "%-30s \033[0;32m%-10s\033[0m\n" $plugin $enabled
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_enable_plugin() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local plugin=$1
|
||||
_map_exists plugins $plugin
|
||||
if [[ $? -ne 0 ]]; then
|
||||
_map_put plugins $plugin enabled
|
||||
fi
|
||||
}
|
||||
|
||||
_enable_theme() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local theme=$1
|
||||
_map_put themes theme $theme
|
||||
}
|
||||
|
||||
_disable_plugin() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local plugin=$1
|
||||
local enabled=$(_map_get plugins $plugin)
|
||||
[[ $enabled = "enabled" ]] && _map_remove plugins $plugin
|
||||
}
|
||||
|
||||
_populate_enabled_plugins() {
|
||||
for plugin ($(_list_pre_enabled_enabled_plugins)); do
|
||||
if [[ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]]; then
|
||||
fpath=($ZSH/plugins/$plugin $fpath)
|
||||
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||
elif [[ -f $ZSH/plugins/$plugin/_$plugin ]]; then
|
||||
fpath=($ZSH/plugins/$plugin $fpath)
|
||||
elif [[ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]]; then
|
||||
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
|
||||
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
|
||||
elif [[ -f $ZSH_CUSTOM/plugins/$plugin/_$plugin ]]; then
|
||||
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_populate_enabled_theme() {
|
||||
ZSH_THEME=$(_map_get themes theme)
|
||||
}
|
||||
|
||||
_update_plugin() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local plugin=$1
|
||||
if [[ -d $ZSH_CUSTOM/plugins/$plugin ]]; then
|
||||
pushd $ZSH_CUSTOM/plugins/$plugin > /dev/null
|
||||
git pull
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
_update_theme() {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local theme=$1
|
||||
if [[ -d $ZSH_CUSTOM/themes/$theme ]]; then
|
||||
pushd $ZSH_CUSTOM/themes/$theme > /dev/null
|
||||
git pull
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
_pre_enable_plugins
|
||||
_populate_enabled_plugins
|
||||
_init_theme
|
||||
_populate_enabled_theme
|
||||
21
plugins/oh-my-zsh-bootstrap/oh-my-zsh-bootstrap.plugin.zsh
Normal file
21
plugins/oh-my-zsh-bootstrap/oh-my-zsh-bootstrap.plugin.zsh
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
_load_bootstrap() {
|
||||
export ZSH_BOOTSTRAP=$1
|
||||
source $ZSH_BOOTSTRAP/lib/map.zsh
|
||||
source $ZSH_BOOTSTRAP/lib/repository.zsh
|
||||
source $ZSH_BOOTSTRAP/lib/download.zsh
|
||||
}
|
||||
|
||||
[[ -f $ZSH_CUSTOM/plugins/oh-my-zsh-bootstrap/oh-my-zsh-bootstrap.plugin.zsh ]] && _load_bootstrap $ZSH_CUSTOM/plugins/oh-my-zsh-bootstrap
|
||||
[[ -f $ZSH/plugins/oh-my-zsh-bootstrap/oh-my-zsh-bootstrap.plugin.zsh ]] && _load_bootstrap $ZSH/plugins/oh-my-zsh-bootstrap
|
||||
|
||||
|
||||
alias list_plugins="_list_plugins|less"
|
||||
alias list_themes="_list_themes|less"
|
||||
alias download_and_enable_plugin="_download_plugin"
|
||||
alias download_and_enable_theme="_download_theme"
|
||||
alias list_enabled_plugins="_list_enabled_plugins"
|
||||
alias enable_plugin="_enable_plugin"
|
||||
alias enable_theme="_enable_theme"
|
||||
alias disable_plugin="_disable_plugin"
|
||||
alias update_plugin="_udpate_plugin"
|
||||
alias update_theme="_update_theme"
|
||||
Loading…
Add table
Add a link
Reference in a new issue