zshrc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. #allow tab completion in the middle of a word
  22. setopt COMPLETE_IN_WORD
  23. ## Correct my spelling
  24. #setopt CORRECT
  25. ## Don't ask me
  26. setopt RMSTARSILENT
  27. ## Don't require 'cd'
  28. #setopt AUTOCD
  29. ## Automatically pushd - then I can go to an old dir with cd - <tab> (pick no.)
  30. setopt AUTOPUSHD
  31. export DIRSTACKSIZE=11 # stack size of eleven gives me a list with ten entries
  32. ## Autocomplete hosts from .ssh/known_hosts
  33. #local _myhosts
  34. _myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} )
  35. zstyle ':completion:*' hosts $_myhosts
  36. HISTSIZE=3000
  37. SAVEHIST=3000
  38. HISTFILE=~/.zsh_history
  39. #####################
  40. # SHELL ENVIRONMENT #
  41. #####################
  42. ## Ctrl-W stops at a directory
  43. ## see http://www.zsh.org/mla/users/1995/msg00088.html
  44. WORDCHARS='*?_-.[]~\!#$%^(){}<>|`@#$%^*()+:?'
  45. ## set up my prompt
  46. export PS1="%{${fg[yellow]}%}[%n@%m] %{${fg[green]}%}%3~ %# %{${fg[default]}%}"
  47. #export RPS1="%{${fg[yellow]}%}%T%{${fg[default]}%}"
  48. ## color STDERR red
  49. #exec 2>>(while read line; do
  50. # print '\e[91m'${(q)line}'\e[0m' > /dev/tty; done &)
  51. #if [ "`uname`" = "Darwin" ]; then
  52. # 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
  53. # alias run='open -a'
  54. #fi
  55. #############
  56. # FUNCTIONS #
  57. #############
  58. trash() { mv $@ ~/.Trash }
  59. pc() { awk "{print \$$1}" }
  60. mcd() { mkdir -p "$1" && cd "$1" }
  61. calc() { echo "$@" | bc -l -q -i }
  62. dont() { echo "OK, I won't!" }
  63. settab() { echo -ne "\e]1;$1\a" }
  64. settabh() { settab `hostname | cut -d. -f1` }
  65. #'"
  66. ###########
  67. # ALIASES #
  68. ###########
  69. ## history
  70. alias h='history'
  71. ## shortcuts
  72. alias l='ls'
  73. alias l1='ls -1'
  74. alias ll='ls -hl'
  75. alias la='ls -A'
  76. alias lal="ls -Ahl"
  77. alias l.='ls -d .[^.]*'
  78. alias lsd='ls -ld *(-/DN)'
  79. alias lg='ls -l | grep -i'
  80. alias cd..='cd ..';
  81. alias ..='cd ..'
  82. alias df='df -h'
  83. alias du='du -sh'
  84. alias mkdir='nocorrect mkdir'
  85. alias mv='nocorrect mv'
  86. alias cp='nocorrect cp'
  87. alias touch='nocorrect touch'
  88. alias ln='nocorrect ln'
  89. alias -g G="| grep"
  90. alias -g g="| grep -i"
  91. alias -g L="| less"
  92. alias -g H="| head"
  93. alias -g ...="../.."
  94. alias -g ....="../../.."
  95. alias -g .....="../../../.."
  96. alias igrep='grep -i'
  97. alias rgrep='grep -R'
  98. alias rigrep='grep -iR'
  99. alias phplog='tail -f /private/etc/httpd/phplog.txt'
  100. alias proxy='export http_proxy=http://192.168.1.102:3128;export HTTP_PROXY=$http_proxy;export FTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export ftp_proxy=$http_proxy;'
  101. alias noproxy="export http_proxy='';export HTTP_PROXY=$http_proxy;export FTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export ftp_proxy=$http_proxy;"
  102. alias hosts='vim /etc/hosts'
  103. alias graceful='apachectl graceful'
  104. alias flushdns='lookupd -flushcache'
  105. alias bc='bc -l'
  106. alias o.='open .'
  107. alias upd='cvs -q upd -dP'
  108. alias upd-head='cvs -q upd -dPA'
  109. #alias guantanamo-start='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k start'
  110. #alias guantanamo-graceful='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k graceful'
  111. #alias guantanamo-stop='env -i /usr/sbin/chroot /jails/guantanamo /usr/local/apache2/bin/httpd -k stop'
  112. #alias guantanamo-check='chroot /jails/guantanamo /usr/local/apache2/bin/apachectl -t'
  113. #alias woomera-start='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k start'
  114. #alias woomera-graceful='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k graceful'
  115. #alias woomera-stop='env -i /usr/sbin/chroot /jails/woomera /usr/local/apache2/bin/httpd -k stop'
  116. #alias woomera-check='chroot /jails/woomera /usr/local/apache2/bin/apachectl -t'
  117. #alias littlehey-start='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k start'
  118. #alias littlehey-graceful='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k graceful'
  119. #alias littlehey-stop='env -i /usr/sbin/chroot /jails/littlehey /usr/local/apache2/bin/httpd -k stop'
  120. #alias littlehey-check='chroot /jails/littlehey /usr/local/apache2/bin/apachectl -t'
  121. #alias alcatraz-start='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k start'
  122. #alias alcatraz-graceful='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k graceful'
  123. #alias alcatraz-stop='env -i /usr/sbin/chroot /jails/alcatraz /usr/local/apache2/bin/httpd -k stop'
  124. #alias alcatraz-check='chroot /jails/alcatraz /usr/local/apache2/bin/apachectl -t'
  125. #alias kerobokan-start='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k start'
  126. #alias kerobokan-graceful='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k graceful'
  127. #alias kerobokan-stop='env -i /usr/sbin/chroot /jails/kerobokan /usr/local/apache2/bin/httpd -k stop'
  128. #alias kerobokan-check='chroot /jails/kerobokan /usr/local/apache2/bin/apachectl -t'
  129. #alias changi-start='/etc/init.d/tc-chroot start'
  130. #alias changi-stop='/etc/init.d/tc-chroot stop'
  131. # If I am on the mac,
  132. if [ `uname` = Darwin ]; then
  133. alias updatedb='sudo /usr/libexec/locate.updatedb'
  134. fi
  135. ## common typos
  136. #alias sl='ls' #commented out because Jaf's steam train /usr/bin/sl much more fun
  137. alias vf='cd'
  138. alias xs='cd'
  139. alias ks='ls'
  140. alias ecgi='echo'
  141. ## ensure X11 is running when I gvim, xterm etc
  142. alias xterm='open -a X11 && /usr/X11R6/bin/xterm -sb -sl 5000 -rightbar -fg white -bg black -geometry 100x50+40+20'
  143. alias gvim='open -a X11 && vim -g'
  144. ## on the other hand, don't try and connect to X when I am not gvimming
  145. #alias vim='vim -X'
  146. #alias x='open -a X11'
  147. ## shortcuts to other machines
  148. alias dev='ssh mekong && settabh'
  149. alias elrond='ssh elrond && settabh'
  150. alias samwise='ssh samwise && settabh'
  151. alias legolas2='ssh legolas2 && settabh'
  152. alias web1='ssh web1 && settabh'
  153. settabh
  154. alias debug='strace -f -e open'
  155. alias athome='screen -t murray'
  156. alias selrond='screen -t elrond ssh elrond'
  157. alias snile='screen -t nile ssh nile'
  158. alias sorinoco='screen -t orinoco ssh orinoco'
  159. alias skwai='screen -t kwai ssh kwai'
  160. alias ssamwise='screen -t samwise ssh samwise'
  161. alias sseine='screen -t seine ssh seine'