Update prompt to truncate directory in worktree
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user