]> git.donarmstrong.com Git - zsh.git/blob - .zsh/zshrc/30_aliases
fd8dd2429cefc41d261fd055dfc8da16f0de7be7
[zsh.git] / .zsh / zshrc / 30_aliases
1 # zshrc/30_aliases
2 #
3 # Defines command shortcuts
4 #
5 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
7 #
8 # Source repository: git://git.madduck.net/etc/zsh.git
9 #
10
11 function trace() { eval "set -x; $@" }
12
13 alias mv='nocorrect mv'
14 alias cp='nocorrect cp'
15 alias ln='nocorrect ln'
16 alias mkdir='nocorrect mkdir'
17 alias rm='nocorrect rm'
18
19 alias find='noglob find'
20 alias w3m='noglob w3m -no-mouse'
21 alias links='noglob links'
22 alias wb='noglob www-browser'
23 alias wget='noglob wget'
24 alias curl='noglob curl'
25 alias apt-cache='noglob apt-cache'
26 alias locate='noglob locate'
27
28 local _USER_AGENT="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080404 Iceweasel/2.0.0.14 (Debian-2.0.0.14-2)"
29 alias swget="noglob wget --user-agent='$USER_AGENT'"
30
31 typeset -a _ls_opts; _ls_opts=(-bC --color=auto)
32 command ls --group-directories-first >/dev/null 2>&1 \
33   && _ls_opts+=--group-directories-first
34 # I prefer POSIX collation for ls
35 alias ls="LC_COLLATE=POSIX ls $_ls_opts"
36
37 alias l='ls --time-style=+%Y%m%d.%H%M -gG'
38 alias ll='ls -l'
39 alias la='ls -a'
40 alias lla='ls -la'
41 alias lt='ls -lt'
42 alias lrt='ls -lrt'
43 alias lat='ls -lat'
44 alias lart='ls -lart'
45 # List only directories and symbolic links that point to directories
46 alias lsd='ll -d *(-/DN)'
47
48 alias lscontext=ls
49 cd () { __CHPWD_RUN_FIRST=lscontext && builtin cd "$@" && unset __CHPWD_RUN_FIRST }
50 #_cd_l() { ll }
51 #chpwd_functions+=_cd_l
52
53 # #183394
54 alias w='w|cat'
55
56 alias egrep='egrep --color=auto -d skip'
57 alias fgrep='fgrep --color=auto -d skip'
58 alias grep='grep --color=auto -d skip'
59
60 alias mmv='noglob zmv -W'
61 alias zcp='zmv -C'
62 alias zln='zmv -L'
63 alias zgmv='zmv -p git-mv'
64
65 alias cal='cal -3'
66 alias ftp=lftp
67
68 alias mbug='bts show --mbox'
69 alias bug='BROWSER=www-browser bts show'
70
71 # handy documentation lookup on Debian
72 # from http://www.michael-prokop.at/computer/config/.zshrc
73 doc() { cd /usr/share/doc/$1 }
74 compdef '_files -W /usr/share/doc -/' doc
75
76 alias giti='git init && git add . && git commit -minitial\ checkin && git tag orig'
77 gbs() {
78   local branch; branch="$(git symbolic-ref -q HEAD)"; branch="${branch##*/}"
79   git config branch.${branch}.remote ${1:-origin}
80   git config branch.${branch}.merge refs/heads/${branch}
81   git config branch.${branch}.rebase true
82 }
83
84 if whence mtail >/dev/null; then
85   alias t=mtail
86 elif whence tailf >/dev/null; then
87   alias t=tailf
88 else
89   alias t='tail -f'
90 fi
91 compdef _files t
92
93 function ltail() { t ~log/$1 }
94 compdef '_files -W ~log' ltail
95
96 function lless() { sensible-pager ~log/$1 }
97 compdef '_files -W ~log' lless
98
99 alias tsl='ltail syslog'
100 alias lsl='lless syslog'
101 alias tml='ltail mail.log'
102 alias lml='lless mail.log'
103 alias tal='ltail auth.log'
104 alias lal='lless auth.log'
105 alias tdl='ltail daemon.log'
106 alias ldl='lless daemon.log'
107 alias tkl='ltail kern.log'
108 alias lkl='lless kern.log'
109
110 function lgrep() {
111   local pattern="$1"; shift
112   eval egrep "'$pattern'" "~log/${(j: ~log/:)@}"
113 }
114
115 alias px='ps afux'
116 alias mps='ps -ao user,pcpu,start,command'
117
118 function of() { lsof -np "$1" }
119 compdef _pids of
120
121 function psgrep() { ps aux | grep "[${1[1]}]${1[2,-1]}" }
122
123 alias bofh='fortune bofh-excuses'
124
125 autoload -U baseconv
126 alias b2d='baseconv 2 10'
127 alias d2b='baseconv 10 2'
128 alias d2h='baseconv 10 16'
129 alias h2d='baseconv 16 10'
130 alias d2o='baseconv 10 8'
131 alias d2o='baseconv 10 8'
132 alias h2b='baseconv 16 2'
133 alias b2h='baseconv 2 16'
134
135 alias sendmail=/usr/sbin/sendmail
136
137 _d() { dict $* }
138 d() { _d $* | sensible-pager }
139 the() { d -d moby-thesaurus $* }
140 typeset -A _LANGUAGES
141 _LANGUAGES[en]=eng
142 _LANGUAGES[de]=deu
143 _LANGUAGES[es]=spa
144 _LANGUAGES[fr]=fra
145 _LANGUAGES[it]=ita
146 _LANGUAGES[tn]=lat
147 for l0 in ${(k)_LANGUAGES}; do
148   for l1 in ${(k)_LANGUAGES}; do
149     eval "function _${l0}-${l1}() { _d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
150     eval "function ${l0}-${l1}() { d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
151   done
152 done
153 unset '_LANGUAGES[en]'
154 for l in ${(k)_LANGUAGES}; do
155   eval "function ${l}() { (_${l}-en \$*; _en-${l} \$*) | more }"
156 done
157 unset _LANGUAGES
158
159 alias dpkg-buildpackage="dpkg-buildpackage -k$DEBKEYID -rfakeroot"
160
161 bugsub() { echo X-debbugs-autosubscribe: madduck | sendmail -f $DEBEMAIL ${1:?No bug number}-subscribe@bugs.debian.org }
162 bugunsub() { sendmail -f $DEBEMAIL ${1:?No bug number}-unsubscribe@bugs.debian.org </dev/null }
163 ptssub() { echo subscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
164 ptsunsub() { echo unsubscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
165 qasub() { echo subscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
166 qaunsub() { echo unsubscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
167
168 uc() { unicode --max=0 --colour=off "$@" | sensible-pager }
169
170 alias ipr='ip r'
171 alias ipa='ip a'
172 alias ipl='ip l'
173
174 alias btd='btdownloadheadless'
175
176 alias mdtest='swaks -s localhost -t'
177
178 if whence devtodo >/dev/null; then
179   _devtodo_on_chpwd() {
180     local out; out="$(devtodo)"
181     [[ -n $out ]] && print "todo:\n$out"
182   }
183   [[ -z ${(M)chpwd_functions:#_devtodo_on_chpwd} ]] && chpwd_functions+=_devtodo_on_chpwd
184 fi
185
186 # vim:ft=zsh