summaryrefslogtreecommitdiffstats
path: root/gitprompt
blob: f114f91fbb72a0e22e9e62327f7a94c84b68aea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/zsh
# detect git first

trap 'print -n;exit 1' INT
#autoload -U colors && colors

estatus=0

#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
dir="$(print (../)#.git)"
if  test $dir 2>/dev/null;then
#if  [[ $isgit == "true" ]];then
     local gprompt="("
     gprompt+="${${$(<$dir/HEAD)[(ws| |)2]}[(ws:/:)-1]}"
     #gprompt+="$(git branch | grep '*'| cut -d ' ' -f 2  | tr -d '\n')"
     #timeout 3 git status -s
     if [[ -n $(timeout -s KILL 2 git status -s) ]];then
         gprompt+="⚡";
         estatus=1
     else
         gprompt+="ʃ";
     fi
     gprompt+=")"
     print -n $gprompt
fi

exit $estatus