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/plugins/$plugin"
56 "$AXZSH/default_plugins/$plugin"
59 [[ ! -d "$dname" ]] && continue
63 ln -sv "$dname" "$PWD"
68 ax_msg 2 "Plugin \"$1\" not found!"
72 function DisablePlugin {
73 local dir="$AXZSH/active_plugins"
75 if [[ ! -h "$dir/$1" ]]; then
76 ax_msg 1 "Plugin \"$1\" not active?"
84 function ResetPlugins {
85 local dir="$AXZSH/active_plugins"
87 if [[ -e "$dir" ]]; then
88 ax_msg - "Removing all symbolic links in $dir ..."
89 find "$dir" -type l -print -delete
94 function EnableDefaultPlugins {
95 local dir="$AXZSH/active_plugins"
97 ax_msg - "Activating (linking) default plugins ..."
101 ln -sfv "$AXZSH/default_plugins/"* "$PWD"
106 NAME="$(basename "$0")"
108 [[ $# -gt 0 ]] || Usage
110 if [[ -z "$AXZSH" || ! -d "$AXZSH" ]]; then
111 ax_msg 2 "Oops, \"AXZSH\" is not set or invalid!"
120 [[ $# -gt 0 ]] || Usage
121 for plugin in "$@"; do
122 EnablePlugin "$plugin"
126 [[ $# -gt 0 ]] || Usage
127 for plugin in "$@"; do
128 DisablePlugin "$plugin"
132 [[ $# -eq 0 ]] || Usage
136 "enable-default-plugins")
137 [[ $# -eq 0 ]] || Usage