commit babc58304348c5e700d6605d36f43f7df34fa6f1 parent b2105c126a1760082fd0ed503c1689b2261736aa Author: Alex Balgavy <a.balgavy@gmail.com> Date: Wed, 14 Oct 2020 09:24:12 +0200 shell: p10k shell level fix for vim/tmux Former-commit-id: 55020ce15a387ee9898046eb1a0c80f9752dc45c Diffstat:
M | shell/p10k-dark.zsh | | | 13 | ++++++++----- |
M | shell/p10k-light.zsh | | | 13 | ++++++++----- |
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/shell/p10k-dark.zsh b/shell/p10k-dark.zsh @@ -1141,11 +1141,14 @@ # p10k segment -f 4 -e -t $lvl'%B${(l:$_my_lvl::$_my_lvl:)}%(1j.%j.)' # These ^ are cool functions but overkill for me local lvl=""; - if [ $SHLVL -gt 1 ]; then - if [ $SHLVL -gt 2 ] || ( [ -z "$VIMRUNTIME" ] && [ -z "$TMUX" ] ); then - lvl="(L$SHLVL)" - fi - fi + [ -n "$TMUX" ] && { + [ -n "$VIMRUNTIME" -a $SHLVL -gt 3 ] && lvl="(L$(($SHLVL-2)))" + [ -z "$VIMRUNTIME" -a $SHLVL -gt 2 ] && lvl="(L$(($SHLVL-1)))" + } + [ -z "$TMUX" ] && { + [ -n "$VIMRUNTIME" -a $SHLVL -gt 2 ] && lvl="(L$(($SHLVL-1)))" + [ -z "$VIMRUNTIME" -a $SHLVL -gt 1 ] && lvl="(L$SHLVL)" + } p10k segment -f 4 -t "$lvl" } diff --git a/shell/p10k-light.zsh b/shell/p10k-light.zsh @@ -1277,11 +1277,14 @@ # p10k segment -f 4 -e -t $lvl'%B${(l:$_my_lvl::$_my_lvl:)}%(1j.%j.)' # These ^ are cool functions but overkill for me local lvl=""; - if [ $SHLVL -gt 1 ]; then - if [ $SHLVL -gt 2 ] || ( [ -z "$VIMRUNTIME" ] && [ -z "$TMUX" ] ); then - lvl="(L$SHLVL)" - fi - fi + [ -n "$TMUX" ] && { + [ -n "$VIMRUNTIME" -a $SHLVL -gt 3 ] && lvl="(L$(($SHLVL-2)))" + [ -z "$VIMRUNTIME" -a $SHLVL -gt 2 ] && lvl="(L$(($SHLVL-1)))" + } + [ -z "$TMUX" ] && { + [ -n "$VIMRUNTIME" -a $SHLVL -gt 2 ] && lvl="(L$(($SHLVL-1)))" + [ -z "$VIMRUNTIME" -a $SHLVL -gt 1 ] && lvl="(L$SHLVL)" + } p10k segment -f 4 -t "$lvl" }