1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # Copyright (c) 2015 Alexander Barton <alex@barton.de>
4 script_name="$(basename -- "${(%):-%N}")"
5 script_type="$script_name[2,-1]"
7 # Load plugin code of a given type.
9 # - $2: plugin type (optional; defaults to "zshrc")
10 function axzsh_load_plugin {
12 [[ -z "$2" ]] && type="zshrc" || type="$2"
15 "$AXZSH_PLUGIN_D/$plugin" \
16 "$AXZSH/plugins/$plugin" \
17 "$AXZSH/core/$plugin" \
19 [[ ! -d "$dname" ]] && continue
21 fname="$dname/$plugin.$type"
22 if [[ ! -r "$fname" && "$type" == "zshrc" ]]; then
23 if [[ -r "$dname/$plugin.plugin.zsh" ]]; then
26 fname="$dname/$plugin.plugin.zsh"
27 elif [[ -r "$dname/init.zsh" ]]; then
30 fname="$dname/init.zsh"
34 if [[ -r "$fname" ]]; then
35 [[ -f "$HOME/.axzsh.debug" ]] \
36 && echo " - $plugin ($type) ..."
43 if [[ -f "$HOME/.axzsh.debug" ]]; then
44 # Show error message for all stages in "debug mode":
45 echo "AX-ZSH plugin \"$plugin\" not found (type \"$type\")!" >&2
46 elif [[ "$type" == "zshrc" ]]; then
47 # Show error message for the "zshrc" stage:
48 echo "AX-ZSH plugin \"$plugin\" not found, skipped!" >&2
53 # Make sure that "AXZSH" variable is set and exported
54 if [[ -z "$AXZSH" ]]; then
55 export AXZSH="$HOME/.axzsh"
56 [[ -f "$HOME/.axzsh.debug" ]] && echo "AXZSH=$AXZSH"
59 # Setup list of default plugins if not set already. This allows users to
60 # overwrite this list in their "~/.zshenv" file, for example.
61 typeset -U axzsh_default_plugins
62 if ! typeset +m axzsh_default_plugins | fgrep array >/dev/null 2>&1; then
63 axzsh_default_plugins=(
76 # Setup list of plugins to load:
77 typeset -U plugin_list
80 $axzsh_default_plugins
86 # Read in all the plugins for the current "type":
87 [[ -f "$HOME/.axzsh.debug" ]] && echo "ยป $script_name:"
88 for plugin ($plugin_list); do
89 axzsh_load_plugin "$(basename "$plugin")" "$script_type"
91 unset script_name script_type plugin