Use shorteded form of branch names to minify prompt

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-11-17 11:43:25 +01:00
parent 60d08b8998
commit bc1a7c9c65
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E

View File

@ -35,6 +35,12 @@ function config-git_prompt() {
fi
}
function shortened_branch() {
local branch=$(git_current_branch)
[ $(echo -n "${branch}" | wc -c) -gt 15 ] && branch="${branch:0:15}%{$fg[red]%}$(printf '\uf141')%{$reset_color%}"
echo "${branch}"
}
function build_git_prompt() {
# Allow hiding the right side of the prompt
(test "${NO_RIGHT}" = "true") && return
@ -66,7 +72,7 @@ function build_git_prompt() {
# Show current branch and commit / tag
echo -n "%{$reset_color%}"
echo -n "$(git_current_branch) "
echo -n "$(shortened_branch) "
echo -n "($(git_describe)) "
# Print repository status information