-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
253 lines (220 loc) · 7.13 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# erik's global zshrc file
# default prompt color
PROMPT_COLOR='\[\e\[0;39m\]'
PROMPT_COLOR2='\[\e\[0;39m\]'
autoload -U compinit
compinit
# source site specific resources
for bashrc in `/bin/ls -a ~ | grep bashrc.`
do
if [ -f ~/$bashrc ]; then
source ~/$bashrc
fi
done
# Don't use ^D to exit
set -o ignoreeof
# turn off the bell
set bell-style none
# Don't put duplicate lines in the history.
export HISTCONTROL=erasedups
# export HISTIGNORE=" *:[^./]*([^ ])"
# command line prompt, in color
#PS1="$PROMPT_COLOR\h:$PROMPT_COLOR2\w$PROMPT_COLOR\$\[\e[0m\] "
# ignore unlikely files
FIGNORE='.o:~:.class:.pyc'
# grep colors
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;32'
# make subversion happy
export SVN_EDITOR=/usr/bin/vim
export EDITOR=/usr/bin/vim
# make files only mine by default
umask 027
function gvd() {
DISPLAY= P4DIFF=vimdiff g4 diff $@
}
function exit() {
if [ -e $STY ]; then
unfunction exit
exit
fi
echo "You're in screen, don't exit!"
}
function _exit() {
unfunction exit
exit
}
# aliases
alias ls="ls --color=auto --block-size=K"
alias sl="ls"
alias tree='tree -Csu'
alias cat='cat -v'
alias p="ps x -o pgrp,pid,cmd"
alias srcc="source ~/.zshrc"
alias vi="vim -X"
alias on="screen -x -R"
alias vg="vi ~/.gitconfig"
alias vv="vi ~/.vimrc"
alias vzr="vi ~/.zshrc"
alias vze="vi ~/.zshenv"
bindkey "^[[1;5D" backward-word # ctrl left
bindkey "^[[1;5C" forward-word # ctrl right
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey '^F' history-beginning-search-backward
bindkey '^G' history-beginning-search-forward
bindkey '^D' kill-word
bindkey "$(echotc @7)" end-of-line # end
bindkey '^S' menu-complete
autoload edit-command-line
zle -N edit-command-line
bindkey '^O' edit-command-line
bindkey '^L' clear-screen
bindkey '^P' yank
bindkey '^W' backward-kill-word
bindkey '^R' history-incremental-pattern-search-backward
# This doesn't appear to be in the version of zsh I'm running (4.3)
function xxx-bash-backward-kill-word() {
local WORDCHARS='*?_-.[]~&;!#$%^(){}<>'
zle .backward-kill-word
}
zle -N xxx-bash-backward-kill-word xxx-bash-backward-kill-word
bindkey '^D' xxx-bash-backward-kill-word
bindkey "^[[5C" forward-word # shift-right
bindkey ";5C" forward-word # shift-right
bindkey ";2C" forward-word # shift-right
bindkey "^[[5D" backward-word # shift-left
bindkey ";5D" backward-word # shift-left
bindkey ";2D" backward-word # shift-left
bindkey -r "^[[5;" # shift-left
{ local saveterm="$TERM"; TERM=xterm-vt220-full
bindkey "$(echotc %i)" forward-word # shift-right
bindkey "$(echotc \#3)" yank # shift-insert
bindkey "$(echotc \#4)" backward-word # shift-left
bindkey "$(echotc \*7)" end-of-history # shift-end
TERM="$saveterm" } 2> /dev/null
bindkey "$(echotc @7)" end-of-line # end
bindkey "$(echotc kD)" delete-char # delete
bindkey "$(echotc kI)" overwrite-mode # insert
bindkey "$(echotc kN)" down-history # page down
bindkey "$(echotc kP)" up-history # page up
bindkey "$(echotc kb)" backward-delete-char # backspace
bindkey "$(echotc kd)" down-line-or-history # down arrow
bindkey "$(echotc kh)" beginning-of-line # home
bindkey "$(echotc kl)" backward-char # left arrow
bindkey "$(echotc kr)" forward-char # right arrow
bindkey "$(echotc ku)" up-line-or-history # up arrow
bindkey '^?' backward-delete-char
bindkey '^H' backward-delete-char
# stolen from ambrose
function setup_prompt {
typeset -gH reset="$(echotc me)"
typeset -gH bold="$(echotc md)"
typeset -gH underline="$(echotc us)"
typeset -gH black="$(echotc AF 0 0 0)"
typeset -gH red="$(echotc AF 1 1 1)"
typeset -gH green="$(echotc AF 2 2 2)"
typeset -gH yellow="$(echotc AF 3 3 3)"
typeset -gH blue="$(echotc AF 4 4 4)"
typeset -gH magenta="$(echotc AF 5 5 5)"
typeset -gH cyan="$(echotc AF 6 6 6)"
typeset -gH white="$(echotc AF 7 7 7)"
typeset -gH reverse="$(echotc mr)"
# set screen hardstatus, or xterm icon name and window title
function hardstatus { print -n "\e]0;" && print -Rn "$@" && print -n "\a" }
# set screen window title
function windowname { [[ -n "$WINDOW" ]] && print -n "\ek" && print -Rn "$@" && print -n "\e\\" }
function precmd {
local cmd_status=$?
print -Rn "$reset$bold$blue"
jobs
hardstatus "$(print -Pn "[%m:%~] %%")"
windowname "$(print -Pn "%2~%#")"
if [ -n "$precmd_cmd" -a $cmd_status -ne 0 ]; then
print -Rn "$reset$bold$red"
print "$cmd_status: $precmd_cmd"
fi
precmd_cmd=''
}
function preexec {
print -n "$reset"
local cmd="$1"
precmd_cmd=$cmd
if [[ "$cmd[(w)1]" == "fg" ]]; then
cmd="$cmd %%"
jobs "$cmd[(w)2]" 2> /dev/null | read cmd cmd cmd cmd
fi
cmd="$(print -Rn " $cmd" | tr -cs '[:print:]' ' ')"
hardstatus "$(print -Pn "[%m:%~]")""$cmd"
windowname "$(print -Pn "%2~:")""$cmd"
}
typeset -gH PS1="%{$reset$bold$cyan%}%m%{$white%}:%{$yellow%}\${PWD##$HOME/#}%{$reset$bold%}\${WINDOW:+.s$WINDOW}%# %{$reset%}"
typeset -gH PROMPT prompt
typeset -gH POSTEDIT="$reset"
}
setup_prompt
# history
if [ -z "$HISTFILE" ]; then
typeset -r HISTFILE=~/.bash_history
typeset -r HISTSIZE=90000
typeset -r SAVEHIST=90000
fi
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
#ZSH_HIGHLIGHT_PATTERNS+=('rm -rf ' 'fg=white,bold,bg=red')
ZSH_HIGHLIGHT_STYLES[globbing]='fg=cyan'
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=yellow'
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=cyan'
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=cyan'
###-begin-npm-completion-###
#
# npm command completion script
#
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
export COMP_WORDBREAKS
if type complete &>/dev/null; then
_npm_completion () {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${COMP_WORDS[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -F _npm_completion npm
elif type compdef &>/dev/null; then
_npm_completion() {
si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
elif type compctl &>/dev/null; then
_npm_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _npm_completion npm
fi
###-end-npm-completion-###