From 98a065afe5aca04cb773f2d1303904a03887bdad Mon Sep 17 00:00:00 2001 From: Antti Kupila Date: Tue, 26 Mar 2019 17:06:50 +0100 Subject: [PATCH] Fix double character in non-git dir (#5) This commit fixes an issue where a the first character would be repeated in the following scenario: 1. cd to directory that's not part of a git repo 2. Type 'a' 3. Hit tab 4. Cancel with ctrl-c 5. Double aa shows up The fix is to print nothing at all if there is no output. --- cmd/gitprompt/gitprompt.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/gitprompt/gitprompt.go b/cmd/gitprompt/gitprompt.go index e9af54b..0b5bd04 100644 --- a/cmd/gitprompt/gitprompt.go +++ b/cmd/gitprompt/gitprompt.go @@ -115,6 +115,9 @@ func main() { _, _ = fmt.Fprintln(os.Stderr, err) os.Exit(1) } + if s == nil { + return + } out, num := gitprompt.Print(s, format.String()) _, _ = fmt.Fprint(os.Stdout, out) if *zsh {