From f6f767c78ac1404a20eeeabaca63d94e9210e40c Mon Sep 17 00:00:00 2001 From: "Hristos N. Triantafillou" Date: Sat, 26 Mar 2016 10:40:11 -0500 Subject: [PATCH] Show rev info when in detached HEAD If you're in a detached HEAD state, it's not a symbolic ref, and so `$branch` was left empty. --- modules/git/functions/git-info | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index 8aaa4c32..2302248b 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -215,7 +215,8 @@ function git-info { fi # Get the branch. - branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" + branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" \ + || branch="$(git rev-parse --short HEAD 2> /dev/null)" # Format branch. zstyle -s ':prezto:module:git:info:branch' format 'branch_format'