4 # Defines command shortcuts
6 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
7 # Released under the terms of the Artistic Licence 2.0
9 # Source repository: git://git.madduck.net/etc/zsh.git
12 function trace() { eval "set -x; $@" }
14 alias mv='nocorrect mv'
15 alias cp='nocorrect cp'
16 alias ln='nocorrect ln'
17 alias mkdir='nocorrect mkdir'
18 alias rm='nocorrect rm'
20 alias find='noglob find'
21 alias w3m='noglob w3m -no-mouse'
22 alias links='noglob links'
23 alias wb='noglob www-browser'
24 alias wget='noglob wget'
25 alias curl='noglob curl'
26 alias apt-cache='noglob apt-cache'
27 alias locate='noglob locate'
29 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)"
30 alias swget="noglob wget --user-agent='$USER_AGENT'"
32 typeset -a _ls_opts; _ls_opts=(-bC --color=auto)
33 command ls --group-directories-first >/dev/null 2>&1 \
34 && _ls_opts+=--group-directories-first
35 # I prefer POSIX collation for ls
36 alias ls="LC_COLLATE=POSIX ls $_ls_opts"
38 alias l='ls --time-style=+%Y%m%d.%H%M -gG'
46 # List only directories and symbolic links that point to directories
47 alias lsd='ll -d *(-/DN)'
50 #cd () { __CHPWD_RUN_FIRST=lscontext && builtin cd "$@" && unset __CHPWD_RUN_FIRST }
52 #chpwd_functions+=_cd_l
57 alias -g ND='*(/om[1])' # newest directory
58 alias -g NF='*(.om[1])' # newest file
60 alias egrep='egrep --color=auto -d skip'
61 alias fgrep='fgrep --color=auto -d skip'
62 alias grep='grep --color=auto -d skip'
64 alias mmv='noglob zmv -W'
67 alias zgmv='zmv -p git-mv'
72 alias mbug='bts show --mbox'
73 alias bug='BROWSER=www-browser bts show'
76 [[ -z "$1" ]] && { echo "Usage: edalias <alias_to_edit>" ; return 1 } || vared aliases'[$1]' ;
78 compdef _aliases edalias
81 [[ -z "$1" ]] && { echo "Usage: edfunc <function_to_edit>" ; return 1 } || zed -f "$1" ;
83 compdef _functions edfunc
85 doc() { cd /usr/share/doc/$1 }
86 compdef '_files -W /usr/share/doc -/' doc
88 alias giti='git init && git add . && git commit -minitial\ checkin && git tag orig'
90 local branch; branch="$(git symbolic-ref -q HEAD)"; branch="${branch##*/}"
91 git config branch.${branch}.remote ${1:-origin}
92 git config branch.${branch}.merge refs/heads/${branch}
93 git config branch.${branch}.rebase true
96 if whence mtail >/dev/null; then
98 elif whence tailf >/dev/null; then
105 function ltail() { t ~log/$1 }
106 compdef '_files -W ~log' ltail
108 function lless() { sensible-pager ~log/$1 }
109 compdef '_files -W ~log' lless
111 alias tsl='ltail syslog'
112 alias lsl='lless syslog'
113 alias tml='ltail mail.log'
114 alias lml='lless mail.log'
115 alias tal='ltail auth.log'
116 alias lal='lless auth.log'
117 alias tdl='ltail daemon.log'
118 alias ldl='lless daemon.log'
119 alias tkl='ltail kern.log'
120 alias lkl='lless kern.log'
123 local pattern="$1"; shift
124 eval egrep "'$pattern'" "~log/${(j: ~log/:)@}"
128 alias mps='ps -ao user,pcpu,start,command'
130 function of() { lsof -np "$1" }
133 function psgrep() { ps aux | grep "[${1[1]}]${1[2,-1]}" }
135 alias rw-='chmod 600'
136 alias rwx='chmod 700'
137 alias r--='chmod 644'
138 alias r-x='chmod 755'
139 alias r-s='chmod 2755'
140 alias rws='chmod 2775'
142 alias bofh='fortune bofh-excuses'
145 alias b2d='baseconv 2 10'
146 alias d2b='baseconv 10 2'
147 alias d2h='baseconv 10 16'
148 alias h2d='baseconv 16 10'
149 alias d2o='baseconv 10 8'
150 alias d2o='baseconv 10 8'
151 alias h2b='baseconv 16 2'
152 alias b2h='baseconv 2 16'
154 alias sendmail=/usr/sbin/sendmail
157 d() { _d $* | sensible-pager }
158 the() { d -d moby-thesaurus $* }
159 typeset -A _LANGUAGES
166 for l0 in ${(k)_LANGUAGES}; do
167 for l1 in ${(k)_LANGUAGES}; do
168 eval "function _${l0}-${l1}() { _d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
169 eval "function ${l0}-${l1}() { d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
172 unset '_LANGUAGES[en]'
173 for l in ${(k)_LANGUAGES}; do
174 eval "function ${l}() { (_${l}-en \$*; _en-${l} \$*) | more }"
178 alias dpkg-buildpackage="dpkg-buildpackage -k$DEBKEYID -rfakeroot"
180 bugsub() { echo X-debbugs-autosubscribe: don | sendmail -f $DEBEMAIL ${1:?No bug number}-subscribe@bugs.debian.org }
181 bugunsub() { sendmail -f $DEBEMAIL ${1:?No bug number}-unsubscribe@bugs.debian.org </dev/null }
182 ptssub() { echo subscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
183 ptsunsub() { echo unsubscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
184 qasub() { echo subscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
185 qaunsub() { echo unsubscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
186 listsub() { echo Subject: subscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
187 listunsub() { echo Subject: unsubscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
189 uc() { unicode --max=0 --colour=off "$@" | sensible-pager }
195 alias btd='btdownloadheadless'
197 function asc () { autossh -t "$@" 'screen -qxp= || screen -qdRR' }
200 alias mdtest='swaks -s localhost -t'
206 pdftk "$i" cat "${@:-1-end}" output "${o%.pdf}.pdf"
208 compdef _files pdfextract
211 local annex; annex=false
217 if [ -n "$file" ]; then
218 echo >&2 "E: filename already given"
224 if [ -z "$file" ]; then
225 file=$(TMPDIR=${PWD} tempfile -ptest. -s.txt)
228 echo "Test file created $(date)" >| $file
233 git commit -m"Add test file $file to annex"
237 git commit -m"Add test file $file"