]> arthur.barton.de Git - ax-zsh.git/blobdiff - ax.zsh
ssh: Slightly enhance file comments
[ax-zsh.git] / ax.zsh
diff --git a/ax.zsh b/ax.zsh
index f460ba6b2dc0b181918a2896afacf243177b7965..2736da96fab13318002774a21cb436266c38848f 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -9,16 +9,30 @@ script_type="$script_name[2,-1]"
 # - $1: Script name
 # - $2: Stage name (ax-io, zprofile, zshrc, zlogin, zlogout)
 function axzsh_handle_stage {
-       name="$1"
-       type="$2"
+       local name="$1"
+       local type="$2"
 
        [[ -n "$AXZSH_DEBUG" ]] && echo "ยป $name ($type):"
 
+       # Look for some 3rd-party integrations ...
+
+       # --- Powerlevel10k ---
+       # Read in Powerlevel10k configuration file, if not already read:
+       [[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
+       # Enable instant prompt. Should stay close to the top of ~/.zshrc.
+       # Initialization code that may require console input (password prompts,
+       # [y/n] confirmations, etc.) must be executed before this, so all ax-zsh
+       # plugings should do output in their "zprofile" stage!
+       if [[ "$type" == "zprofile" ]]; then
+               p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
+               [[ -r "$p10k_instant_prompt" ]] && source "$p10k_instant_prompt"
+       fi
+
        # Initialize cache
        mkdir -p "$AXZSH/cache"
-       cache_file="$AXZSH/cache/$type.cache"
+       local cache_file="$AXZSH/cache/$type.cache"
 
-       cat_cmd=${commands[cat]:-cat}
+       local cat_cmd=${commands[cat]:-cat}
 
        if [[ -r "$cache_file" ]]; then
                # Cache file exists, use it!
@@ -36,6 +50,7 @@ function axzsh_handle_stage {
        else
                # No cache file available.
                # Setup list of plugins to load:
+               local plugin_list
                typeset -U plugin_list
                plugin_list=(
                        "$AXZSH/core/"[0-5]*
@@ -112,6 +127,10 @@ function axzsh_load_plugin {
                        # Oh My ZSH plugin with "zsh-" prefix stripped
                        type="plugin.zsh"
                        fname="$dname/${plugin_short##zsh-}.plugin.zsh"
+               elif [[ -r "$dname/${plugin%.plugin.zsh}.plugin.zsh" ]]; then
+                       # Oh My ZSH plugin with ".plugin.zsh" suffix in its name
+                       type="plugin.zsh"
+                       fname="$dname/${plugin}"
                elif [[ -r "$dname/init.zsh" ]]; then
                        # Prezto module
                        type="init.zsh"
@@ -191,14 +210,16 @@ fi
 [[ -n "$SHELL" ]] || export SHELL=$(command -v zsh)
 
 # Make sure that "AXZSH" variable is set and exported
-if [[ -z "$AXZSH" ]]; then
-       export AXZSH="$HOME/.axzsh"
-       if [[ -f "$HOME/.axzsh.debug" ]]; then
-               export AXZSH_DEBUG=1
-               echo "AXZSH=$AXZSH"
-               echo "AXZSH_DEBUG=$AXZSH_DEBUG"
-               echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
-       fi
+[[ -n "$AXZSH" ]] || export AXZSH="$HOME/.axzsh"
+
+# Check for "debug mode" ...
+if [[ -f "$AXZSH/debug" || -f "$HOME/.axzsh.debug" ]]; then
+       export AXZSH_DEBUG=1
+       echo "AXZSH=$AXZSH"
+       echo "AXZSH_DEBUG=$AXZSH_DEBUG"
+       echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
+       echo "AXZSH_ZLOGIN_READ=$AXZSH_ZLOGIN_READ"
+       echo "AXZSH_ZPROFILE_READ=$AXZSH_ZPROFILE_READ"
 fi
 
 if [[ "$script_type" = "zprofile" ]]; then
@@ -206,20 +227,6 @@ if [[ "$script_type" = "zprofile" ]]; then
        axzsh_handle_stage "$script_name" "ax-io"
 fi
 
-# Look for some 3rd-party integrations ...
-
-# --- Powerlevel10k ---
-# Read in Powerlevel10k configuration file, if not already read:
-[[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
-# Enable instant prompt. Should stay close to the top of ~/.zshrc.
-# Initialization code that may require console input (password prompts,
-# [y/n] confirmations, etc.) must be executed before this, so all ax-zsh
-# plugings should do output in their "zprofile" stage!
-if [[ "$script_type" == "zprofile" ]]; then
-       p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
-       [[ -r "$p10k_instant_prompt" ]] && source "$p10k_instant_prompt"
-fi
-
 axzsh_handle_stage "$script_name" "$script_type"
 
 # Clean up ...