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."
40 function EnablePlugin {
41 local dir="$AXZSH/active_plugins"
43 if [[ -h "$dir/$1" ]]; then
44 ax_msg 1 "Plugin \"$1\" already active!"
50 "$AXZSH_PLUGIN_D/$plugin"
52 "$AXZSH/plugins/$plugin"
53 "$AXZSH/default_plugins/$plugin"
56 [[ ! -d "$dname" ]] && continue
60 ln -sv "$dname" "$PWD"
65 ax_msg 2 "Plugin \"$1\" not found!"
69 function DisablePlugin {
70 local dir="$AXZSH/active_plugins"
72 if [[ ! -h "$dir/$1" ]]; then
73 ax_msg 1 "Plugin \"$1\" not active?"
81 function ResetPlugins {
82 local dir="$AXZSH/active_plugins"
84 if [[ -e "$dir" ]]; then
85 ax_msg - "Removing all symbolic links in $dir ..."
86 find "$dir" -type l -print -delete
89 ax_msg - "Activating (linking) default plugins ..."
93 ln -sv "$AXZSH/default_plugins/"* "$PWD"
98 NAME="$(basename "$0")"
100 [[ $# -gt 0 ]] || Usage
102 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
103 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
112 [[ $# -gt 0 ]] || Usage
113 for plugin in "$@"; do
114 EnablePlugin "$plugin"
118 [[ $# -gt 0 ]] || Usage
119 for plugin in "$@"; do
120 DisablePlugin "$plugin"
124 [[ $# -eq 0 ]] || Usage