Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ Defaults to 0.
name are included in the output. Useful if you have an ID or other
fixed-length identifier appended to the branch name. Defaults to 0 with
manual install , set to 8 by install script.
* omz-separator - character used to separate the prefix and suffix.
Defaults to a dot `.`
* omz-separator-length - number used to multiply the separator. Defaults to 3
15 changes: 12 additions & 3 deletions omz-git.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@ function git_prompt_info() {

length=${#ref}
suffixStart=`expr ${length} - ${suffixLength} + 1`
separatorLength=3 #3 dots...
separatorLength=$(command git config --get oh-my-zsh.omz-separator-length 2>/dev/null)
if [[ -z ${separatorLength} ]]; then
separatorLength=3 # 3 dots...
fi

separator=$(command git config --get oh-my-zsh.omz-separator 2>/dev/null)
if [[ -z ${separator} ]]; then
separator='.'
fi
separatorExpression=$(printf "%${separatorLength}s")

nameEnd=`expr ${maxLength} - ${suffixLength} - ${separatorLength}`
ref="$(command echo ${ref} | cut -c 1-${nameEnd})...$(command echo ${ref} | cut -c ${suffixStart}-)"
ref="$(command echo ${ref} | cut -c 1-${nameEnd})$(command echo ${separatorExpression// /${separator}})$(command echo ${ref} | cut -c ${suffixStart}-)"
fi

echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}