From 2c1dab2a28dee4a384f93ddfecac9ecabf7f2a3f Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 15 Sep 2022 19:21:16 +0200 Subject: [PATCH] config/zsh: add nesting level to prompt and disable instant https://stackoverflow.com/questions/4511407/how-do-i-know-if-im-running-a-nested-shell/4511483#4511483 --- .config/zsh/.p10k.zsh | 11 ++++++----- .config/zsh/.zshrc | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.config/zsh/.p10k.zsh b/.config/zsh/.p10k.zsh index 05b5a45..b7ea03a 100644 --- a/.config/zsh/.p10k.zsh +++ b/.config/zsh/.p10k.zsh @@ -32,6 +32,7 @@ typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( # =========================[ Line #1 ]========================= context # user@hostname + nesting dir # current directory vcs # git status # =========================[ Line #2 ]========================= @@ -57,14 +58,14 @@ nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) - # node_version # node.js version - # go_version # go version (https://golang.org) + node_version # node.js version + go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) # dotnet_version # .NET version (https://dotnet.microsoft.com) # php_version # php version (https://www.php.net/) # laravel_version # laravel php framework version (https://laravel.com/) # java_version # java version (https://www.java.com/) - # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + package # name@version from package.json (https://docs.npmjs.com/files/package.json) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) fvm # flutter version management (https://github.com/leoafarias/fvm) @@ -1497,8 +1498,8 @@ # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. # # Type `p10k help segment` for documentation and a more sophisticated example. - function prompt_example() { - p10k segment -f 208 -i '⭐' -t 'hello, %n' + function prompt_nesting() { + p10k segment -e -f 8 -c "$(expr "$SHLVL" \> 2 >/dev/null && echo 1)" -t '${SHLVL}' } # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index f646585..e898ea7 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -8,9 +8,9 @@ fi 2>/dev/null || return 0 # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi +#if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then +# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +#fi DEFAULT_USER=$USER