3 # AX-ZSH: Alex' Modular ZSH Configuration
4 # Copyright (c) 2015-2016 Alexander Barton <alex@barton.de>
7 # Include "ax-common.sh", if available:
8 for dir ("$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr); do
9 [[ -z "$ax_common_sourced" ]] || break
10 ax_common="${dir}/lib/ax/ax-common.sh"
11 [[ -r "$ax_common" ]] && source "$ax_common"
13 if [[ -z "$ax_common_sourced" ]]; then
16 "1"|"2") echo -n "! "; ;;
23 unset dir ax_common ax_common_sourced
26 echo "Usage: $NAME <command> [...]"
28 echo " enable-plugin <name|directory> [<name|directory> [...]]"
29 echo " Enable plugin(s)."
31 echo " disable-plugin <name> [<name> [...]]"
32 echo " Disable plugin(s)."
35 echo " Reset active plugins to the default set."
37 echo " enable-default-plugins"
38 echo " Enable all default plugins."
40 echo " set-theme <name>|-"
41 echo " Set active theme to <name>, or to the default."
44 echo " Upgrade AX-ZSH installation (requires Git)."
49 function EnablePlugin {
50 local dir="$AXZSH/active_plugins"
52 if [[ -h "$dir/$1" ]]; then
53 ax_msg 1 "Plugin \"$1\" already active!"
59 "$AXZSH_PLUGIN_D/$plugin"
61 "$AXZSH/custom_plugins/$plugin"
62 "$AXZSH/plugins/$plugin"
63 "$AXZSH/default_plugins/$plugin"
66 [[ ! -d "$dname" ]] && continue
70 ln -sv "$dname" "$PWD"
75 ax_msg 2 "Plugin \"$1\" not found!"
79 function DisablePlugin {
80 local dir="$AXZSH/active_plugins"
82 if [[ ! -h "$dir/$1" ]]; then
83 ax_msg 1 "Plugin \"$1\" not active?"
91 function ResetPlugins {
92 local dir="$AXZSH/active_plugins"
94 if [[ -e "$dir" ]]; then
95 ax_msg - "Removing all symbolic links in $dir ..."
96 find "$dir" -type l -print -delete
101 function EnableDefaultPlugins {
102 local dir="$AXZSH/active_plugins"
104 ax_msg - "Activating (linking) default plugins ..."
108 ln -sfv "$AXZSH/default_plugins/"* "$PWD"
114 local link_name="$AXZSH/active_theme"
116 if [ $# -ne 1 ]; then
117 echo "Usage: axzsh_set_theme <name|->"
121 rm -f "$link_name" || return 1
123 if [ "$1" = "-" ]; then
124 echo "Theme settings have been reset."
130 elif [ -r "$AXZSH/custom_themes/$1.axzshtheme" ]; then
131 theme="$AXZSH/custom_themes/$1.axzshtheme"
132 elif [ -r "$AXZSH/themes/$1.axzshtheme" ]; then
133 theme="$AXZSH/themes/$1.axzshtheme"
135 echo "Theme \"$1\" not found!"
138 ln -sv "$theme" "$link_name" || return 1
142 function UpgradeAXZSH {
143 if [[ $+commands[git] -eq 0 ]]; then
144 ax_msg 2 "The git(1) command is not available!"
147 if [[ ! -d "$AXZSH/.git" ]]; then
148 ax_msg 2 "AX-ZSH seems not to be installed using Git. Can't upgrade!"
152 ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..."
153 ( cd "$AXZSH" && git pull --ff-only )
158 [[ $# -gt 0 ]] || Usage
160 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
161 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
170 [[ $# -gt 0 ]] || Usage
171 for plugin in "$@"; do
172 EnablePlugin "$plugin"
176 [[ $# -gt 0 ]] || Usage
177 for plugin in "$@"; do
178 DisablePlugin "$plugin"
182 [[ $# -eq 0 ]] || Usage
186 "enable-default-plugins")
187 [[ $# -eq 0 ]] || Usage
191 [[ $# -eq 1 ]] || Usage
195 [[ $# -eq 0 ]] || Usage