-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
73 lines (60 loc) · 1.74 KB
/
zshrc
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
alias reload!='. ~/.zshrc'
export LSCOLORS="exfxcxdxbxegedabagacad"
export CLICOLOR=true
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt NO_BG_NICE # don't nice background tasks
setopt NO_HUP
setopt NO_LIST_BEEP
setopt LOCAL_OPTIONS # allow functions to have local options
setopt LOCAL_TRAPS # allow functions to have local traps
setopt HIST_VERIFY
setopt SHARE_HISTORY # share history between sessions ???
setopt EXTENDED_HISTORY # add timestamps to history
setopt PROMPT_SUBST
setopt CORRECT
setopt COMPLETE_IN_WORD
setopt IGNORE_EOF
setopt APPEND_HISTORY # adds history
setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions
setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history
setopt HIST_REDUCE_BLANKS
autoload colors && colors
git_branch() {
echo $(/usr/bin/git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
}
git_dirty() {
st=$(/usr/bin/git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]
then
echo ""
else
if [[ $st == "nothing to commit (working directory clean)" ]]
then
echo " on %{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}"
else
echo " on %{$fg_bold[red]%}$(git_prompt_info)%{$reset_color%}"
fi
fi
}
git_prompt_info () {
ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null) || return
# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})"
echo "${ref#refs/heads/}"
}
unpushed () {
/usr/bin/git cherry -v origin/$(git_branch) 2>/dev/null
}
need_push () {
if [[ $(unpushed) == "" ]]
then
echo " "
else
echo " with %{$fg_bold[magenta]%}unpushed%{$reset_color%} "
fi
}
directory_name(){
echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}"
}
export PROMPT=$'$fg_bold[green]%m:%3~$reset_color$(git_dirty)$(need_push)$ '