]> arthur.barton.de Git - ax-zsh.git/commitdiff
Integrate support for Powerlevel10k, including "instant prompt"
authorAlexander Barton <alex@barton.de>
Thu, 11 Jun 2020 12:05:21 +0000 (14:05 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 11 Jun 2020 12:05:21 +0000 (14:05 +0200)
- <https://github.com/romkatv/powerlevel10k>,
- <https://github.com/romkatv/powerlevel10k#instant-prompt>

ax.zsh
bin/axzshctl

diff --git a/ax.zsh b/ax.zsh
index 2d7bd66b6093f705d3cca365871fcb098612285e..23eda0166f99d31368b2f0e19cec0de2f5acaef1 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -206,6 +206,20 @@ if [[ "$script_type" = "zprofile" ]]; then
        axzsh_handle_stage "$script_name" "ax-io"
 fi
 
        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 ...
 axzsh_handle_stage "$script_name" "$script_type"
 
 # Clean up ...
index efc8a982f3d939f00ef8c13dc632c9067728046a..05062bd346c02c636bcc747de96a8c1ce654e028 100755 (executable)
@@ -220,6 +220,10 @@ function EnableDefaultPlugins {
 function SetTheme {
        local link_name="$AXZSH/active_theme"
 
 function SetTheme {
        local link_name="$AXZSH/active_theme"
 
+       # --- Powerlevel10k ---
+       # Remove "instant prompt" configuration, if any ...
+       rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
+
        if [[ "$1" = "-" ]]; then
                rm -f "$link_name" || return 1
                ax_msg 0 "Theme settings have been reset."
        if [[ "$1" = "-" ]]; then
                rm -f "$link_name" || return 1
                ax_msg 0 "Theme settings have been reset."