]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/shell/aliases.in
herbstluftwm/autostart: add bindings to run programs and select windows
[config/dotfiles.git] / shell / shell / aliases.in
1 # Aliases and similar functions which can be used by all shells (supporting
2 # them).
3
4 # Copyright (C) 2011-2015  Simon Ruderich
5 #
6 # This file is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This file is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this file.  If not, see <http://www.gnu.org/licenses/>.
18
19
20 # Shortcuts for often used programs.
21 alias c=clear
22 alias d=cd
23 alias e=elinks
24 alias g=git
25 alias h=htop
26 alias l=ls
27 alias m=make
28 alias p=less # p for pager
29 alias s=ssh
30 alias t=tig
31 alias v=vim
32 alias x=exit
33 # Shortcuts for a little less used programs.
34 alias ga='git annex'
35 alias gr=grep
36 alias gri='grep -i'
37 alias grr='grep -r'
38 alias grri='grep -ri'
39 alias mc='make clean'
40 alias mj='make -j$(nproc)'
41 alias mu=mutt
42 alias rs=reset # like git's reset alias
43 alias sa=ssh-add
44 alias ta=task
45 alias te=tree
46 alias ti=timew
47
48 # systemd ... (sc is provided as shell script for better completion); redirect
49 # stderr because my color-stderr hack breaks systemd's terminal detection.
50 jc() {
51     journalctl "$@" 2>&1
52 }
53 lc() {
54     loginctl "$@" 2>&1
55 }
56
57
58 unalias mv cp 2>/dev/null
59 # Ask for confirmation before overwriting files. Especially useful when moving
60 # to a different directory. No alias for `rm` because I specify the files to
61 # remove directly, so I know what will happen.
62 alias mv='mv -i'
63 # Additionally preserve all file attributes when copying, this includes
64 # copying symbolic links as is without dereferencing them.
65 alias cp='cp -i -a'
66
67
68 # Make sure there is no alias named ls as it causes problems with the
69 # following ls function on (at least) bash 4.0.35.
70 unalias ls 2>/dev/null
71 # Improved ls which displays the files in columns (-C), visualizes
72 # directories, links and other special files (-F), uses human file sizes (-h)
73 # and pages everything through less.
74 #
75 # If available use GNU ls with colorized output. If it isn't available try
76 # normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
77 # pager. If none work no colors are used.
78 #
79 # See `setup.sh` for details. LS_* are replaced with the appropriate values
80 # when this file is generated.
81 ls() {
82     LS_ARGS -C -F -h "$@" 2>&1 | less -S
83 }
84
85 unalias ll lt la lal lat 2>/dev/null
86 # List the files in list format with access rights, etc.
87 alias ll='ls -l'
88 # List the files sorted by last modification date.
89 alias lt='ls -l -t'
90 # List all files.
91 alias la='ls -a'
92 # List all files in list format with access rights, etc.
93 alias lal='ls -al'
94 # List all files sorted by last modification date.
95 alias lat='ls -al -t'
96
97
98 # Make going up directories simple.
99 alias ..='cd ..'
100 alias ...='cd ../..'
101 alias ....='cd ../../..'
102 alias .....='cd ../../../..'
103
104 # Automatically use unified diffs.
105 alias diff='diff -u'
106
107 # COLUMN is set to `| column -t` if it's available, empty otherwise.
108
109 # Display all files (-s), use human readable sizes (-h) and display the
110 # complete size (-c).
111 alias du='du -shc'
112 # Use human readable sizes and format it nicely, thanks to climagic
113 # (http://twitter.com/climagic/status/49623386762129408).
114 df() {
115     command df -hP "$@" COLUMN
116 }
117
118 # Highlight matched strings. Doesn't work with a pager!
119 alias grep='grep --color=auto'
120
121 # Pipe output through less.
122 tree() {
123     command tree -C "$@" | less -S
124 }
125
126 # Better viewer for info pages .. just pipe everything into less.
127 info() {
128     command info "$@" 2>/dev/null | less
129 }
130
131 # Using su (or sudo) as root to a less privileged user might allow the other
132 # user to run arbitrary commands as root. See also Debian bugs #628843 and
133 # #657784.
134 if test "`id -u`" -eq 0; then
135     su() {
136         echo 'never su as root' >&2
137         return 1
138     }
139 fi
140
141 # Use short `ip` output per default.
142 alias ip='ip -br'
143
144 # vim: ft=sh