zshrc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #
  2. # .zshrc is sourced in interactive shells.
  3. # It should contain commands to set up aliases,
  4. # functions, options, key bindings, etc.
  5. #
  6. ##################
  7. # LOAD FUNCTIONS #
  8. ##################
  9. ## completions
  10. autoload -U compinit
  11. compinit
  12. ## colors
  13. autoload -U colors
  14. colors
  15. ## renaming
  16. autoload zmv
  17. alias mmv='noglob zmv -W'
  18. ###############
  19. # SET OPTIONS #
  20. ###############
  21. # vi keybindings
  22. bindkey -v
  23. #allow tab completion in the middle of a word
  24. setopt COMPLETE_IN_WORD
  25. ## Correct my spelling
  26. #setopt CORRECT
  27. ## Don't ask me
  28. setopt RMSTARSILENT
  29. ## Don't require 'cd'
  30. #setopt AUTOCD
  31. ## Automatically pushd - then I can go to an old dir with cd - <tab> (pick no.)
  32. setopt AUTOPUSHD
  33. export DIRSTACKSIZE=11 # stack size of eleven gives me a list with ten entries
  34. ## Autocomplete hosts from .ssh/known_hosts
  35. #local _myhosts
  36. _myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} )
  37. zstyle ':completion:*' hosts $_myhosts
  38. HISTSIZE=3000
  39. SAVEHIST=3000
  40. HISTFILE=~/.zsh_history
  41. #####################
  42. # SHELL ENVIRONMENT #
  43. #####################
  44. ## Ctrl-W stops at a directory
  45. ## see http://www.zsh.org/mla/users/1995/msg00088.html
  46. WORDCHARS='*?_-.[]~\!#$%^(){}<>|`@#$%^*()+:?'
  47. ## set up my prompt
  48. export PS1="%{${fg[yellow]}%}[%n@%m] %{${fg[green]}%}%3~ %# %{${fg[default]}%}"
  49. #export RPS1="%{${fg[yellow]}%}%T%{${fg[default]}%}"
  50. ## color STDERR red
  51. #exec 2>>(while read line; do
  52. # print '\e[91m'${(q)line}'\e[0m' > /dev/tty; done &)
  53. #if [ "`uname`" = "Darwin" ]; then
  54. # compctl -f -x 'c[-1,-a][-1,-A] p[2]' -s "`/bin/ls -d1 /Applications/*/*.app /Applications/*.app | sed 's|^.*/\([^/]*\)\.app.*|\\1|;s/ /\\\\ /g'`" -- open
  55. # alias run='open -a'
  56. #fi
  57. ## set list colours
  58. export LS_COLORS='no=00:fi=00:di=00;36:ln=01;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
  59. #############
  60. # FUNCTIONS #
  61. #############
  62. trash() { mv $@ ~/.Trash }
  63. pc() { awk "{print \$$1}" }
  64. mcd() { mkdir -p "$1" && cd "$1" }
  65. calc() { echo "$@" | bc -l -q -i }
  66. dont() { echo "OK, I won't!" }
  67. settab() { echo -ne "\e]1;$1\a" }
  68. settabh() { settab `hostname | cut -d. -f1` }
  69. #'"
  70. ###########
  71. # ALIASES #
  72. ###########
  73. ## history
  74. alias h='history'
  75. ## shortcuts
  76. alias l='ls'
  77. alias l1='ls -1'
  78. alias ll='ls -hl'
  79. alias la='ls -A'
  80. alias lal="ls -Ahl"
  81. alias l.='ls -d .[^.]*'
  82. alias lsd='ls -ld *(-/DN)'
  83. alias lg='ls -l | grep -i'
  84. alias cd..='cd ..';
  85. alias ..='cd ..'
  86. alias df='df -h'
  87. alias du='du -sh'
  88. alias mkdir='nocorrect mkdir'
  89. alias mv='nocorrect mv'
  90. alias cp='nocorrect cp'
  91. alias touch='nocorrect touch'
  92. alias ln='nocorrect ln'
  93. alias -g G="| grep"
  94. alias -g g="| grep -i"
  95. alias -g L="| less"
  96. alias -g H="| head"
  97. alias -g ...="../.."
  98. alias -g ....="../../.."
  99. alias -g .....="../../../.."
  100. alias igrep='grep -i'
  101. alias rgrep='grep -R'
  102. alias rigrep='grep -iR'
  103. alias proxy='export http_proxy=http://192.168.1.248:3128;export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
  104. alias noproxy='export http_proxy='';export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
  105. alias hosts='vim /etc/hosts'
  106. alias graceful='apachectl graceful'
  107. alias flushdns='lookupd -flushcache'
  108. alias bc='bc -l'
  109. alias o.='open .'
  110. alias upd='cvs -q upd -dP'
  111. alias upd-head='cvs -q upd -dPA'
  112. #alias guantanamo-start='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k start'
  113. #alias guantanamo-graceful='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k graceful'
  114. #alias guantanamo-stop='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k stop'
  115. #alias guantanamo-check='chroot /jails/guantanamo /usr/local/apache2/bin/apachectl -t'
  116. #alias woomera-start='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k start'
  117. #alias woomera-graceful='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k graceful'
  118. #alias woomera-stop='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k stop'
  119. #alias woomera-check='chroot /jails/woomera /usr/local/apache2/bin/apachectl -t'
  120. #alias littlehey-start='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k start'
  121. #alias littlehey-graceful='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k graceful'
  122. #alias littlehey-stop='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k stop'
  123. #alias littlehey-check='chroot /jails/littlehey /usr/local/apache2/bin/apachectl -t'
  124. #alias alcatraz-start='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k start'
  125. #alias alcatraz-graceful='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k graceful'
  126. #alias alcatraz-stop='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k stop'
  127. #alias alcatraz-check='chroot /jails/alcatraz /usr/local/apache2/bin/apachectl -t'
  128. #alias kerobokan-start='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k start'
  129. #alias kerobokan-graceful='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k graceful'
  130. #alias kerobokan-stop='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k stop'
  131. #alias kerobokan-check='chroot /jails/kerobokan /usr/local/apache2/bin/apachectl -t'
  132. #alias changi-start='/etc/init.d/tc-chroot start'
  133. #alias changi-stop='/etc/init.d/tc-chroot stop'
  134. # If I am on the mac,
  135. if [ `uname` = Darwin ]; then
  136. alias updatedb='sudo /usr/libexec/locate.updatedb'
  137. fi
  138. ## common typos
  139. #alias sl='ls' #commented out because Jaf's steam train /usr/bin/sl much more fun
  140. alias vf='cd'
  141. alias xs='cd'
  142. alias ks='ls'
  143. alias ecgi='echo'
  144. ## ensure X11 is running when I gvim, xterm etc
  145. alias xterm='open -a X11 && /usr/X11R6/bin/xterm -sb -sl 5000 -rightbar -fg white -bg black -geometry 100x50+40+20'
  146. alias gvim='open -a X11 && vim -g'
  147. ## on the other hand, don't try and connect to X when I am not gvimming
  148. #alias vim='vim -X'
  149. #alias x='open -a X11'
  150. settabh
  151. ## shortcuts to other machines
  152. alias murray='ssh weiyi@murray'
  153. alias nile='ssh weiyi@nile'
  154. alias niles='ssh weiyi@nile-stage'
  155. alias orinoco='ssh weiyi@orinoco'
  156. alias orinocos='ssh weiyi@orinoco-stage'
  157. alias kwai='ssh weiyi@kwai'
  158. alias devbox='ssh root@devbox'
  159. alias dev5='ssh root@dev5'
  160. alias danshui='ssh weiyi@danshui'
  161. alias elrond='ssh weiyi@elrond'
  162. alias samwise='ssh weiyi@samwise'
  163. alias tfine='ssh cinaeco@tfine'
  164. alias blackomelette='ssh cinaeco@10.0.1.1'
  165. ## shortcuts for development
  166. alias migrate='li3 migration db:migrate'
  167. alias hr-psych-log='tail -F /jails/kerobokan/usr/local/www-conf/logs/hr-psych-phplog'
  168. alias oars-log='tail -F /jails/alcatraz/usr/local/www-conf/logs/oars-phplog'
  169. alias acerfoundation-log='tail -F /jails/alcatraz/usr/local/www-conf/logs/acerfoundation-phplog'
  170. alias cdo='cd /jails/alcatraz/usr/local/www/oars'
  171. alias cda='cd /jails/alcatraz/usr/local/www/acerfoundation'
  172. alias cdh='cd /jails/kerobokan/usr/local/www/hr-psych'
  173. alias sqlo='mysql -u oars -p'
  174. alias sqla='mysql -u acerfoundation -p'