X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=ax.zsh;h=a0fb5d8b66e664e372a081ccfd2289df4d77cf6e;hb=HEAD;hp=3d693da9725fbf4cde83fec09e555017d69a6c6f;hpb=91738cf4ea15ddc93d1de29894b35698948864e0;p=ax-zsh.git diff --git a/ax.zsh b/ax.zsh index 3d693da..05f2002 100644 --- a/ax.zsh +++ b/ax.zsh @@ -1,5 +1,5 @@ # AX-ZSH: Alex' Modular ZSH Configuration -# Copyright (c) 2015-2020 Alexander Barton +# Copyright (c) 2015-2024 Alexander Barton script_name="${${(%):-%N}:t}" script_type="$script_name[2,-1]" @@ -17,16 +17,27 @@ function axzsh_handle_stage { # 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 "ax-io" stage only! - if [[ "$type" == "zprofile" ]]; then + # plugins should do output in their "ax-io" stage only! + # Read the initialization script in the "zprofile" stage for login + # shells, and in the "zshrc" stage for non-login sub-shells (which have + # the profile already read in and therefore will skip the "ax-io" and + # "zprofile" stages and not catch up). + if [[ \ + ( "$type" == "zprofile" ) || \ + ( ! -o login && "$type" == "zshrc" && -n "$AXZSH_ZPROFILE_READ" ) \ + ]]; then p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" - [[ -r "$p10k_instant_prompt" ]] && source "$p10k_instant_prompt" + if [[ -r "$p10k_instant_prompt" ]]; then + [[ -n "$AXZSH_DEBUG" ]] && echo " Reading \"$p10k_instant_prompt\" ..." + source "$p10k_instant_prompt" + fi + unset p10k_instant_prompt fi + # Read in Powerlevel10k configuration file, if not already read: + [[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh # Initialize cache [[ -d "$AXZSH/cache" ]] || mkdir -p "$AXZSH/cache" @@ -46,7 +57,7 @@ function axzsh_handle_stage { [[ -n "$AXZSH_DEBUG" ]] \ && echo " - Reading cache file \"$cache_file\" ..." source "$cache_file" - unfunction axzsh_plugin_init + (( $+functions[axzsh_plugin_init] )) && unfunction axzsh_plugin_init else # No cache file available. local new_cache_file="$cache_file.NEW" @@ -65,6 +76,17 @@ function axzsh_handle_stage { && echo " (Writing new cache file to \"$new_cache_file\" ...)" if ! printf "# %s\n\n" "$(LC_ALL=C date)" >"$new_cache_file"; then unset new_cache_file + else + # New cache file successfully created ... + if [[ "$type" = "ax-io" ]]; then + # AX-IO Stage: + # Write an initial PATH variable to the cache + # file, which becomes overwritten by the path + # plugin at the "zprofile" stage later on, but + # this way "ax-io" stage plugins have a somewhat + # saner PATH to begin with ... + printf 'export PATH="%s"\n\n' "$PATH" >>"$new_cache_file" + fi fi # Read in all the plugins for the current "type": @@ -217,7 +239,7 @@ fi [[ -n "$SHELL" ]] || export SHELL=$(command -v zsh) # Make sure that "AXZSH" variable is set and exported -[[ -n "$AXZSH" ]] || export AXZSH="$HOME/.axzsh" +[[ -n "$AXZSH" ]] || export AXZSH="${ZDOTDIR:-$HOME}/.axzsh" # Check for "debug mode" ... if [[ -f "$AXZSH/debug" || -f "$HOME/.axzsh.debug" ]]; then