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."
43 function EnablePlugin {
44 local dir="$AXZSH/active_plugins"
46 if [[ -h "$dir/$1" ]]; then
47 ax_msg 1 "Plugin \"$1\" already active!"
53 "$AXZSH_PLUGIN_D/$plugin"
55 "$AXZSH/custom_plugins/$plugin"
56 "$AXZSH/plugins/$plugin"
57 "$AXZSH/default_plugins/$plugin"
60 [[ ! -d "$dname" ]] && continue
64 ln -sv "$dname" "$PWD"
69 ax_msg 2 "Plugin \"$1\" not found!"
73 function DisablePlugin {
74 local dir="$AXZSH/active_plugins"
76 if [[ ! -h "$dir/$1" ]]; then
77 ax_msg 1 "Plugin \"$1\" not active?"
85 function ResetPlugins {
86 local dir="$AXZSH/active_plugins"
88 if [[ -e "$dir" ]]; then
89 ax_msg - "Removing all symbolic links in $dir ..."
90 find "$dir" -type l -print -delete
95 function EnableDefaultPlugins {
96 local dir="$AXZSH/active_plugins"
98 ax_msg - "Activating (linking) default plugins ..."
102 ln -sfv "$AXZSH/default_plugins/"* "$PWD"
107 NAME="$(basename "$0")"
109 [[ $# -gt 0 ]] || Usage
111 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
112 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
121 [[ $# -gt 0 ]] || Usage
122 for plugin in "$@"; do
123 EnablePlugin "$plugin"
127 [[ $# -gt 0 ]] || Usage
128 for plugin in "$@"; do
129 DisablePlugin "$plugin"
133 [[ $# -eq 0 ]] || Usage
137 "enable-default-plugins")
138 [[ $# -eq 0 ]] || Usage