80_aliases 13.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#/bin/zsh
# Tous les aliases

# {{{ some aliases
if check_com -c screen ; then
    if [[ -r $HOME/.screenrc ]] ; then
        alias screen="${commands[screen]} -c $HOME/.screenrc"
    fi
fi

# do we have GNU ls with color-support?
if ls --help 2>/dev/null | grep -- --color= >/dev/null && [[ "$TERM" != dumb ]] ; then
    #a1# execute \kbd{@a@}:\quad ls with colors
    alias ls='ls -b -CF --color=auto'
    #a1# execute \kbd{@a@}:\quad list all files, with colors
    alias la='ls -lA --color=auto'
    #a1# long colored list, without dotfiles (@a@)
    alias ll='ls -l --color=auto'
    #a1# long colored list, human readable sizes (@a@)
    alias lh='ls -hAl --color=auto'
    #a1# List files, append qualifier to filenames \\&\quad(\kbd{/} for directories, \kbd{@} for symlinks ...)
    alias l='ls -lF --color=auto'
else
    alias ls='ls -b -CF'
    alias la='ls -lA'
    alias ll='ls -l'
    alias lh='ls -hAl'
    alias l='ls -lF'
fi

alias mdstat='cat /proc/mdstat'
alias ...='cd ../../'

# generate alias named "$KERNELVERSION-reboot" so you can use boot with kexec:
if [[ -x /sbin/kexec ]] && [[ -r /proc/cmdline ]] ; then
    alias "$(uname -r)-reboot"="kexec -l --initrd=/boot/initrd.img-"$(uname -r)" --command-line=\"$(cat /proc/cmdline)\" /boot/vmlinuz-"$(uname -r)""
fi

alias sudo='nocorrect sudo'        # no spelling correction on sudo
alias cp='nocorrect cp -i'         # no spelling correction on cp
alias mkdir='nocorrect mkdir'      # no spelling correction on mkdir
alias mv='nocorrect mv -i'         # no spelling correction on mv
alias rm='nocorrect rm -i'         # no spelling correction on rm

Maxime Bombar's avatar
Aliases    
Maxime Bombar committed
45
46
47
48

alias superplan='javaws /home/pollion/BDE/Reservations/SuperPlan.jnlp'


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#a1# Execute \kbd{rmdir}
alias rd='rmdir'
#a1# Execute \kbd{mkdir}
alias md='mkdir'

# see http://www.cl.cam.ac.uk/~mgk25/unicode.html#term for details
alias term2iso="echo 'Setting terminal to iso mode' ; print -n '\e%@'"
alias term2utf="echo 'Setting terminal to utf-8 mode'; print -n '\e%G'"

# get top 10 shell commands:
alias top10='print -l ? ${(o)history%% *} | uniq -c | sort -nr | head -n 10'

if [[ -r /etc/debian_version ]] ; then
    #a3# Execute \kbd{apt-cache search}
    alias acs='apt-cache search'
    #a3# Execute \kbd{apt-cache show}
    alias acsh='apt-cache show'
    #a3# Execute \kbd{apt-cache policy}
    alias acp='apt-cache policy'
    #a3# Execute \kbd{apt-get dist-upgrade}
    salias adg="apt-get dist-upgrade"
    #a3# Execute \kbd{apt-get install}
    salias agi="apt-get install"
    #a3# Execute \kbd{aptitude install}
    salias ati="aptitude install"
    #a3# Execute \kbd{apt-get upgrade}
    salias ag="apt-get upgrade"
    #a3# Execute \kbd{apt-get update}
    salias au="apt-get update"
    #a3# Execute \kbd{aptitude update ; aptitude safe-upgrade}
    salias -a up="aptitude update ; aptitude safe-upgrade"
    #a3# Execute \kbd{dpkg-buildpackage}
    alias dbp='dpkg-buildpackage'
    #a3# Execute \kbd{grep-excuses}
    alias ge='grep-excuses'

    #a1# Take a look at the syslog: \kbd{\$PAGER /var/log/syslog}
    salias llog="$PAGER /var/log/syslog"     # take a look at the syslog
    #a1# Take a look at the syslog: \kbd{tail -f /var/log/syslog}
    salias tlog="tail -f /var/log/syslog"    # follow the syslog
fi

# sort installed Debian-packages by size
if check_com -c grep-status ; then
    #a3# List installed Debian-packages sorted by size
    alias debs-by-size='grep-status -FStatus -sInstalled-Size,Package -n "install ok installed" | paste -sd "  \n" | sort -rn'
fi

# use colors when GNU grep with color-support
#a2# Execute \kbd{grep -{}-color=auto}
(grep --help 2>/dev/null |grep -- --color) >/dev/null && alias grep='grep --color=auto'
#a2# Execute \kbd{grep -i -{}-color=auto}
alias GREP='grep -i --color=auto'

# highlight important stuff in diff output, usage example: hg diff | hidiff
#m# a2 hidiff \kbd{histring} oneliner for diffs
check_com -c histring && \
    alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"

# Xterm resizing-fu.
# Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
alias tiny='echo -en "\033]50;xft:DejaVu Sans Mono-4\007"'
alias small='echo -en "\033]50;xft:DejaVu Sans Mono-5\007"'
alias medium='echo -en "\033]50;xft:DejaVu Sans Mono-6\007"'
alias default='echo -e "\033]50;xft:DejaVu Sans Mono-8\007"'
alias large='echo -en "\033]50;xft:DejaVu Sans Mono-12\007"'
alias huge='echo -en "\033]50;xft:DejaVu Sans Mono-16\007"'

# general
#a2# Execute \kbd{du -sch}
alias da='du -sch'
#a2# Execute \kbd{jobs -l}
alias j='jobs -l'

# compile stuff
#a2# Execute \kbd{./configure}
alias CO="./configure"
#a2# Execute \kbd{./configure --help}
alias CH="./configure --help"

# listing stuff
#a2# Execute \kbd{ls -lSrah}
alias dir="ls -lSrah"
#a2# Only show dot-directories
alias lad='ls -d .*(/)'                # only show dot-directories
#a2# Only show dot-files
alias lsa='ls -a .*(.)'                # only show dot-files
#a2# Only files with setgid/setuid/sticky flag
alias lss='ls -l *(s,S,t)'             # only files with setgid/setuid/sticky flag
#a2# Only show 1st ten symlinks
alias lsl='ls -l *(@)'                 # only symlinks
#a2# Display only executables
alias lsx='ls -l *(*)'                 # only executables
#a2# Display world-{readable,writable,executable} files
alias lsw='ls -ld *(R,W,X.^ND/)'       # world-{readable,writable,executable} files
#a2# Display the ten biggest files
alias lsbig="ls -flh *(.OL[1,10])"     # display the biggest files
#a2# Only show directories
alias lsd='ls -d *(/)'                 # only show directories
#a2# Only show empty directories
alias lse='ls -d *(/^F)'               # only show empty directories
#a2# Display the ten newest files
alias lsnew="ls -rl *(D.om[1,10])"     # display the newest files
#a2# Display the ten oldest files
alias lsold="ls -rtlh *(D.om[1,10])"   # display the oldest files
#a2# Display the ten smallest files
alias lssmall="ls -Srl *(.oL[1,10])"   # display the smallest files

# chmod
#a2# Execute \kbd{chmod 600}
alias rw-='chmod 600'
#a2# Execute \kbd{chmod 700}
alias rwx='chmod 700'
#m# a2 r-{}- Execute \kbd{chmod 644}
alias r--='chmod 644'
#a2# Execute \kbd{chmod 755}
alias r-x='chmod 755'

# some useful aliases
Maxime Bombar's avatar
Maxime Bombar committed
168
#a2# Execute \kbd{mkdir -p}
169
170
171
172
173
174
175
176
177
178
179
180
181
182
alias md='mkdir -p'

# console stuff
#a2# Execute \kbd{mplayer -vo fbdev}
alias cmplayer='mplayer -vo fbdev'
#a2# Execute \kbd{mplayer -vo fbdev -fs -zoom}
alias fbmplayer='mplayer -vo fbdev -fs -zoom'
#a2# Execute \kbd{links2 -driver fb}
alias fblinks='links2 -driver fb'

#a2# ssh with StrictHostKeyChecking=no \\&\quad and UserKnownHostsFile unset
alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'

Maxime Bombar's avatar
Maxime Bombar committed
183
#alias emacs='emacsclient --alternate-editor="" -nw'
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

# simple webserver
check_com -c python && alias http="python -m SimpleHTTPServer"

# Use 'g' instead of 'git':
check_com g || alias g='git'

# work around non utf8 capable software in utf environment via $LANG and luit
if check_com isutfenv && check_com luit ; then
    if check_com -c mrxvt ; then
        isutfenv && [[ -n "$LANG" ]] && \
            alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} luit mrxvt"
    fi

    if check_com -c aterm ; then
        isutfenv && [[ -n "$LANG" ]] && \
            alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} luit aterm"
    fi

    if check_com -c centericq ; then
        isutfenv && [[ -n "$LANG" ]] && \
            alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} luit centericq"
    fi
fi

check_com -c qma && alias ?='qma zshall'

Maxime Bombar's avatar
Maxime Bombar committed
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240

# +----------------+
# | Aliases commun |
# +----------------+

# Demander confirmation avant écrasement ou suppression des fichiers/dossiers
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

# Afficher la taille des partitions en human-readable
alias df='df -h'

# Affichage des couleurs automatiques
if [ -x /usr/bin/dircolors ]; then
    alias grep='grep --color=auto'
    alias egrep='egrep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias ls='ls --color=auto'
fi

# Alias ls
alias ll='ls -alFh'
alias la='ls -A'
alias l='ls -CF'

# parce que LS/sl c'est cool, mais qu'on veut pouvoir l'interrompre
alias sl='sl -e'
alias LS='LS -e'

Maxime Bombar's avatar
Maxime Bombar committed
241
242
243
# Pour pouvoir piper dans le clipboard
alias xclip='xclip -selection c'

Maxime Bombar's avatar
Kikoo    
Maxime Bombar committed
244
245
# Owii des couleurs
alias ip='ip -c'
Maxime Bombar's avatar
Maxime Bombar committed
246
247
248
249
250
251
252

# +------------+
# | My aliases |
# +------------+

alias sshfsinfo='sshfs bombar@ssh.dptinfo.ens-cachan.fr:/users/dptinfo/bombar ~/Home_411'
alias rm='rm -i'
253
alias open='xdg-open'
Maxime Bombar's avatar
Maxime Bombar committed
254
alias irc='ssh -D 1080 bombar@zamok.crans.org -t "~/screen.sh"'
Maxime Bombar's avatar
Maxime Bombar committed
255
256
257
258
alias zamok='ssh zamok'
alias google='chromium'
alias opentex='texmaker'
alias sl='sl-h'
259
alias tunnel='ssh -D 1080 note-galois'
Maxime Bombar's avatar
Maxime Bombar committed
260
261
262
263
264
alias thot='ssh bombar@thot.crans.org'
alias note='ssh note'
alias note-test='ssh note-test'
alias sauron='ssh sauron'
alias clean='rm -f *.{aux,log,out,bbl,blg,rip,nav,snm,toc,vrb} *~ \#*'
Maxime Bombar's avatar
Maxime Bombar committed
265
alias gpgsendkeys='gpg --list-keys|grep pub -A 1 | grep -v ''-'' | grep -v pubring | awk '"'"'{print $1}'"'"' | sort | uniq | xargs -t -I {} gpg --keyserver keyserver.ubuntu.com --send-keys {}'
Maxime Bombar's avatar
Maxime Bombar committed
266
alias gpgupdatekeys='gpg --list-keys|grep pub -A 1 | grep -v ''-'' | grep -v pubring | awk '"'"'{print $1}'"'"' | sort | uniq | xargs -t -I {} curl "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{}" | gpg --import'
267
alias mklatex='cp ~/Git/Latex/Main/* ./'
Maxime Bombar's avatar
Maxime Bombar committed
268

Maxime Bombar's avatar
Maxime Bombar committed
269
270
271
272
273
274
# +----------+
# | Sur note |
# +----------+

alias dumpmanuel='pg_dump note > ~/dump_manuel/dump_manuel_`date +%Y-%m-%d_%T`.sql'

Maxime Bombar's avatar
Maxime Bombar committed
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# +-----+
# | ssh |
# +-----+

# Pour que ssh-add ne mémorise la passphrase que pendant 30 minutes
alias sshadd='ssh-add -t 1800'

#~# # Tunnels (pour les membres actifs)
alias sshimprimante="echo -e 'Port : 2222\nRappel : https://localhost:2222';ssh -L 2222:imprimante.adm.crans.org:443 vo"
alias sshcups="echo -e 'Port : 3333\nRappel : http://localhost:3333';ssh -L 3333:o2.adm.crans.org:631 vo"
alias sshbabar="echo -e 'Port : 3333\nRappel : http://localhost:3333/backuppc';ssh -L 3333:babar.adm.crans.org:80 vo"



# +------------------+
# | Fixing mistyping |
# +------------------+
#~# # Souvenir de Windows
alias cd..='cd ..'

alias screen-r='screen -r'



#~# # +----------------------+
#~# # | AltGr+Space is wrong |
#~# # +----------------------+
#~#
#~# # Workaround crade :
#~# # Permet d'aliaser les commandes dans lesquelles on pipe usuellement
#~# # pour qu'elle marche aussi quand elles sont précédées d'une espace insécable.
#~#

for commande in grep egrep fgrep wc tail head less sed awk xargs sort uniq sponge
do
  alias  $commande=$commande
done
unset commande

# +--------------------------------------+
# | Gestion de variables d'environnement |
# +--------------------------------------+

#~# # Pour loader en mémoire la variable qui empêche less de breaker les lignes
#~# # très utile pour les sorties psql
alias exportless="export LESS='-S'"


# +-------+
# | softs |
# +-------+
# Des raccourcis pour appeler des logiciels avec des options supplémentaires

#~# # Pour que youtube-dl récupère seulement l'audio, et en MP3 s'il vous plait
alias youtube-dl='youtube-dl --extract-audio -t --audio-format=mp3'

#~# # Pour avoir les diff sous format git-like
alias diff='diff -u'
alias colordiff='colordiff -u'

#~# # Pour que mtr n'utilise pas l'interface graphique
alias mtr='mtr -t'

#~# # Pour que les semaines de cal commencent le Lundi
Maxime Bombar's avatar
Aliases    
Maxime Bombar committed
339
alias cal='ncal -bM'
Maxime Bombar's avatar
Maxime Bombar committed
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

#~# # Hack pour déclencher les hooks sur un dépôt bare git
#~# # (genre git-update-server-info et/ou trigger KGB)
#~# # en faisant un truc bidon et transparent pour l'historique
#~# # (à savoir créer une branche et la supprimer)
alias shakegit='git checkout -b shakegitbranch && git push origin shakegitbranch && git checkout master && git branch -d shakegitbranch && git push origin :shakegitbranch'

# +--------+
# | Divers |
# +--------+

#~# # Pour se débarasser rapidement des fichier garbage
#~# # C'est typiquement là où il faut rajouter vos extensions persos !
alias rmtilde='rm -f *~ .*~'
alias rm~=rmtilde
alias rmpyc='rm -f *.pyc'
alias rmccompiled='rm -f *.o *.h'
alias rmso='rm -f *.so'
alias rmclass='rm -f *.class'

#~# # Pour récupérer les droits d'un fichier en octal
alias getmod='/usr/bin/stat -c "%a"'

# Pour trouver les pages des pdfs du dossier courrant
alias pdfpages="find . -name '*.pdf' -exec pdfinfo {} \; | egrep '^Pages'"
# et pour les sommer
alias pdfpagessum='pdfpages | awk "{print \$2}" | paste -sd+ | bc'

# Add an "alert" alias for long running commands.  Use like so:
#   long_command; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Pour afficher les derniers mails reçus
# (adapter le path de votre procmail.log si besoin)
alias tailprocmail='tail -f ~/.procmail/logs/procmail.log'


Maxime Bombar's avatar
Maxime Bombar committed
377
378
379
# Pour activer flash dans chromium
chromiumflash='chromium --ppapi-flash-path=/usr/local/lib/libpepflashplayer.so --ppapi-flash-version=32.0.0.344'

Maxime Bombar's avatar
Maxime Bombar committed
380
381
382
383
384
385
386
387
388
389

# +------------+
# | Cool stuff |
# +------------+

#~# # A♡ !!!
#~# alias a♡tv='cvlc udp://@239.231.140.230:1337'

#Meteo
meteo () { curl wttr.in/`tr -s ' ' '_' <<< "$*"`; }
390
391
392
393
394
395
396

###
### Because cat is old school, use bat !! https://github.com/sharkdp/bat
###

which bat > /dev/null
bat=$?; if [[ $bat = 0 ]]; then alias cat=bat; fi
Maxime Bombar's avatar
Maxime Bombar committed
397

398
alias sshmalow='ssh pollion@hilbert.satellist.fr -t ssh -p 4242 maxime@localhost'
Maxime Bombar's avatar
Maxime Bombar committed
399
400
401
402
403

#### https://github.com/jamesofarrell/i3-swallow

alias evince='swallow evince'
alias zotero='swallow zotero'
Maxime Bombar's avatar
Maxime Bombar committed
404
405
406
407


alias pass="PASSWORD_STORE_ENABLE_EXTENSIONS=true PASSWORD_STORE_DIR=~/.pass/perso /usr/bin/pass"
alias passcrans="PASSWORD_STORE_ENABLE_EXTENSIONS=true PASSWORD_STORE_DIR=~/.pass/crans /usr/bin/pass"