]> 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:

89d2ca864e52e248dfb85bc7998ef08a6bcffb37
[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 -g L='|less'
60
61 alias egrep='egrep --color=auto -d skip'
62 alias fgrep='fgrep --color=auto -d skip'
63 alias grep='grep --color=auto -d skip'
64
65 alias mmv='noglob zmv -W'
66 alias zcp='zmv -C'
67 alias zln='zmv -L'
68 alias zgmv='zmv -p git-mv'
69
70 alias cal='cal -3'
71 alias ftp=lftp
72
73 alias mbug='bts show --mbox'
74 alias bug='BROWSER=www-browser bts show'
75
76 # handy documentation lookup on Debian
77 # from http://www.michael-prokop.at/computer/config/.zshrc
78 doc() { cd /usr/share/doc/$1 }
79 compdef '_files -W /usr/share/doc -/' doc
80
81 alias giti='git init && git add . && git commit -minitial\ checkin && git tag orig'
82 gbs() {
83   local branch; branch="$(git symbolic-ref -q HEAD)"; branch="${branch##*/}"
84   git config branch.${branch}.remote ${1:-origin}
85   git config branch.${branch}.merge refs/heads/${branch}
86   git config branch.${branch}.rebase true
87 }
88
89 if whence mtail >/dev/null; then
90   alias t=mtail
91 elif whence tailf >/dev/null; then
92   alias t=tailf
93 else
94   alias t='tail -f'
95 fi
96 compdef _files t
97
98 function ltail() { t ~log/$1 }
99 compdef '_files -W ~log' ltail
100
101 function lless() { sensible-pager ~log/$1 }
102 compdef '_files -W ~log' lless
103
104 alias tsl='ltail syslog'
105 alias lsl='lless syslog'
106 alias tml='ltail mail.log'
107 alias lml='lless mail.log'
108 alias tal='ltail auth.log'
109 alias lal='lless auth.log'
110 alias tdl='ltail daemon.log'
111 alias ldl='lless daemon.log'
112 alias tkl='ltail kern.log'
113 alias lkl='lless kern.log'
114
115 function lgrep() {
116   local pattern="$1"; shift
117   eval egrep "'$pattern'" "~log/${(j: ~log/:)@}"
118 }
119
120 alias px='ps afux'
121 alias mps='ps -ao user,pcpu,start,command'
122
123 function of() { lsof -np "$1" }
124 compdef _pids of
125
126 function psgrep() { ps aux | grep "[${1[1]}]${1[2,-1]}" }
127
128 alias bofh='fortune bofh-excuses'
129
130 autoload -U baseconv
131 alias b2d='baseconv 2 10'
132 alias d2b='baseconv 10 2'
133 alias d2h='baseconv 10 16'
134 alias h2d='baseconv 16 10'
135 alias d2o='baseconv 10 8'
136 alias d2o='baseconv 10 8'
137 alias h2b='baseconv 16 2'
138 alias b2h='baseconv 2 16'
139
140 alias sendmail=/usr/sbin/sendmail
141
142 _d() { dict $* }
143 d() { _d $* | sensible-pager }
144 the() { d -d moby-thesaurus $* }
145 typeset -A _LANGUAGES
146 _LANGUAGES[en]=eng
147 _LANGUAGES[de]=deu
148 _LANGUAGES[es]=spa
149 _LANGUAGES[fr]=fra
150 _LANGUAGES[it]=ita
151 _LANGUAGES[tn]=lat
152 for l0 in ${(k)_LANGUAGES}; do
153   for l1 in ${(k)_LANGUAGES}; do
154     eval "function _${l0}-${l1}() { _d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
155     eval "function ${l0}-${l1}() { d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
156   done
157 done
158 unset '_LANGUAGES[en]'
159 for l in ${(k)_LANGUAGES}; do
160   eval "function ${l}() { (_${l}-en \$*; _en-${l} \$*) | more }"
161 done
162 unset _LANGUAGES
163
164 alias dpkg-buildpackage="dpkg-buildpackage -k$DEBKEYID -rfakeroot"
165
166 bugsub() { echo X-debbugs-autosubscribe: madduck | sendmail -f $DEBEMAIL ${1:?No bug number}-subscribe@bugs.debian.org }
167 bugunsub() { sendmail -f $DEBEMAIL ${1:?No bug number}-unsubscribe@bugs.debian.org </dev/null }
168 ptssub() { echo subscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
169 ptsunsub() { echo unsubscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
170 qasub() { echo subscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
171 qaunsub() { echo unsubscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
172
173 uc() { unicode --max=0 --colour=off "$@" | sensible-pager }
174
175 alias ipr='ip r'
176 alias ipa='ip a'
177 alias ipl='ip l'
178
179 alias btd='btdownloadheadless'
180
181 alias mdtest='swaks -s localhost -t'
182
183 if whence devtodo >/dev/null; then
184   _devtodo_on_chpwd() {
185     local out; out="$(devtodo)"
186     [[ -n $out ]] && print "todo:\n$out"
187   }
188   [[ -z ${(M)chpwd_functions:#_devtodo_on_chpwd} ]] && chpwd_functions+=_devtodo_on_chpwd
189 fi
190
191 # vim:ft=zsh