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
This commit is contained in:
xeruf 2022-09-15 19:21:16 +02:00
parent e9bb7d6d0e
commit 2c1dab2a28
2 changed files with 9 additions and 8 deletions

View File

@ -32,6 +32,7 @@
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]========================= # =========================[ Line #1 ]=========================
context # user@hostname context # user@hostname
nesting
dir # current directory dir # current directory
vcs # git status vcs # git status
# =========================[ Line #2 ]========================= # =========================[ Line #2 ]=========================
@ -57,14 +58,14 @@
nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv)
nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) nvm # node.js version from nvm (https://github.com/nvm-sh/nvm)
nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
# node_version # node.js version node_version # node.js version
# go_version # go version (https://golang.org) go_version # go version (https://golang.org)
# rust_version # rustc version (https://www.rust-lang.org) # rust_version # rustc version (https://www.rust-lang.org)
# dotnet_version # .NET version (https://dotnet.microsoft.com) # dotnet_version # .NET version (https://dotnet.microsoft.com)
# php_version # php version (https://www.php.net/) # php_version # php version (https://www.php.net/)
# laravel_version # laravel php framework version (https://laravel.com/) # laravel_version # laravel php framework version (https://laravel.com/)
# java_version # java version (https://www.java.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) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io) rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm) 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. # 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. # Type `p10k help segment` for documentation and a more sophisticated example.
function prompt_example() { function prompt_nesting() {
p10k segment -f 208 -i '⭐' -t 'hello, %n' 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 # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job

View File

@ -8,9 +8,9 @@ fi 2>/dev/null || return 0
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. # 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] # Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below. # 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 #if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" # source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi #fi
DEFAULT_USER=$USER DEFAULT_USER=$USER