From f722f3d1cebc757f0d32b323bb744d40040a2909 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 27 Oct 2019 11:27:03 +0100 Subject: [PATCH] add direnv segment; fixes 291 --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ config/p10k-rainbow.zsh | 8 ++++++++ internal/icons.zsh | 13 +++++++++---- internal/p10k.zsh | 6 ++++++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index a7d5ee62..5f1424ab 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -44,6 +44,7 @@ status # exit code of the last command command_execution_time # duration of the last command background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) anaconda # conda environment (https://conda.io/) pyenv # python environment (https://github.com/pyenv/pyenv) @@ -490,6 +491,12 @@ # Icon to show when there are background jobs. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Icon to show when direnv is active. + typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 43479409..e06eb555 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -44,6 +44,7 @@ status # exit code of the last command command_execution_time # duration of the last command background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) anaconda # conda environment (https://conda.io/) pyenv # python environment (https://github.com/pyenv/pyenv) @@ -470,6 +471,12 @@ # Icon to show when there are background jobs. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⇶' + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Icon to show when direnv is active. + typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 751a85e3..c1e70030 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -44,6 +44,7 @@ status # exit code of the last command command_execution_time # duration of the last command background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) anaconda # conda environment (https://conda.io/) pyenv # python environment (https://github.com/pyenv/pyenv) @@ -486,6 +487,13 @@ # Icon to show when there are background jobs. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + # typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3 + # typeset -g POWERLEVEL9K_DIRENV_BACKGROUND=0 + # Icon to show when direnv is active. + typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. # typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7 diff --git a/internal/icons.zsh b/internal/icons.zsh index b1c1d4c1..8bef2168 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -114,7 +114,8 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' - AZURE_ICON '\u2601' # ☁ + AZURE_ICON '\u2601' # ☁ + DIRENV_ICON '\u25BC' # ▼ ) ;; 'awesome-fontconfig') @@ -216,7 +217,8 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' - AZURE_ICON '\u2601' # ☁ + AZURE_ICON '\u2601' # ☁ + DIRENV_ICON '\u25BC' # ▼ ) ;; 'awesome-mapped-fontconfig') @@ -323,6 +325,7 @@ function _p9k_init_icons() { PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' AZURE_ICON '\u2601' # ☁ + DIRENV_ICON '\u25BC' # ▼ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -426,6 +429,7 @@ function _p9k_init_icons() { PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '\uE77F' #  AZURE_ICON '\uFD03' # ﴃ + DIRENV_ICON '\u25BC' # ▼ ) ;; *) @@ -446,7 +450,7 @@ function _p9k_init_icons() { AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\u2699' # ⚙ TEST_ICON '' - TODO_ICON '\u2611' # ☑ (portable alternatives: ▼ ∆) + TODO_ICON '\u2611' # ☑ (portable alternative: ∆) BATTERY_ICON '\U1F50B' # 🔋 DISK_ICON 'hdd' OK_ICON '\u2714' # ✔ @@ -525,9 +529,10 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u2B82' # ⮂ + PROXY_ICON '\u2194' # ↔ DOTNET_ICON '.NET' AZURE_ICON '\u2601' # ☁ + DIRENV_ICON '\u25BC' # ▼ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index fd9b41de..2b924a28 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3347,6 +3347,12 @@ function prompt_proxy() { _p9k_prompt_segment $0 $_p9k_color1 blue PROXY_ICON 0 '' "$p[1]" } +function prompt_direnv() { + _p9k_prompt_segment $0 $_p9k_color1 yellow DIRENV_ICON 0 '$DIRENV_DIR' '' +} + +function instant_prompt_direnv() { prompt_direnv; } + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then