cf5db83facf67a27faa2860241f6ddc1d7e27b4f

Author
Victor Torres <vpaivatorres@gmail.com>
Committer
Victor Torres <vpaivatorres@gmail.com>
Date

Message

Implementing mcornella's suggestions in pull request 4451.

Diff

 1diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh
 2index c918ea2b5a9152609da0a7d2992bd3c21b823f0e..a1e9ca31be4fbe016fa8470294868b5f4ceae294 100644
 3--- a/plugins/branch/branch.plugin.zsh
 4+++ b/plugins/branch/branch.plugin.zsh
 5@@ -4,23 +4,23 @@
 6 
 7 function branch_prompt_info() {
 8   # Defines path as current directory
 9-  path=$(pwd)
10+  local current_dir=$PWD
11   # While current path is not root path
12-  while [ $path != '/' ];
13+  while [[ $current_dir != '/' ]]
14   do
15     # Git repository
16-    if [ -d ${path}/.git ];
17+    if [[ -d "${current_dir}/.git" ]]
18     then
19-      echo '±' $(/bin/cat ${path}/.git/HEAD | /usr/bin/cut -d / -f 3-)
20+      echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
21       return;
22     fi
23     # Mercurial repository
24-    if [ -d ${path}/.hg ];
25+    if [[ -d "${current_dir}/.hg" ]]
26     then
27-      echo '☿' $(/bin/cat ${path}/.hg/branch)
28+      echo '☿' $(<"$current_dir/.hg/branch")
29       return;
30     fi
31     # Defines path as parent directory and keeps looking for :)
32-    path=$(/usr/bin/dirname $path)
33+    current_dir="${current_dir:h}"
34   done
35 }