ftp -o - https://jcs.org/move_in | sh -
1# vim:ts=3:et:ft=zsh
2#
3# zshell config
4# joshua stein <jcs@jcs.org>
5#
6
7# environment variables
8export BLOCKSIZE=1k
9export CVS_RSH=/usr/bin/ssh
10export IRCNAME="*Unknown*"
11unset HISTFILE
12export LANG=en_US.UTF-8
13export LESS="-i"
14export LESSHISTFILE=/dev/null
15export MYSQL_HISTFILE=/dev/null
16export NO_COLOR=1
17export PAGER="less -R"
18export PATH=~/bin:~/go/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin
19export SSH_ASKPASS_REQUIRE=prefer
20
21# let control+w only delete one directory of a path, not the whole word
22export WORDCHARS='*?_[]~=&;!#$%^(){}'
23
24# on non-interactive shells, just exit here to speed things up
25if [[ ! -o interactive ]]; then
26 return
27fi
28
29# zsh will try to use vi key bindings because of the vi $EDITOR, but i want
30# emacs style for control+a/e, etc.
31bindkey -e
32
33# i'm too lazy to type these out
34alias calc='perl -pe "print eval(\$_) . chr(10);"'
35alias cdgmp='cd /usr/src/sys/arch/`arch -s`/compile/GENERIC.MP'
36alias cdu="cvs -q diff -upRN"
37alias cp="cp -i"
38alias gd="git diff"
39alias gs="git status"
40alias hg="history | grep "
41alias jobs="jobs -p"
42alias k9="kill -9 %1"
43alias ll="ls -alF"
44alias ltr="ls -alFtr"
45alias ls="ls -aF"
46alias mv="mv -i"
47alias offline_mutt="mutt -R -F ~/.muttrc.offline"
48alias patchp0="patch -p0 -V none"
49alias ph="ps auwwx | head"
50alias pg="ps auwwx | grep -i -e ^USER -e "
51alias publicip="curl -w '\n' -s http://ifconfig.me"
52alias refetch="cvs -q up -PACd"
53alias rg="rg --color=never -N -z"
54alias telnet="telnet -K"
55alias tm="tail -f /var/log/messages"
56alias u="cvs -q up -PAd"
57# serve up the current directory
58alias webserver="ifconfig | grep 'inet ' | grep -v 127.0.0.1; python2 -m SimpleHTTPServer"
59
60# when i say vi i mean vim (if it's installed)
61if [ -x "`which vim`" ]; then
62 alias vi="vim"
63 alias view="vim -R"
64 export EDITOR=`which vim`
65else
66 export EDITOR=/usr/bin/vi
67fi
68
69# options
70setopt noclobber # halp me
71setopt nohup # don't kill things when i logout
72setopt print_exit_value # i want to know if something went wrong
73HISTSIZE=500
74PS1="%m:%~%(!.#.$) " # prompt
75TMOUT=0 # don't auto logout
76
77# i am frequently too quick to logout with control+d twice (one to exit ssh,
78# another to close the terminal) and will miss the 'you have suspended jobs'
79# message, so hitting it twice still logs me out. prevent that by not sending
80# eof on control+d but manually bind to it and run a function that exits.
81setopt ignore_eof
82_block_quick_bail() {
83 _sj=`jobs -sp`
84 if [[ $_sj == "" ]]; then
85 exit
86 else
87 _sj=$'\n'${_sj}
88 zle -M "zsh: you have suspended jobs:${_sj}"
89 fi
90}
91zle -N _block_quick_bail
92bindkey '^d' _block_quick_bail
93
94# show all logins and such
95watch=all
96WATCHFMT="%B%n%b %a %l at %@"
97
98# etc
99limit coredumpsize 0 # don't know why you'd want anything else
100umask 022 # be nice
101
102# https://superuser.com/questions/458906
103__git_files () {
104 _wanted files expl 'local files' _files
105}
106
107# envs.sh file service
108mirror() {
109 curl -F "url=$1" https://envs.sh/
110}
111upload() {
112 if [[ -z $1 ]]; then a="file=@-"; else a="file=@$1"; fi
113 curl -F $a https://envs.sh/
114}
115
116# os-specific tweaks
117
118# mac os
119if [[ $OSTYPE = darwin* ]]; then
120 export STORE_LASTDIR=1
121 export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
122
123elif [[ $OSTYPE = linux* ]]; then
124 alias ls="ls -aFv"
125 alias ph="ps auwwx | sort -rk 3,3 | head"
126fi
127
128# and the reverse
129if [[ $OSTYPE != linux* ]]; then
130 # siginfo
131 stty status '^T'
132fi
133
134if [[ $OSTYPE != darwin* ]]; then
135 watch=
136fi
137
138case $TERM in
139xterm*)
140 precmd() { print -Pn "\e]0;%m:%~$\a" }
141 preexec() { print -Pn "\e]0;%m:%~$ ${~1:gs/%/%%}\a" }
142;;
143esac
144
145if [ -f ~/.zshrc.local ]; then
146 source ~/.zshrc.local
147fi
148
149if [ "$STORE_LASTDIR" = "1" ]; then
150 # now go to the last dir that was there
151 chpwd() {
152 pwd >! ~/.zsh.lastdir
153 }
154
155 if [ -f ~/.zsh.lastdir ]; then
156 if [ -d "`cat ~/.zsh.lastdir`" ]; then
157 cd "`cat ~/.zsh.lastdir`"
158 else
159 rm -f ~/.zsh.lastdir
160 fi
161 fi
162fi