view .zshrc @ 375:26aed4e65671
cleanup hgrc a bit
| author |
Alexander Solovyov <alexander@solovyov.net> |
| date |
Mon Jan 23 18:20:04 2012 +0200 |
| parents |
3db73011e173 |
| children |
4f3ecd037f2f |
line source
3 # (c) 2003-2011 Alexander Solovyov
4 # piranha AT piranha.org.ua
11 export LANG=en_US.UTF-8
15 [[ $TERM = "xterm" ]] && stty pass8
24 export PATH=~/bin:~/.cabal/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
27 if [ -x "`whence -c vim`" ]; then
32 export BROWSER="links"
34 export PS_FORMAT="user,group,pid,rss,sz,stime,time,cmd"
35 export PIP_RESPECT_VIRTUALENV=true
36 export WORKON_HOME=~/.virtualenvs
38 # local settings can override some settings
39 if [ -f ~/.zshlocal ]; then
43 # Prompt setup (c) smax 2002, adapted for zsh (c) piranha 2004
44 # 0-black, 1-red, 2-green, 3-yellow, 4-blue, 5-magenta 6-cyan, 7-white
45 Cr() { echo '%{\033[3'$1'm%}'; }
46 hc=`Cr 6`; wc=`Cr 3`; tc=`Cr 7`; w=`Cr 7`; n=`Cr 9`; r=`Cr 1`; y=`Cr 6`; gr=`Cr 2`
47 [ $UID = 0 ] && at=$r%B'#'%b || at='@'
48 #PS1="$wc%n$at$hc%m $err$wc%~$w>$n"
49 # for white background
51 PS1="$wc%n$n$at$wc%m $err$wc%~>$n "
52 unset n b Cr uc hc wc tc tty at r y gr
54 fpath=(~/.zsh.d $fpath)
56 # automatically remove duplicates from these arrays
57 typeset -U path cdpath fpath manpath
64 setopt extended_history
65 setopt hist_ignore_all_dups
66 setopt hist_ignore_space
67 setopt hist_reduce_blanks
70 setopt pushd_ignore_dups
72 # other important options
73 unsetopt extended_glob # it's quite annoying
74 setopt notify # report the status of backgrounds jobs immediately
84 zmodload -a zsh/zpty zpty
88 bindkey "[2~" transpose-words
89 bindkey "[3~" delete-char
90 bindkey "[1~" beginning-of-line
91 bindkey "[4~" end-of-line
92 bindkey "[A" up-line-or-history
93 bindkey "[B" down-line-or-history
94 bindkey '^[[5D' emacs-backward-word
95 bindkey '^[[5C' emacs-forward-word
97 bindkey "\e[8~" end-of-line
98 bindkey "\e[7~" beginning-of-line
100 # press meta-e for editing command line in $EDITOR or $VISUAL
101 autoload -U edit-command-line
102 zle -N edit-command-line
103 bindkey '\ee' edit-command-line
105 autoload -U select-word-style
106 select-word-style normal
107 # don't contains -_/= - and thus breaks words on them
108 zstyle ':zle:*' word-chars '*?.[]~&;!#$%^(){}<>'
110 ######## Completion #######
111 #hostsmy=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
112 hosts=(${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*})
113 #???#zstyle ':completion:*:processes' command 'ps -au$USER'
114 zstyle ':completion:*' use-cache on
115 zstyle ':completion:*' cache-path ~/.zcompcache
116 zstyle ':completion:*' completer _expand _complete _correct _approximate
117 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z} r:|[._-]=* r:|=*' 'm:{a-zA-Z}={A-Za-z} r:|[._-]=* r:|=*' 'm:{a-zA-Z}={A-Za-z} r:|[._-]=* r:|=*' 'm:{a-zA-Z}={A-Za-z} r:|[._-]=* r:|=*'
118 zstyle ':completion:*:match:*' original only
119 zstyle ':completion:*' max-errors 1 numeric
121 # Completing process IDs with menu selection
122 zstyle ':completion:*:*:kill:*' menu yes select
123 zstyle ':completion:*:kill:*' force-list always
125 # cd will never select the parent directory (e.g.: cd ../<TAB>)
126 zstyle ':completion:*:cd:*' ignore-parents parent pwd
128 zstyle :compinstall filename '.zshrc'
130 compctl -o wget make man rpm iptables
131 compctl -k $hosts ssh telnet ping mtr traceroute
132 compctl -j -P "%" kill
133 compctl -g '*.gz' + -g '*(-/)' gunzip gzcat
134 compctl -g '*.rar' + -g '*(-/)' rar unrar
135 compctl -g '*.bz2' + -g '*(-/)' bunzip2 bzcat
136 compctl -g '*(-*)' + -g '*(-/)' strip
137 compctl -g '*.ps *.eps' + -g '*(-/)' gs ghostview psnup psduplex ps2ascii
138 compctl -g '*.dvi *.pdf *.ps *.ps.gz' + -g '*(-/)' evince epdfview
139 compctl -g '*.xpm *.xpm.gz' + -g '*(-/)' xpmroot sxpm pixmap xpmtoppm
140 compctl -g '*.fig' + -g '*(-/)' xfig
141 compctl -g '*(-/) .*(-/)' cd
142 compctl -g '(^(*.o|*.class|*.jar|*.gz|*.gif|*.a|*.Z|*.bz2))' + -g '.*' less vim
143 compctl -g '(^(*.o|*.class|*.jar|*.gif|*.a))' + -g '.*' most
144 compctl -g '*.ltx' + -g '*(-/)' pdflatex
145 compctl -g '*.wav' auCDtect
146 compctl -g '*.fb2 *.fb2.zip' FBReader
149 if [ $UID -eq 0 ]; then
150 compinit -i -d ~/.zrootcompdump
159 print -Pn "\033]0;%n@%M - %/\a"
160 print -Pn "\033]1;%n@%m \a"
163 print -Pn "\033]0;%n@%M - %/ - ($1)\a"
164 print -Pn "\033]1;%n@%m \a"
170 echo -ne "\ek${1[(w)1]}\e\\"
174 echo -ne "\ekzsh\e\\"
180 # Search file, containing string in name
181 function ff() { ls -lhd **/*$** ; }
183 # rename file to lowercase
192 echo "First argument - pattern to grep from processes"
195 for i in `ps aux|grep -i $1|awk '{print $6}'`; do
202 function split2flac {
204 echo "Usage: split2flac cue-file sound-file"
206 cuebreakpoints $1 | shnsplit -o flac $2
207 cuetag $1 split-track*.flac
212 if [ -z `ps -C emacs -o pid=` ]; then
215 emacsclient -t -c ${@}
220 awk '{print $2}'|xargs kill ${@}
223 ############# ALIASES ###############
225 #alias mv="nocorrect mv"
226 #alias cp="nocorrect cp"
227 alias mkdir="nocorrect mkdir"
230 if [ -x "`whence -c lftp`" ]; then
232 function sftp() { lftp sftp://`whoami`@$1 }
236 if [ `uname` != "Linux" -a -x "`whence -c gfind`" ]; then
237 alias find="noglob gfind"
239 alias find="noglob find"
243 if [ -x "`whence -c emacsclient`" ]; then
247 xargs emacsclient --no-wait $LINE
249 emacsclient --no-wait $1
252 alias et="emacsclient -t"
253 export ALTERNATE_EDITOR="vim"
258 if [ -x "`whence -c rlwrap`" ]; then
263 if [ $(uname) = "Linux" ]; then
264 alias ls="/bin/ls --color"
265 elif [ -x "$(whence -c gls)" ]; then
266 alias ls="gls --color"
268 alias ls="/bin/ls -G"
272 alias lsd="ls -ld *(-/DN)"
273 alias lsa="ls -ld .*"
275 # ZSH Directory Bookmarks
276 alias m1='alias g1="cd \"`pwd`\""'
277 alias m2='alias g2="cd \"`pwd`\""'
278 alias m3='alias g3="cd \"`pwd`\""'
279 alias m4='alias g4="cd \"`pwd`\""'
280 alias m5='alias g5="cd \"`pwd`\""'
281 alias m6='alias g6="cd \"`pwd`\""'
282 alias m7='alias g7="cd \"`pwd`\""'
283 alias m8='alias g8="cd \"`pwd`\""'
284 alias m9='alias g9="cd \"`pwd`\""'
285 alias mdump='alias | awk "/^g[0-9]/ { print \"alias \" \$0 }" > ~/.bookmarks'
286 alias ml='alias | grep "^g[0-9]"'
291 while [ -z $EPATH ]; do
292 EPATH=$(emacsclient -e "(with-current-buffer (window-buffer (frame-selected-window)) default-directory)")
294 cd $(echo $EPATH | sed -E 's/(^\")|(\"$)//g')
298 if [ $# -gt 0 -a -d $1 ]; then
309 alias sd="screen -D -r"
311 alias g="egrep -i --color"
317 alias myapg="apg -a 1 -n 8 -x 9 -M NCL -E l1iI0Oo"
318 alias rezsh="source ~/.zshrc"
319 alias apt="noglob sudo apt-get"
321 alias s="mdfind -name"
322 alias ri="ri -f ansi"
324 alias clive="noglob clive"
325 function preview { man -t $1 | open -f -a Preview }
326 alias depyc='noglob find . -name *.pyc -delete'
327 alias ve='virtualenv --distribute --no-site-packages'
328 alias wget='wget --no-check-certificate'
329 alias ho="sudo vim /etc/hosts"
331 alias sudo="sudo " # this carries aliases to sudo calls
333 function mq() { hg --cwd $(hg root)/.hg/patches/ $@ }
334 function qser() { vim $(hg root)/.hg/patches/series }
335 function hgrc() { vim $(hg root)/.hg/hgrc }
336 function bdiff() { hg diff -r "ancestor('$1', master)" -r "$1" $2 $3 $4 }
339 alias psfg="ps -ylfC"
340 function psk() { ps -C $1 -o pid= | xargs kill }
343 if [ $# -lt 2 ]; then
352 echo "Usage: rtun PORT [DESTPORT]"
353 echo "Setup tunnel from remote host to local; show off local work"
356 echo "sapientisat.org:$DPORT"
357 ssh -q -f -N -R 0.0.0.0:$DPORT:localhost:$1 sapientisat.org > /dev/null 2&>1
362 [[ $TERM = "dumb" ]] && unsetopt zle && PS1='$ ' && unalias ls || return 0