From 87d65db1e52f5651a06afa91708091494de6364a Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 29 Aug 2023 23:19:09 -0400 Subject: [PATCH] Limit branch name length --- zsh/.config/zsh/prompt | 10 ++++++++++ zsh/.zshenv | 2 ++ 2 files changed, 12 insertions(+) diff --git a/zsh/.config/zsh/prompt b/zsh/.config/zsh/prompt index f806ddb..59ea34a 100644 --- a/zsh/.config/zsh/prompt +++ b/zsh/.config/zsh/prompt @@ -4,9 +4,19 @@ precmd() { zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*:prompt:*' formats "(%b)" + zstyle ':vcs_info:git*+set-message:*' hooks git-branch vcs_info 'prompt' } +function +vi-git-branch() { + local branch_name=${hook_com[branch]} + local readonly max=${ZDOT_MAX_BRANCH_LENGTH:-20} + + if [[ ${#branch_name} -gt $max ]]; then + hook_com[branch]="${branch_name:0:($max - 1)}…" + fi +} + local current_time="[%B%D{%T}%b]" local current_dir='%~%f' local current_branch='${vcs_info_msg_0_}' diff --git a/zsh/.zshenv b/zsh/.zshenv index 3407918..48e106f 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,5 +1,7 @@ ZDOTDIR=$HOME/.config/zsh +ZDOT_MAX_BRANCH_LENGTH=30 + XDG_CONFIG_HOME="$HOME/.config" PERSONAL_BIN_PATH="$HOME/bin"