1
## Profiling options
2
#PS4='+$(date "+%s:%N") %N:%i> '
3
#exec 3>&2 2>/tmp/zsh-startlog.$$
4
#setopt prompt_subst
5
#setopt xtrace
6
7
typeset -ga preexec_functions
8
typeset -ga precmd_functions
9
typeset -ga chpwd_functions
10
fpath=($fpath $HOME/.zsh/func)
11
#typeset -u fpath
12
13
# Options
14
setopt appendhistory hist_ignore_space hist_ignore_all_dups extendedglob nomatch notify dvorak # correct
15
unsetopt beep
16
bindkey -e
17
18
zstyle :compinstall filename '~/.zshrc'
19
autoload -Uz compinit colors zgitinit && colors && zgitinit
20
compinit -u
21
#bindkey '^L' push-line
22
bindkey "^I" expand-or-complete-prefix
23
umask 022
24
25
# Fix $TERM
26
if [ -f /etc/termcap ] ; then
27
    export TERMCAP=/etc/termcap
28
fi
29
case "$TERM" in
30
    rxvt-unicode) export TERM=rxvt;;
31
    rxvt-256color) export TERM=rxvt;;
32
esac
33
34
# Paths
35
#export LD_LIBRARY_PATH=/opt/csw/lib
36
#zsh's path
37
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
38
export MANPATH=~/local/share/man:/usr/man:/usr/share/man
39
paths=(/usr/texbin /cat/bin /cat/games/bin /opt/csw/sbin /opt/csw/bin /pkgs/ghc/current/bin
40
/pkgs/chromium/bin /usr/sfw/sbin /usr/sfw/bin /opt/SUNWut/sbin /opt/SUNWut/bin
41
/usr/ccs/bin /opt/local/sbin /opt/local/bin /usr/local/share/bin /usr/openwin/bin /usr/bin/X11
42
/usr/local/bin/X11 /usr/openwin/bin/xview /opt/java/bin /opt/java5/bin
43
/opt/java/jre/bin /opt/openoffice/program)
44
prepaths=(/usr/local/bin /usr/local/sbin ~/.cabal/bin ~/local/bin ~/local/sbin
45
~/local/share/bin)
46
for dir in $paths ; do
47
    if [ -d $dir ] ; then
48
        export PATH=$PATH:$dir
49
    fi
50
    if [ -d `dirname $dir`/man ] ; then
51
        export MANPATH=$MANPATH:`dirname $dir`/man
52
    fi
53
done
54
for dir in $prepaths ; do
55
    if [ -d $dir ] ; then
56
        export PATH=$dir:$PATH
57
    fi
58
    if [ -d `dirname $dir`/man ] ; then
59
        export MANPATH=`dirname $dir`/man:$MANPATH
60
    fi
61
done
62
# Load profiles from /etc/profile.d
63
if test -d /etc/profile.d/; then
64
    for profile in /etc/profile.d/*.sh; do
65
        test -x $profile && . $profile
66
    done
67
    unset profile
68
fi
69
#gem's path
70
if [ -d ~/.gems/bin ] ; then
71
    export PATH="$HOME/.gems/bin:$PATH"
72
fi
73
if [ -d ~/.gem/ruby/1.8/bin ] ; then
74
    export PATH="$PATH:$HOME/.gem/ruby/1.8/bin"
75
fi
76
#for dir in `find /opt/*/bin|grep /bin$` `find /opt/csw/*/bin|grep /bin$` ; do
77
#    export PATH=$PATH:$dir
78
#done
79
80
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
81
82
83
# Setting vars
84
#TERM=rxvt
85
#export GEM_HOME="$HOME/.gems"
86
#export GEM_HOME="/Library/Ruby/Gems/1.8"
87
#export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
88
#export GEM_PATH="/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"
89
zshhosts=(serenity.cat.pdx.edu hunner@mint.cic.pdx.edu drkatz.cat.pdx.edu walt.ece.pdx.edu bunny.cat.pdx.edu spof.cat.pdx.edu fops.cat.pdx.edu narsil.cat.pdx.edu hunner@odin.pdx.edu hunnur@alcmaeonllc.com mir.cat.pdx.edu geppetto.cat.pdx.edu)
90
HISTSIZE=1000
91
SAVEHIST=1000
92
HISTFILE=~/.history
93
export GPGKEY="48C7AF0C"
94
export NETHACKOPTIONS='autopickup,color,!cmdassist,!number_pad,hilite_pet,boulder:0,pickup_types:$"=/!?+,menustyle:partial,!legacy,suppress_alert:3.3.1'
95
export ENVPUPPET_BASEDIR="/Users/hunner/Documents/work/git"
96
export OVFTOOL='/Applications/VMware OVF Tool/ovftool'
97
98
# Prompt
99
#PS1="%m%# "
100
prompt_precmd() {
101
    gitcolor=""
102
    if zgit_isgit ; then
103
        if ! zgit_isindexclean ; then
104
            #PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f](%F{cyan}$(zgit_branch)%f)>"
105
            gitcolor=$fg[blue]
106
        elif ! zgit_isworktreeclean ; then
107
            #PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f]>"
108
            gitcolor=$fg[green]
109
        fi
110
    fi
111
    color="%(?.$gitcolor.$fg[red])"
112
    PROMPT="%m$color%#%{$reset_color%} "
113
}
114
#precmd_functions+=prompt_precmd
115
PROMPT="%m%# "
116
117
if [ `uname -s` = "SunOS" ] ; then
118
    export LANG="C"
119
else
120
    export LANG="en_US.UTF-8"
121
fi
122
#export LC_CTYPE="en_US.UTF-8"
123
export LC_COLLATE="C" #order files in ls
124
#export LC_TIME="en_US.UTF-8"
125
#export LC_NUMERIC="en_US.UTF-8"
126
#export LC_MONETARY="en_US.UTF-8"
127
#export LC_MESSAGES="en_US.UTF-8"
128
#export LC_ALL='en_US.utf8'
129
export DIALOGOPTS='--visit-items'
130
export MAIL=~/mail
131
export MAILCHECK=0
132
#export AWT_TOOLKIT=MToolkit
133
#export AWT_TOOLKIT=XToolkit
134
export _JAVA_AWT_WM_NONREPARENTING=1
135
if [ -x `whence less` ] ; then
136
    export PAGER==less
137
else
138
    export PAGER==more
139
fi
140
if [ -z "$PERL5LIB" ] ; then
141
        # If PERL5LIB wasn't previously defined, set it...
142
        export PERL5LIB=~/local/lib/perl5:~/local/lib/perl5/site_perl
143
else
144
        # ...otherwise, extend it.
145
        export PERL5LIB=$PERL5LIB:~/local/lib/perl5:~/local/lib/perl5/site_perl
146
fi
147
148
## Set up vim aliases
149
if whence vim > /dev/null ; then
150
    VIM=vim
151
    if whence mvim > /dev/null ; then
152
        #VIM=mvim
153
        VIM="mvim -c 'au VimLeave * maca hide:'"
154
    fi
155
else
156
    VIM=vi
157
fi
158
export VISUAL="$VIM -f"
159
export EDITOR="$VIM -f"
160
alias v=$VIM
161
alias vh="mvim -c 'au VimLeave * maca hide:'"
162
alias vi=$VIM
163
alias vr="$VIM --remote-tab"
164
alias vl="$VIM --serverlist"
165
vs() { $VIM --servername $1 --remote-tab $argv[2,$] }
166
alias vd=${VIM}diff
167
alias vir=vr
168
alias vis=vs
169
alias gvim="gvim -font 'APL385 Unicode 8' -c 'set keymap=uniapl385'"
170
171
## For forwarding ssh auth I think
172
if [ -n "$SSH_AUTH_SOCK" ] ; then
173
    ln -fs $SSH_AUTH_SOCK $HOME/.ssh-agent
174
fi
175
176
## Add extra fonts
177
#xset fp+ /usr/APL2/fonts/X11
178
#xset fp  rehash
179
180
## Set up ruby gems for $RUBYLIB
181
#if [ -d $HOME/.gems/gems ] ; then
182
#    for rlib in $HOME/.gems/gems/*/lib ; do
183
#        export RUBYLIB=$RUBYLIB:$rlib
184
#    done
185
#fi
186
#for rubylib in /usr/lib/ruby/gems/1.8/gems/*/lib ; do
187
#    export RUBYLIB=$RUBYLIB:$rubylib
188
#done
189
190
# Aliases
191
alias ls="ls -F"
192
alias l="ls -F"
193
alias ll="l -Fl"
194
alias la="l -Fa"
195
alias lla="ll -Fa"
196
alias c="cd"
197
cl() { cd $@ && ls }
198
alias e="TERM=rxvt-256color; emacs -nw"
199
alias et="TERM=rxvt-256color; emacsclient -t"
200
alias ec="emacsclient -c --eval '(set-background-color \"black\")'"
201
alias ecx="emacsclient --eval '(make-frame-on-display \"$DISPLAY\")'"
202
#alias s="TERM=xterm;ssh serenity.cat.pdx.edu"
203
alias s="TERM=rxvt;ssh hunner@serenity.cat.pdx.edu"
204
alias f="TERM=rxvt;ssh hunner@firefly.cat.pdx.edu"
205
alias z="TERM=rxvt;ssh hunner@zabava.cat.pdx.edu"
206
alias o="TERM=rxvt;ssh hunner@osiris.cat.pdx.edu"
207
alias m="TERM=rxvt;ssh hunner@mint.cic.pdx.edu"
208
alias chandra="TERM=rxvt;ssh hunner@chandra.cs.pdx.edu"
209
export CS=cs.pdx.edu
210
alias odin="TERM=xterm;ssh hunner@odin.pdx.edu"
211
alias budda="ssh hunnur@budda.dreamhost.com"
212
alias kvar="ssh hunner@131.252.134.134"
213
alias kvin="ssh hunner@131.252.135.22"
214
alias mutt="TERM=xterm-256color mutt"
215
alias x="exit"
216
alias gpg-add="/usr/libexec/gpg-preset-passphrase"
217
alias rsync="rsync -azPHe ssh" #-a equals -rlptgoD
218
alias mang="cd ~/zips/mangband ; DISPLAY=\"\" ./mangclient"
219
alias nh="export HISTFILE=/dev/null"
220
#alias cl="co -l"
221
alias cu="ci -u"
222
alias sl="screen -ls"
223
alias sr="screen -r"
224
alias sx="screen -x"
225
alias srd="screen -rd"
226
alias t="TERM=xterm-256color tmux at"
227
alias tl="tmux ls"
228
alias bc="bc -q"
229
alias fm="fmstatus.sh&;shell-fm"
230
alias apl="gvim -font 'APL385 Unicode 14' -c 'set keymap=uniapl385'"
231
alias d="dtach -a ~/.dtach"
232
alias eo="xmodmap ~/keymaps/eo_dv_hunner.pke"
233
alias vt="export TERM=vt220"
234
alias rm=rm; unalias rm #hack
235
alias g="git"
236
alias gl="git lg"
237
alias gp="git push"
238
alias gu="git pull"
239
alias gs="git status"
240
alias gm="git mv"
241
alias gr="git rm"
242
alias ga="git add"
243
alias gaf="git add --force"
244
alias gb="git branch"
245
alias gc="git commit"
246
alias gca="git commit --amend"
247
alias gd="git diff"
248
alias gdw="git diff --color-words"
249
alias gdt="git difftool"
250
alias go="git checkout"
251
alias gob="git checkout -b"
252
alias gk="gitk --all&"
253
alias gx="gitx --all"
254
alias uzbl="uzbl-browser"
255
alias hide="SetFile -a V"
256
alias show="SetFile -a v"
257
#startup aliases
258
alias -s pdf="zathura"
259
alias -s txt="vi"
260
alias -s flv="mplayer"
261
alias -s avi="mplayer"
262
alias -s mkv="mplayer"
263
alias -s mpg="mplayer"
264
265
# Functions
266
args() { echo $#; }
267
title() { WINTITLE="$*"; print -Pn "\e]0;$WINTITLE\a" }
268
#if [ x$WINDOW != x ]; then
269
#    # Running under screen(1)
270
#    precmd()  { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [W$WINDOW] [%~]\a" || : }
271
#    preexec() { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [W$WINDOW] [$1]\a" || : }
272
#else
273
#    precmd()  { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [%~]\a" || : }
274
#    preexec() { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [$1]\a" || : }
275
#fi
276
if [ x$DISPLAY != x ] ; then
277
    precmd()  { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [%~]\a" || : }
278
    preexec() { [ -z "$WINTITLE" ] && print -Pn "\e]0;%m [$1]\a" || : }
279
fi
280
alias resize="printf '\33]50;%s%d\007' 'xft:Terminus:pixelsize=' $1" # ':antialias=true'"
281
alias asdf="xkbcomp -w0 ~/keymaps/xkb/hunner.xkb $DISPLAY"
282
alias auie="xkbcomp -w0 ~/keymaps/xkb/hunner.xkb $DISPLAY"
283
alias aoeu='setxkbmap us'
284
alias bepo='setxkbmap fr bepo "ctrl:swapcaps"'
285
alias notes='vi ~/Dropbox/Notes/vim*'
286
alias 256colors='(x=`tput op` y=`printf %80s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)'
287
alias hibernateon='sudo pmset -a hibernatemode 25'
288
alias hibernateoff='sudo pmset -a hibernatemode 3'
289
alias hibernate='pmset -g|grep hibernatemode'
290
291
if [ -f $HOME/.termcap ] ; then
292
    TERMCAP=$(< $HOME/.termcap)
293
    export TERMCAP
294
fi
295
make_termcap() {
296
    cat > $HOME/.termcap << EOF
297
rxvt-256color|rxvt-256color terminal (X Window System):\
298
    :Co#256:\
299
    :tc=rxvt-unicode:\
300
    :tc=rxvt:
301
EOF
302
}
303
type7() {
304
    if [ `uname -s` = "SunOS" ] ; then
305
        xmodmap ~/keymaps/eo_dv_hunner_type7_sol.pke
306
    else
307
        xmodmap ~/keymaps/nu_type7.pke
308
    fi
309
}
310
zpush() {
311
    for host in $zshhosts ; do
312
        files=(.zshrc .vim .vimrc)
313
        if [ x$(hostname) = x$host ] ; then
314
            continue
315
        fi
316
        if [ $(uname) = "Linux" ] ; then
317
            ping -c1 -W1 ${host#*@} > /dev/null
318
        else
319
            ping -c1 -t1 ${host#*@} > /dev/null
320
        fi
321
        if [ $status -eq 0 ] ; then
322
            echo -n "$host: copying"
323
            for file in $files ; do
324
                echo -n .
325
                if ! rsync -azPH $file $host:~ > /dev/null ; then continue 2 ; fi
326
            done
327
            echo "done"
328
            #rsync .zshenv $host:~ > /dev/null
329
        else
330
            echo "$host: unpings"
331
        fi
332
    done;
333
}
334
function r() {
335
    if [[ -n $TMUX ]]; then
336
        NEW_SSH_AUTH_SOCK=`tmux showenv|grep ^SSH_AUTH_SOCK|cut -d = -f 2`
337
        if [[ -n $NEW_SSH_AUTH_SOCK ]] && [[ -S $NEW_SSH_AUTH_SOCK ]]; then
338
            SSH_AUTH_SOCK=$NEW_SSH_AUTH_SOCK
339
        fi
340
    fi
341
}
342
ex () {
343
    if whence gtar > /dev/null ; then
344
        TAR=gtar
345
    else
346
        TAR=tar
347
    fi
348
    if [ -f $1 ] ; then
349
        case $1 in
350
            *.tar.bz2)   $TAR xvjf $1  ;;
351
            *.tar.gz)    $TAR xvzf $1  ;;
352
            *.tar.xz)    $TAR xvJf $1  ;;
353
            *.bz2)       bunzip2 $1    ;;
354
            *.rar)       unrar x $1    ;;
355
            *.gz)        gunzip $1     ;;
356
            *.xz)        unxz $1       ;;
357
            *.tar)       $TAR xvf $1   ;;
358
            *.tbz2)      $TAR xvjf $1  ;;
359
            *.tbz)       $TAR xvjf $1  ;;
360
            *.tgz)       $TAR xvzf $1  ;;
361
            *.txz)       $TAR xvJf $1  ;;
362
            *.zip)       unzip $1      ;;
363
            *.Z)         uncompress $1 ;;
364
            *.7z)        7z x $1       ;;
365
            *)           echo "don't know how to extract '$1'..." ;;
366
        esac
367
    else
368
        echo "'$1' is not a valid file!"
369
    fi
370
}
371
372
## Profiling options
373
#unsetopt xtrace
374
#exec 2>&3 3>&-