From bc1a7c9c65059dcbe173902e118c51ea603b20c2 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 17 Nov 2018 11:43:25 +0100 Subject: [PATCH] Use shorteded form of branch names to minify prompt Signed-off-by: Knut Ahlers --- .zsh/oh-my-custom/luzifer.zsh-theme | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.zsh/oh-my-custom/luzifer.zsh-theme b/.zsh/oh-my-custom/luzifer.zsh-theme index 7d89763..80cca12 100644 --- a/.zsh/oh-my-custom/luzifer.zsh-theme +++ b/.zsh/oh-my-custom/luzifer.zsh-theme @@ -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