浏览代码

Only calling git symbolic-ref HEAD when we are in a .git directory

Robby Russell 15 年之前
父节点
当前提交
a26cb28de4
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      git.zsh

+ 2 - 3
git.zsh

@@ -1,9 +1,8 @@
 # get the name of the branch we are on
 function git_prompt_info() {
-  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
-  branch=${ref#refs/heads/}
-
   if [[ -d .git ]]; then
+    ref=$(git symbolic-ref HEAD 2> /dev/null) || return
+    branch=${ref#refs/heads/}
     CURRENT_BRANCH="%{$fg[red]%}git:(%{$fg[green]${branch}%{$fg[red])"
   else
     CURRENT_BRANCH=''