3 # AX-ZSH: Alex' Modular ZSH Configuration
4 # Copyright (c) 2015 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 "$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."
41 echo " Upgrade AX-ZSH installation (requires Git)."
46 function EnablePlugin {
47 local dir="$AXZSH/active_plugins"
49 if [[ -h "$dir/$1" ]]; then
50 ax_msg 1 "Plugin \"$1\" already active!"
56 "$AXZSH_PLUGIN_D/$plugin"
58 "$AXZSH/custom_plugins/$plugin"
59 "$AXZSH/plugins/$plugin"
60 "$AXZSH/default_plugins/$plugin"
63 [[ ! -d "$dname" ]] && continue
67 ln -sv "$dname" "$PWD"
72 ax_msg 2 "Plugin \"$1\" not found!"
76 function DisablePlugin {
77 local dir="$AXZSH/active_plugins"
79 if [[ ! -h "$dir/$1" ]]; then
80 ax_msg 1 "Plugin \"$1\" not active?"
88 function ResetPlugins {
89 local dir="$AXZSH/active_plugins"
91 if [[ -e "$dir" ]]; then
92 ax_msg - "Removing all symbolic links in $dir ..."
93 find "$dir" -type l -print -delete
98 function EnableDefaultPlugins {
99 local dir="$AXZSH/active_plugins"
101 ax_msg - "Activating (linking) default plugins ..."
105 ln -sfv "$AXZSH/default_plugins/"* "$PWD"
110 function UpgradeAXZSH {
111 if [[ $+commands[git] -eq 0 ]]; then
112 ax_msg 2 "The git(1) command is not available!"
115 if [[ ! -d "$AXZSH/.git" ]]; then
116 ax_msg 2 "AX-ZSH seems not to be installed using Git. Can't upgrade!"
120 ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..."
121 ( cd "$AXZSH" && git pull --ff-only )
124 NAME="$(basename "$0")"
126 [[ $# -gt 0 ]] || Usage
128 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
129 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
138 [[ $# -gt 0 ]] || Usage
139 for plugin in "$@"; do
140 EnablePlugin "$plugin"
144 [[ $# -gt 0 ]] || Usage
145 for plugin in "$@"; do
146 DisablePlugin "$plugin"
150 [[ $# -eq 0 ]] || Usage
154 "enable-default-plugins")
155 [[ $# -eq 0 ]] || Usage
159 [[ $# -eq 0 ]] || Usage