From 111f72bf599ee1472a8a52c434f57acc34e3be7b Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 25 Feb 2026 18:38:48 +0000 Subject: [PATCH] Update prompt to truncate directory in worktree --- prompt_fresh_setup | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/prompt_fresh_setup b/prompt_fresh_setup index 6b6a119..a7ba1c4 100644 --- a/prompt_fresh_setup +++ b/prompt_fresh_setup @@ -79,6 +79,17 @@ fresh_line_one() { # Check we are in a git repository local git=`${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt` + # Truncate branch name from directory when already shown (e.g., worktrees) + if [[ -n "$git" ]] && [[ -z $SANDBOX_HOME ]]; then + local branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + if [[ -n "$branch_name" ]]; then + local dir=${(%):-%~} + if [[ "$dir" == *"@${branch_name}"* ]]; then + directory="%{%F{37}%}${dir/@${branch_name}/@}%{%f%}" + fi + fi + fi + # If the last command failed, display its error code at the right if [[ $exit_code -ne 0 ]]; then case $exit_code in