-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprompt
42 lines (41 loc) · 1.16 KB
/
prompt
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/zsh
NORMAL="%{$reset_color%}"
# Definition du prompt
prompt_hook ()
{
if [ $? -eq 0 ]
then
COLOR3="%{$fg[green]%}"
else
COLOR3="%{$fg[red]%}"
fi
ISGIT=$(git status --ignore-submodules 2> /dev/null)
if [ -n "$ISGIT" ]
then
STATUS=$(echo "$ISGIT" | grep "modified:\|renamed:\|new file:\|deleted:" | grep -v ".vim/bundle\|untracked")
BRANCH=$(git branch | cut -d ' ' -f 2 | tr -d '\n')
if [ -n "$STATUS" ]
then
COLOR="%{$fg[red]%}"
else
REMOTE_EXIST=$(git branch -a | grep remotes/origin/$BRANCH)
if [ -n "$REMOTE_EXIST" ]
then
REMOTE=$(git diff --ignore-submodules origin/$BRANCH)
if [ -n "$REMOTE" ]
then
COLOR="%{$fg[yellow]%}"
else
COLOR="%{$fg[green]%}"
fi
else
COLOR="%{$fg[green]%}"
fi
fi
RPROMPT="%{$COLOR%}($BRANCH)%{$NORMAL%}"
else
RPROMPT=""
fi
PROMPT="%B%{$fg[green]%}%n@%m%{$NORMAL%}%B:%{$fg[blue]%}%~%{$NORMAL%}
%B%{$COLOR3%}> %{$NORMAL%}%b"
}