/
zlogin
35 lines (30 loc) · 839 Bytes
/
zlogin
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
# adds the current branch name in green
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}]"
fi
}
git_prompt_info_incl_dirty() {
st=$(git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]
then
echo ""
else
if [[ $st == "nothing to commit, working tree clean" ]]
then
echo "$(git_prompt_info)"
else
echo "%{$fg_bold[red]%}*%{$reset_color%}$(git_prompt_info)%{$reset_color%}"
fi
fi
}
# makes color constants available
autoload -U colors
colors
# enable colored output from ls, etc
export CLICOLOR=1
# expand functions in the prompt
setopt prompt_subst
# prompt
export PS1='$(git_prompt_info_incl_dirty)[${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}] '