Source

dotfiles / zshrc

The default branch has multiple heads

Full commit
  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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# .zshrc - amix@amix.dk 13/08/07 18:43:43
# Inspired by http://files.csa-net.dk/public/dotfiles/zshrc.txt
# Inspired by http://www.michael-prokop.at/computer/config/.zsh/
# Inspired by http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/zsh/zshrc
umask 002

export BROWSER="/usr/bin/google-chrome %s"
export PAGER="less"
export EDITOR="vim"

export YT_DEST=$HOME/yt-x86_64/
export ARCH_PATH=$HOME/yt-x86_64/
export LD_LIBRARY_PATH=$ARCH_PATH/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib:$LD_LIBRARY_PATH
export PATH=$ARCH_PATH/bin:$PATH
export ANDROID_SDK=/home/mturk/Android/android-sdk-linux_x86
export GOPATH=/home/mturk/Development/go
export XUVTOP=/home/mturk/Development/chianti
export ETS_TOOLKIT=qt4
export ROCKSTAR_DIR=$HOME/Development/Rockstar-0.98.5/

set -o vi

fpath=($fpath ~/.zshfuncs)
path=( /usr/local/cuda/bin $path )

path=( $path $GOPATH/bin )

# Variable settings
export SVN_EDITOR=/Users/matthewturk/.vim/svn_editor
export BZR_EDITOR=/Users/matthewturk/.vim/bzr_editor
export DYLD_LIBRARY_PATH=${S2PATH}/${S2ARCH}:/usr/local/cuda/lib

alias charm='/usr/bin/charm'

# Some virtualenv stuff
export WORKON_HOME=$HOME/Envs
alias venv='source $YT_DEST/bin/virtualenvwrapper.sh'
#source /Library/Frameworks/Python.framework/Versions/Current/bin//virtualenvwrapper_bashrc

###--------------------------------------------------
### history
HISTSIZE="50000"
HISTFILE="${HOME}/.zsh_history"
SAVEHIST="20000"
DIRSTACKSIZE=30
READNULLCMD=less

export LESSCHARSET=iso8859

alias 'quickweb'='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'

cdp () {
  cd "$(python -c "import os.path as _, ${1}; \
    print _.dirname(_.realpath(${1}.__file__[:-1]))"
  )"
}

ppbr()
{
    PP="${HOME}/yt/$1/"
    if [ ! -d ${PP} ] && echo "${PP} doesn't exist" && return
    export PYTHONPATH=${PP}
    #echo "PYTHONPATH=${PYTHONPATH}"
    export YTPATH=${PP}
}
ppbr yt

cyt()
{
    [ -f ${YTPATH}/yt/utilities/command_line.py ] && python2.7 ${YTPATH}/yt/utilities/command_line.py $*
}

pdbyt()
{
    [ -f ${YTPATH}/yt/utilities/command_line.py ] && python2.7 -m pdb ${YTPATH}/yt/utilities/command_line.py $*
}

iyt()
{
    python2.7 ${YTPATH}/scripts/iyt
}

yt_lodgeit.py()
{
    python2.7 ${YTPATH}/scripts/yt_lodgeit.py $*
}

###--------------------------------------------------
### aliases
alias 'c'='cat'
alias 'g'='grep -i'
alias 'm'='less'
alias 'p'='pwd'
alias 'l'='ls -avFG'
alias 'ls'='ls -vG'
alias 'mk'='make'
alias 'which-command'='whence -afv'
alias 'which'='whence -afv'
alias 'pushd'='pushd;dirs -v'
alias 'popd'='podp;dirs -v'
alias 'd'='dirs -v'
alias 'j'='jobs -lp'
alias 'h'='fc -ldD -40'
alias 'svdiff'='$HOME/.vim/svn_vimdiff.sh'

###--------------------------------------------------
### options
setopt autocd autolist automenu autopushd braceccl cdablevars
setopt correct extendedglob noflowcontrol
setopt histignoredups histignorespace histnostore listtypes longlistjobs sharehistory
setopt cshnullglob magicequalsubst listpacked
setopt numericglobsort pushdignoredups pushdminus pushdsilent
setopt pushdtohome rcexpandparam rcquotes
setopt sunkeyboardhack zle nobadpattern autoremoveslash
setopt completeinword autoparamkeys
setopt alwayslastprompt

unsetopt bgnice norcs notify nonomatch hashdirs listambiguous

# Must have the zsh/termcap module loaded for this
if [[ $terminfo[colors] -ge 8 ]]; then
    local RED="%{%}"
    local LIGHT_RED="%{%}"
    local CYAN="%{%}"
    local LIGHT_CYAN="%{%}"
    local BLUE="%{%}"
    local LIGHT_BLUE="%{%}"
    local GREEN="%{%}"
    local LIGHT_GREEN="%{%}"
    local MAGENTA="%{%}"
    local LIGHT_MAGENTA="%{%}"
    local YELLOW="%{%}"
    local LIGHT_YELLOW="%{%}"
    local GRAY="%{%}"
    local LIGHT_GRAY="%{%}"
    local WHITE="%{%}"
    local NO_COLOUR="%{%}"
    local BEGINNING_OF_LINE="%{%}"
else
    local RED=""
    local LIGHT_RED=""
    local CYAN=""
    local LIGHT_CYAN=""
    local BLUE=""
    local LIGHT_BLUE=""
    local GREEN=""
    local LIGHT_GREEN=""
    local MAGENTA=""
    local LIGHT_MAGENTA=""
    local YELLOW=""
    local LIGHT_YELLOW=""
    local GRAY=""
    local LIGHT_GRAY=""
    local WHITE=""
    local NO_COLOUR=""
    local BEGINNING_OF_LINE=""
fi


###--------------------------------------------------
### prompts
PROMPT="%(?..(${RED}{%?}${NO_COLOUR}%))[${YELLOW}%T${NO_COLOUR}][${CYAN}%15<...<%~${NO_COLOUR}]$ "

unset P


### COMPLETION AND MORE

# The following lines were added by compinstall
[[ -z $fpath[(r)$_compdir] ]] && fpath=($fpath $_compdir)
#fpath=(/home/tkoehler/zsh/foo $fpath)

autoload -U compinit
compinit

local _myhosts
_myhosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
# zstyle ':completion:*' hosts $_myhosts

zstyle ':completion:*' auto-description 'specify %d'
zstyle ':completion:*' completer _complete _ignored _match _correct _approximate _prefix
zstyle ':completion:*' file-sort name
zstyle ':completion:*' group-name ''
## domains to use for mutt user@host<TAB> completion
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' matcher-list 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' 'm:{a-z}={A-Z}'
zstyle ':completion:*' match-original both
zstyle ':completion:*' max-errors 3
zstyle ':completion:*' menu select=0
zstyle ':completion:*' prompt 'CORRECT (%e errors found) > '
zstyle ':completion:*' special-dirs true
zstyle ':completion:*' squeeze-slashes true
zstyle '*mutt*' users vim vim-dev tkoehler
zstyle '*' users thomas tkoehler
zstyle ':completion:*' verbose true
zstyle :compinstall filename '/home/tkoehler/.zshrc'
# End of lines added by compinstall
#fpath=(/usr/share/doc/zsh/examples/Functions/Misc/ $fpath)
#autoload nslookup


zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:*:*:hosts' list-colors '=(#b)(*)(to.com)=34;40=35;40' '=(#b)(*)(mayn.de)=36;40=35;40' '=unser.linux.laeuft.auf.s390.org=33;40' '=*=31;40'
zstyle ':completion:*:*:*:*:users' list-colors '=*=32;40'

autoload -U zfinit
zfinit

ZLS_COLOURS='ma=7:di=0:ex=0:bd=0:cd=0:ln=0:so=0'

### KEY BINDINGS
# vi keybindings
bindkey -v

bindkey "^P" history-beginning-search-backward
bindkey "^N" history-beginning-search-forward
bindkey "" forward-char
bindkey "" backward-char
bindkey "^Xq" push-line
bindkey "^Xr" history-incremental-search-backward
bindkey "^Xs" history-incremental-search-forward
bindkey "^X_" insert-last-word
bindkey "^Xa" accept-and-hold
bindkey "^X^H" run-help
bindkey "^Xh" _complete_help
bindkey "^I" expand-or-complete
bindkey "^E" expand-word
bindkey -M vicmd "^R" redo
bindkey -M vicmd "u" undo
bindkey -M vicmd "ga" what-cursor-position

### VI MODE EXTENSIONS
redisplay() {
   builtin zle .redisplay
   ( true ; show_mode "insert") &!
}
redisplay2() {
   builtin zle .redisplay
   (true ; show_mode "normal") &!
}
zle -N redisplay
zle -N redisplay2
bindkey -M viins "^X^R" redisplay
bindkey -M vicmd "^X^R" redisplay2

screenclear () {
   echo -n "\033[2J\033[400H"
   builtin zle .redisplay
   (true ; show_mode "insert") &!
}
zle -N screenclear
bindkey "" screenclear

screenclearx () {
   # print -n '7'
   repeat 2 print 
   local MYLINE="$LBUFFER$RBUFFER"
   highlight $MYLINE
   repeat 4 print 
   builtin zle redisplay
}
zle -N screenclearx
bindkey "^Xl" screenclearx

show_mode() {
   local COL
   local x
   COL=$[COLUMNS-3]
   COL=$[COL-$#1]
   x=$(echo $PREBUFFER | wc -l )
   x=$[x+1]
   echo -n "7[0;$COL;H"
   echo -n ""

   if [[ $1 = insert ]]; then
       echo -n " Insert "
   fi
   if [[ $1 = normal ]]; then
       echo -n " Normal "
   fi
   if [[ $1 = replace ]]; then
       echo -n " Replace "
   fi
   echo -n "8"
}

###       vi-add-eol (unbound) (A) (unbound)
###              Move  to the end of the line and enter insert mode.
vi-add-eol() {
   show_mode "insert"
   builtin zle .vi-add-eol
}
zle -N vi-add-eol
bindkey -M vicmd "A" vi-add-eol

###       vi-add-next (unbound) (a) (unbound)
###              Enter insert mode after the  current  cursor  posi­
###              tion, without changing lines.
vi-add-next() {
   show_mode "insert"
   builtin zle .vi-add-next
}
zle -N vi-add-next
bindkey -M vicmd "a" vi-add-next

###       vi-change (unbound) (c) (unbound)
###              Read a movement command from the keyboard, and kill
###              from  the  cursor  position  to the endpoint of the
###              movement.  Then enter insert mode.  If the  command
###              is vi-change, change the current line.

vi-change() {
   show_mode "insert"
   builtin zle .vi-change
}
zle -N vi-change
bindkey -M vicmd "c" vi-change

###       vi-change-eol (unbound) (C) (unbound)
###              Kill  to the end of the line and enter insert mode.
vi-change-eol() {
   show_mode "insert"
   builtin zle .vi-change-eol
}
zle -N vi-change-eol
bindkey -M vicmd "C" vi-change-eol

###       vi-change-whole-line (unbound) (S) (unbound)
###              Kill the current line and enter insert mode.
vi-change-whole-line() {
   show_mode "insert"
   builtin zle .vi-change-whole-line
}
zle -N vi-change-whole-line
bindkey -M vicmd "S" vi-change-whole-line

###       vi-insert (unbound) (i) (unbound)
###              Enter insert mode.
vi-insert() {
   show_mode "insert"
   builtin zle .vi-insert
}
zle -N vi-insert
bindkey -M vicmd "i" vi-insert

###       vi-insert-bol (unbound) (I) (unbound)
###              Move to the first non-blank character on  the  line
###              and enter insert mode.
vi-insert-bol() {
   show_mode "insert"
   builtin zle .vi-insert-bol
}
zle -N vi-insert-bol
bindkey -M vicmd "I" vi-insert-bol

###       vi-open-line-above (unbound) (O) (unbound)
###              Open a line above the cursor and enter insert mode.
vi-open-line-above() {
   show_mode "insert"
   builtin zle .vi-open-line-above
}
zle -N vi-open-line-above
bindkey -M vicmd "O" vi-open-line-above

###       vi-open-line-below (unbound) (o) (unbound)
###              Open a line below the cursor and enter insert mode.
vi-open-line-below() {
   show_mode "insert"
   builtin zle .vi-open-line-below
}
zle -N vi-open-line-below
bindkey -M vicmd "o" vi-open-line-below

###       vi-substitute (unbound) (s) (unbound)
###              Substitute the next character(s).
vi-substitute() {
   show_mode "insert"
   builtin zle .vi-substitute
}
zle -N vi-substitute
bindkey -M vicmd "s" vi-substitute


###       vi-replace (unbound) (R) (unbound)
###              Enter overwrite mode.
###
vi-replace() {
   show_mode "replace"
   builtin zle .vi-replace
}
zle -N vi-replace
bindkey -M vicmd "R" vi-replace

###       vi-cmd-mode (^X^V) (unbound) (^[)
###              Enter  command  mode;  that  is, select the `vicmd'
###              keymap.  Yes, this is bound  by  default  in  emacs
###              mode.
vi-cmd-mode() {
   show_mode "normal"
   builtin zle .vi-cmd-mode
}
zle -N vi-cmd-mode
bindkey -M viins "" vi-cmd-mode


###       vi-oper-swap-case
###              Read a movement command from the keyboard, and swap
###              the case of all characters from the cursor position
###              to the endpoint of the movement.  If  the  movement
###              command  is vi-oper-swap-case, swap the case of all
###              characters on the current line.
###
bindkey -M vicmd "g~" vi-oper-swap-case