-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zhengkai
192 lines (150 loc) · 3.71 KB
/
.zhengkai
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
[ -z "$PS1" ] && return
export TZ='Asia/Shanghai'
export TERM="xterm-256color"
export EDITOR=vim
export LINES
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export COW_INSTALLDIR=/home/zhengkai/.cow
umask 002
set -o vi
tabs 4
# Ctrl-S Ctrl-Q
stty stop undef
stty start undef
# 输入法
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
PS1_HOST="\h";
if [[ -n $SSH_CONNECTION ]];
then
PS1_HOST="\[\033[38;5;217m\]\h\[\033[00m\]";
fi
export CCACHE_DIR=/tmp/ccache
settitle() {
printf "\033]2;$1\033\\"
}
#sudo() {
# settitle "$*"
# command sudo "$@"
#}
hg_propmt() {
branch=`hg branch 2> /dev/null`
if [ -z "$branch" ]; then
return
fi
echo " Hg[ "$branch$(hg_propmt_dirty)" ]"
}
hg_propmt_dirty() {
file=`(hg status | wc -l) 2> /dev/null`
if [ $file -lt 1 ]; then
return
fi
s=`hg diff --stat 2> /dev/null`
if [ -z "$s" ]; then
echo " ] [ $file"
return
fi
addline=`echo $s | \grep -o '[0-9]\+ insertion' | \grep -o '[0-9]\+'`
if [ -z "$addline" ]; then
addline=0
fi
subline=`echo $s | \grep -o '[0-9]\+ deletion' | \grep -o '[0-9]\+'`
if [ -z "$subline" ]; then
subline=0
fi
let count="$addline+$subline"
echo " ] [ $file / $count"
}
git_propmt() {
branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"`
if [ -z "$branch" ]; then
return
fi
echo " Git[ "$branch$(git_propmt_dirty)" ]"
}
git_propmt_dirty() {
file=`(git status -s | wc -l) 2> /dev/null`
if [ $file -lt 1 ]; then
return
fi
s=`git diff -b --shortstat 2> /dev/null`
if [ -z "$s" ]; then
echo " ] [ $file"
return
fi
addline=`echo $s | \grep -o '[0-9]\+ insertion' | \grep -o '[0-9]\+'`
if [ -z "$addline" ]; then
addline=0
fi
subline=`echo $s | \grep -o '[0-9]\+ deletion' | \grep -o '[0-9]\+'`
if [ -z "$subline" ]; then
subline=0
fi
let count="$addline+$subline"
echo " ] [ $file / $count"
}
PS1_TIME="\n\[\033[38;5;39m\] - \D{%I:%M:%S %p} -\[\033[00m\]"
PS1_USER="\u"
if [[ $USER != "zhengkai" ]];
then
PS1_USER="\[\033[38;5;217m\]$USER\[\033[38;5;39m\]"
fi
PS1_HOST="\[\033[38;5;39m\]$PS1_USER@$PS1_HOST"
PS1_PWD="\[\033[1;38;5;39m\]\w\[\033[00m\]"
PS1_GIT="\[\033[38;5;39m\]"'$(git_propmt)$(hg_propmt)'"\[\033[00m\]"
PS1_PROMPT="\n \[\033[38;5;208m\]»\[\033[00m\] "
if [[ -n $TMUX ]];
then
PS1_SET_TITLE='$(settitle $PWD)';
printf '\033Ptmux;\033\033]12;lime\007\033\\'
fi
export PS1="$PS1_SET_TITLE $PS1_TIME $PS1_HOST $PS1_PWD $PS1_GIT $PS1_PROMPT"
export SDIRS=~/conf/.sdirs
if [ -f ~/conf/inc/bashmarks/bashmarks.sh ]; then
. ~/conf/inc/bashmarks/bashmarks.sh
fi
export GOROOT=$HOME/go
export GOARCH=amd64
export GOOS=linux
export GOPATH="/go"
export ANDROID_HOME=/home/zhengkai/Android/Sdk
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/games:$GOROOT/bin:$HOME/.composer/vendor/bin"
# export HTTP_PROXY=localhost:7777
# export HTTPS_PROXY=localhost:7777
# case "$SSH_TTY" in
# /dev/pts*)
# ;;
# *)
# setterm --blank 0;
# ;;
# esac
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
export HISTTIMEFORMAT="%F %T "
export HISTFILESIZE=900000000
export HISTSIZE=1000000
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
# eval `resize`
shopt -s checkwinsize
# man color
#export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[1;38;5;222m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[30;48;5;32m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[38;5;117m'
if [ -f ~/conf/.bash_alias ]; then
. ~/conf/.bash_alias
fi
if [ -f ~/.bash_addon ]; then
. ~/.bash_addon
fi
if [ -z "$(declare -f -F j)" ] && [ -f /usr/share/autojump/autojump.bash ]; then
. /usr/share/autojump/autojump.bash
fi