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

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:

provide a new shortcut to list files in target dir by time
[etc/zsh.git] / .zsh / zshrc / 30_aliases.disabled
1 # zshrc/30_aliases
2 #
3 # Defines command shortcuts
4 #
5 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
7 #
8 # Source repository: http://git.madduck.net/v/etc/zsh.git
9 #
10
11 alias giti='git init && git add . && git commit -minitial\ checkin && git tag orig'
12 gbs() {
13   local branch; branch="$(git symbolic-ref -q HEAD)"; branch="${branch##*/}"
14   git config branch.${branch}.remote ${1:-origin}
15   git config branch.${branch}.merge refs/heads/${branch}
16   git config branch.${branch}.rebase true
17 }
18
19 if whence mtail >/dev/null; then
20   alias t=mtail
21 elif whence tailf >/dev/null; then
22   alias t=tailf
23 else
24   alias t='tail -f'
25 fi
26 compdef _files t
27
28 function ltail() { t ~log/$1 }
29 compdef '_files -W ~log' ltail
30
31 function lless() { sensible-pager ~log/$1 }
32 compdef '_files -W ~log' lless
33
34 alias tsl='ltail syslog'
35 alias lsl='lless syslog'
36 alias tml='ltail mail.log'
37 alias lml='lless mail.log'
38 alias tal='ltail auth.log'
39 alias lal='lless auth.log'
40 alias tdl='ltail daemon.log'
41 alias ldl='lless daemon.log'
42 alias tkl='ltail kern.log'
43 alias lkl='lless kern.log'
44
45 function lgrep() {
46   local pattern="$1"; shift
47   eval egrep "'$pattern'" "~log/${(j: ~log/:)@}"
48 }
49
50 function psgrep() { ps aux | grep "[${1[1]}]${1[2,-1]}" }
51
52 alias sendmail=/usr/sbin/sendmail
53
54 _d() { dict $* }
55 d() { _d $* | sensible-pager }
56 the() { d -d moby-thesaurus $* }
57 typeset -A _LANGUAGES
58 _LANGUAGES[en]=eng
59 _LANGUAGES[de]=deu
60 _LANGUAGES[es]=spa
61 _LANGUAGES[fr]=fra
62 _LANGUAGES[it]=ita
63 _LANGUAGES[tn]=lat
64 for l0 in ${(k)_LANGUAGES}; do
65   for l1 in ${(k)_LANGUAGES}; do
66     eval "function _${l0}-${l1}() { _d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
67     eval "function ${l0}-${l1}() { d -d fd-${_LANGUAGES[$l0]}-${_LANGUAGES[$l1]} \$* }"
68   done
69 done
70 unset '_LANGUAGES[en]'
71 for l in ${(k)_LANGUAGES}; do
72   eval "function ${l}() { (_${l}-en \$*; _en-${l} \$*) | more }"
73 done
74 unset _LANGUAGES
75
76 bugsub() { echo X-debbugs-autosubscribe: madduck | sendmail -f $DEBEMAIL ${1:?No bug number}-subscribe@bugs.debian.org }
77 bugunsub() { sendmail -f $DEBEMAIL ${1:?No bug number}-unsubscribe@bugs.debian.org </dev/null }
78 ptssub() { echo subscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
79 ptsunsub() { echo unsubscribe ${1:?E: no package name given.} | sendmail -f ${2:-$DEBEMAIL} pts@qa.debian.org }
80 qasub() { echo subscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
81 qaunsub() { echo unsubscribe ${1:?E: no package name given.} ${2:-unspecifed} | sendmail -f $DEBEMAIL ddpo@qa.debian.org }
82 listsub() { echo Subject: subscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
83 listunsub() { echo Subject: unsubscribe | sendmail -f ${1%@*}=${1#*@}@mass.madduck.net ${1%@*}-request@${1#*@} }
84
85 uc() { unicode --max=0 --colour=off "$@" | sensible-pager }
86
87 alias ipr='ip r'
88 alias ipa='ip a'
89 alias ipl='ip l'
90
91 alias btd='btdownloadheadless'
92
93 function asc () { autossh -t "$@" 'screen -qxp= || screen -qdRR' }
94 compdef asc=ssh
95
96 alias mdtest='swaks -s localhost -t'
97
98 if whence devtodo >/dev/null; then
99   _devtodo_on_chpwd() {
100     local out; out="$(devtodo)"
101     [[ -n $out ]] && print "todo:\n$out"
102   }
103   [[ -z ${(M)chpwd_functions:#_devtodo_on_chpwd} ]] && chpwd_functions+=_devtodo_on_chpwd
104 fi
105
106 pdfextract() {
107   local i=$1
108   local o=$2
109   shift 2
110   pdftk "$i" cat "${@:-1-end}" output "${o%.pdf}.pdf"
111   if [ -n "$1" ]; then
112     local tmpfile
113     tmpfile=$(tempfile -p pdftk -s .pdf)
114     cleanup() { rm -f $tmpfile; trap - EXIT; }
115     trap cleanup EXIT
116     pdftk "$i" cat "1-end~${(j:~:)@}" output $tmpfile
117     mv $tmpfile "$i"
118     cleanup
119   fi
120 }
121 compdef _files pdfextract
122
123 gittestfile() {
124   local annex; annex=false
125   local file
126
127   case "$1" in
128     (-a) annex=true;;
129     (*)
130       if [ -n "$file" ]; then
131         echo >&2 "E: filename already given"
132         return 1
133       fi
134       file="$1";;
135   esac
136
137   if [ -z "$file" ]; then
138     file=$(TMPDIR=${PWD} tempfile -ptest. -s.txt)
139   fi
140
141   echo "Test file created $(date)" >| $file
142
143   case "$annex" in
144     true)
145       git annex add $file
146       git commit -m"Add test file $file to annex"
147       ;;
148     false)
149       git add $file
150       git commit -m"Add test file $file"
151       ;;
152   esac
153 }
154
155 # vim:ft=zsh