X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=sugar.git;a=blobdiff_plain;f=dot-files%2F_zshrc;h=eaf76574fb788c92b3d7c704bc9e078b9b424d96;hp=d5fdcf850a7e95ae29ad3f515e6487a6559e4372;hb=3787269b0f41f792c3e90c1bdac543bfb8abf7c7;hpb=baaa338e33a4db720a31ce5779bda81d8353a8a0 diff --git a/dot-files/_zshrc b/dot-files/_zshrc index d5fdcf8..eaf7657 100644 --- a/dot-files/_zshrc +++ b/dot-files/_zshrc @@ -75,7 +75,7 @@ function preexec() { # Hook } function chpwd() { # Hook - local dirinfo=$(print_directory_info) + local dirinfo=$(print_directory_info $(pwd)) case $dirinfo in "") @@ -86,40 +86,29 @@ function chpwd() { # Hook } function print_directory_info() { - local vcs_type=$(print_vcs_type $(pwd)) - - case $vcs_type in - git) - git branch --no-color 2>/dev/null \ - | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/';; - hg) - hg branch 2>/dev/null;; - darcs-*) - # Delete `darcs-' at the beginning. - echo ${vcs_type#darcs-};; - *) - # Unknown - echo - esac -} - -function print_vcs_type() { local absdir=$1 if [[ -d $absdir/.git ]] then - echo git + # Git + git branch --no-color 2>/dev/null \ + | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' + elif [[ -d $absdir/.hg ]] then - echo hg + # Hg + hg branch 2>/dev/null + elif [[ -d $absdir/_darcs ]] then - echo darcs-$(basename $absdir) + # Darcs + basename $absdir + else - # Nothing. + # Unknown. if [[ $absdir = "/" ]] then # This is the root directory so exit from the recursion. echo else # Recurse to the parent dir. - print_vcs_type $(dirname $absdir) + print_directory_info $(dirname $absdir) fi fi }