From 38d11d3afbcdfd9e3fe7c4b5ac8ce96c2bd60932 Mon Sep 17 00:00:00 2001 From: lunohodov Date: Thu, 12 Feb 2015 15:20:25 +0100 Subject: [PATCH] Prevent unreadable prompt within Git repository When within a git repository, doing a tab-autocomplete on a command results with the command becoming unreadable. The command still works but this is pretty annoying visually. Basically I 1. Navigate to a directory with a git repository in it. The prompt indicates the current branch properly 2. Next, type `git -` and hit tab The prompt now shows only part of branch's name with the first suggestion appended. After googling a bit I stumbled upon several pages describing a similar problem (most useful to me was http://stackoverflow.com/questions/23740862/issues-with-zsh-prompt). The culprit seems to be the git_prompt_info function escaping the `$current_branch` variable as if it is a color. As a result zsh is confused where the cursor is. After "unescaping" the variable everything seems to work fine. Using zsh 5.0.7 (x86_64-apple-darwin13.4.0). --- zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshrc b/zshrc index 6a56fc99fc..4f3712fd30 100644 --- a/zshrc +++ b/zshrc @@ -2,7 +2,7 @@ git_prompt_info() { current_branch=$(git current-branch 2> /dev/null) if [[ -n $current_branch ]]; then - echo " %{$fg_bold[green]%}%{$current_branch%}%{$reset_color%}" + echo " %{$fg_bold[green]%}$current_branch%{$reset_color%}" fi } setopt promptsubst