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 [[ -f "$HOME/.axzsh.debug" ]] && echo "ยป $script_name:"
9 # Load plugin code of a given type.
11 # - $2: plugin type (optional; defaults to "zshrc")
12 function axzsh_load_plugin {
14 [[ -z "$2" ]] && type="zshrc" || type="$2"
17 "$AXZSH_PLUGIN_D/$plugin" \
18 "$AXZSH/plugins/$plugin" \
19 "$AXZSH/core/$plugin" \
21 [[ ! -d "$dname" ]] && continue
23 fname="$dname/$plugin.$type"
24 if [[ ! -r "$fname" && "$type" == "zshrc" ]]; then
25 if [[ -r "$dname/$plugin.plugin.zsh" ]]; then
28 fname="$dname/$plugin.plugin.zsh"
29 elif [[ -r "$dname/init.zsh" ]]; then
32 fname="$dname/init.zsh"
36 if [[ -r "$fname" ]]; then
37 [[ -f "$HOME/.axzsh.debug" ]] \
38 && echo " - $plugin ($type) ..."
45 if [[ -f "$HOME/.axzsh.debug" ]]; then
46 # Show error message for all stages in "debug mode":
47 echo "AX-ZSH plugin \"$plugin\" not found (type \"$type\")!" >&2
48 elif [[ "$type" == "zshrc" ]]; then
49 # Show error message for the "zshrc" stage:
50 echo "AX-ZSH plugin \"$plugin\" not found, skipped!" >&2
55 # Make sure that "AXZSH" variable is set and exported
56 if [[ -z "$AXZSH" ]]; then
57 export AXZSH="$HOME/.axzsh"
58 if [[ -f "$HOME/.axzsh.debug" ]]; then
60 echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
64 # Setup list of default plugins if not set already. This allows users to
65 # overwrite this list in their "~/.zshenv" file, for example.
66 typeset -U axzsh_default_plugins
67 if ! typeset +m axzsh_default_plugins | fgrep array >/dev/null 2>&1; then
68 axzsh_default_plugins=(
81 # Setup list of plugins to load:
82 typeset -U plugin_list
85 $axzsh_default_plugins
91 # Read in all the plugins for the current "type":
92 for plugin ($plugin_list); do
93 axzsh_load_plugin "$(basename "$plugin")" "$script_type"
95 unset script_name script_type plugin