From d9feb1d46845fe5cf86b453d175dbd779b759adb Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 9 Jul 2025 01:27:37 +0200 Subject: [PATCH] zsh:p10k: Add custom Session.vim prompt segment --- .../15-powerlevel10k.theme.zsh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.config/zsh/zshrc.d/90-external-plugins/15-powerlevel10k.theme.zsh b/.config/zsh/zshrc.d/90-external-plugins/15-powerlevel10k.theme.zsh index 92c9fc7..f473fc6 100644 --- a/.config/zsh/zshrc.d/90-external-plugins/15-powerlevel10k.theme.zsh +++ b/.config/zsh/zshrc.d/90-external-plugins/15-powerlevel10k.theme.zsh @@ -88,6 +88,7 @@ lf # lf shell (https://github.com/gokcehan/lf) xplr # xplr shell (https://github.com/sayanarijit/xplr) vim_shell # vim shell indicator (:sh) + my_vim_session # vim session file (Session.vim) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) @@ -1670,6 +1671,29 @@ prompt_example } + #########################[ my_vim_session: existence of Session.vim ]######################### + function prompt_my_vim_session() { + if [[ -e Session.vim ]]; then + p10k segment -s CURRENT -t "Session.vim" + return + fi + + # TODO: do we actually want :A? + local dir="${${PWD:A}:h}" + while [[ $dir != / ]]; do + if [[ -e "$dir/Session.vim" ]]; then + p10k segment -s PARENT -t "Session.vim" + return + fi + + dir="${dir:h}" + done + } + # Color when Session.vim exists in current directory + typeset -g POWERLEVEL9K_MY_VIM_SESSION_CURRENT_FOREGROUND=3 + # Color when Session.vim exists in parent directory + typeset -g POWERLEVEL9K_MY_VIM_SESSION_PARENT_FOREGROUND=239 + # User-defined prompt segments can be customized the same way as built-in segments. # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐'