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 <p> [<p> [...]]"
29 echo " Enable plugin(s)."
31 echo " disable-plugin <p> [<p> [...]]"
32 echo " Disable plugin(s)."
35 echo " Reset active plugins to the default list."
40 function EnablePlugin {
41 local dir="$AXZSH/active_plugins"
43 if [[ -h "$dir/$1" ]]; then
44 ax_msg 1 "Plugin \"$1\" already active!"
49 "$AXZSH_PLUGIN_D/$plugin:A"
50 "$ZSH_CUSTOM/$plugin:A"
51 "$AXZSH/plugins/$plugin:A"
52 "$AXZSH/default_plugins/$plugin:A"
53 "$AXZSH/core/$plugin:A"
55 [[ ! -d "$dname" ]] && continue
59 ln -sv "$dname" "$PWD"
64 ax_msg 2 "Plugin \"$1\" not found!"
68 function DisablePlugin {
69 local dir="$AXZSH/active_plugins"
71 if [[ ! -h "$dir/$1" ]]; then
72 ax_msg 1 "Plugin \"$1\" not active?"
80 function ResetPlugins {
81 local dir="$AXZSH/active_plugins"
83 if [[ -e "$dir" ]]; then
84 ax_msg - "Removing all symbolic links in $dir ..."
85 find "$dir" -type l -print -delete
88 ax_msg - "Activating (linking) default plugins ..."
92 ln -sv "$AXZSH/default_plugins/"* "$PWD"
97 NAME="$(basename "$0")"
99 [[ $# -gt 0 ]] || Usage
101 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
102 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
111 [[ $# -gt 0 ]] || Usage
112 for plugin in "$@"; do
113 EnablePlugin "$plugin"
117 [[ $# -gt 0 ]] || Usage
118 for plugin in "$@"; do
119 DisablePlugin "$plugin"
123 [[ $# -eq 0 ]] || Usage