]> git.madduck.net Git - etc/zsh.git/blob - .zsh/zshrc/30_aliases

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

d8066816c1ccd77f87e57839695df7b0fc0f440e
[etc/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 -g ND='*(/om[1])' # newest directory
57 alias -g NF='*(.om[1])' # newest file
58
59 alias egrep='egrep --color=auto -d skip -D skip'
60 alias fgrep='fgrep --color=auto -d skip -D skip'
61 alias grep='grep --color=auto -d skip -D skip'
62
63 alias mmv='noglob zmv -W'
64 alias zcp='zmv -C'
65 alias zln='zmv -L'
66 alias zgmv='zmv -p git-mv'
67
68 alias cal='cal -3'
69 alias ftp=lftp
70
71 alias mbug='bts show --mbox'
72 alias bug='BROWSER=www-browser bts show'
73
74 edalias() {
75   [[ -z "$1" ]] && { echo "Usage: edalias <alias_to_edit>" ; return 1 } || vared aliases'[$1]' ;
76 }
77 compdef _aliases edalias
78
79 edfunc() {
80   [[ -z "$1" ]] && { echo "Usage: edfunc <function_to_edit>" ; return 1 } || zed -f "$1" ;
81 }
82 compdef _functions edfunc
83
84 doc() { cd /usr/share/doc/$1 }
85 compdef '_files -W /usr/share/doc -/' doc
86
87 alias giti='git init && git add . && git commit -minitial\ checkin && git tag orig'
88 gbs() {
89   local branch; branch="$(git symbolic-ref -q HEAD)"; branch="${branch##*/}"
90   git config branch.${branch}.remote ${1:-origin}
91   git config branch.${branch}.merge refs/heads/${branch}
92   git config branch.${branch}.rebase true
93 }
94
95 if whence mtail >/dev/null; then
96   alias t=mtail
97 elif whence tailf >/dev/null; then
98   alias t=tailf
99 else
100   alias t='tail -f'
101 fi
102 compdef _files t
103
104 function ltail() { t ~log/$1 }
105 compdef '_files -W ~log' ltail
106
107 function lless() { sensible-pager ~log/$1 }
108 compdef '_files -W ~log' lless
109
110 alias tsl='ltail syslog'
111 alias lsl='lless syslog'
112 alias tml='ltail mail.log'
113 alias lml='lless mail.log'
114 alias tal='ltail auth.log'
115 alias lal='lless auth.log'
116 alias tdl='ltail daemon.log'
117 alias ldl='lless daemon.log'
118 alias tkl='ltail kern.log'
119 alias lkl='lless kern.log'
120
121 function lgrep() {
122   local pattern="$1"; shift
123   eval egrep "'$pattern'" "~log/${(j: ~log/:)@}"
124 }
125
126 alias px='ps afux'
127 alias mps='ps -ao user,pcpu,start,command'
128
129 function of() { lsof -np "$1" }
130 compdef _pids of
131
132 function psgrep() { ps aux | grep "[${1[1]}]${1[2,-1]}" }
133
134 alias rw-='chmod 600'
135 alias rwx='chmod 700'
136 alias r--='chmod 644'
137 alias r-x='chmod 755'
138 alias r-s='chmod 2755'
139 alias rws='chmod 2775'
140
141 alias bofh='fortune bofh-excuses'
142
143 autoload -U baseconv
144 alias b2d='baseconv 2 10'
145 alias d2b='baseconv 10 2'
146 alias d2h='baseconv 10 16'
147 alias h2d='baseconv 16 10'
148 alias d2o='baseconv 10 8'
149 alias d2o='baseconv 10 8'
150 alias h2b='baseconv 16 2'
151 alias b2h='baseconv 2 16'
152
153 alias sendmail=/usr/sbin/sendmail
154
155 _d() { dict $* }
156 d() { _d $* | sensible-pager }
157 the() { d -d moby-thesaurus $* }
158 typeset -A _LANGUAGES
159 _LANGUAGES[en]=eng
160 _LANGUAGES[de]=deu
161 _LANGUAGES[es]=spa
162 _LANGUAGES[fr]=fra
163 _LANGUAGES[it]=ita
164 _LANGUAGES[tn]=lat
165 for l0 in ${(k)_LANGUAGES}; do
166   for l1 in ${(k)_LANGUAGES}; do
167     eval "function _${l0}-${l1}() { _d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
168     eval "function ${l0}-${l1}() { d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
169   done
170 done
171 unset '_LANGUAGES[en]'
172 for l in ${(k)_LANGUAGES}; do
173   eval "function ${l}() { (_${l}-en \$*; _en-${l} \$*) | more }"
174 done
175 unset _LANGUAGES
176
177 alias dpkg-buildpackage="dpkg-buildpackage -k$DEBKEYID -rfakeroot"
178
179 bugsub() { echo X-debbugs-autosubscribe: madduck | sendmail -f $DEBEMAIL ${1:?No bug number}-subscribe@bugs.debian.org }
180 bugunsub() { sendmail -f $DEBEMAIL ${1:?No bug number}-unsubscribe@bugs.debian.org </dev/null }
181 ptssub() { echo subscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
182 ptsunsub() { echo unsubscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
183 qasub() { echo subscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
184 qaunsub() { echo unsubscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
185 listsub() { echo Subject: subscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
186 listunsub() { echo Subject: unsubscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
187
188 uc() { unicode --max=0 --colour=off "$@" | sensible-pager }
189
190 alias ipr='ip r'
191 alias ipa='ip a'
192 alias ipl='ip l'
193
194 alias btd='btdownloadheadless'
195
196 function asc () { autossh -t "$@" 'screen -qxp= || screen -qdRR' }
197 compdef asc=ssh
198
199 alias mdtest='swaks -s localhost -t'
200
201 if whence devtodo >/dev/null; then
202   _devtodo_on_chpwd() {
203     local out; out="$(devtodo)"
204     [[ -n $out ]] && print "todo:\n$out"
205   }
206   [[ -z ${(M)chpwd_functions:#_devtodo_on_chpwd} ]] && chpwd_functions+=_devtodo_on_chpwd
207 fi
208
209 pdfextract() {
210   local i=$1
211   local o=$2
212   shift 2
213   pdftk "$i" cat "${@:-1-end}" output "${o%.pdf}.pdf"
214   if [ -n "$1" ]; then
215     local tmpfile
216     tmpfile=$(tempfile -p pdftk -s .pdf)
217     cleanup() { rm -f $tmpfile; trap - EXIT; }
218     trap cleanup EXIT
219     pdftk "$i" cat "1-end~${(j:~:)@}" output $tmpfile
220     mv $tmpfile "$i"
221     cleanup
222   fi
223 }
224 compdef _files pdfextract
225
226 gittestfile() {
227   local annex; annex=false
228   local file
229
230   case "$1" in
231     (-a) annex=true;;
232     (*)
233       if [ -n "$file" ]; then
234         echo >&2 "E: filename already given"
235         return 1
236       fi
237       file="$1";;
238   esac
239
240   if [ -z "$file" ]; then
241     file=$(TMPDIR=${PWD} tempfile -ptest. -s.txt)
242   fi
243
244   echo "Test file created $(date)" >| $file
245
246   case "$annex" in
247     true)
248       git annex add $file
249       git commit -m"Add test file $file to annex"
250       ;;
251     false)
252       git add $file
253       git commit -m"Add test file $file"
254       ;;
255   esac
256 }
257
258 # vim:ft=zsh