]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/shell/aliases.in
shell: aliases: add alias ti (timew) and ta (task)
[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 ti=timew
32 alias ta=task
33 alias v=vim
34 alias x=exit
35 # Shortcuts for a little less used programs.
36 alias ga='git annex'
37 alias gr=grep
38 alias gri='grep -i'
39 alias grr='grep -r'
40 alias grri='grep -ri'
41 alias mc='make clean'
42 alias mj='make -j$(nproc)'
43 alias mu=mutt
44 alias rs=reset # like git's reset alias
45 alias sa=ssh-add
46 alias te=tree
47 # systemd ... (sc is provided as shell script for better completion)
48 alias jc=journalctl
49 alias lc=loginctl
50 alias mc=machinectl
51
52
53 unalias mv cp 2>/dev/null
54 # Ask for confirmation before overwriting files. Especially useful when moving
55 # to a different directory. No alias for `rm` because I specify the files to
56 # remove directly, so I know what will happen.
57 alias mv='mv -i'
58 # Additionally preserve all file attributes when copying, this includes
59 # copying symbolic links as is without dereferencing them.
60 alias cp='cp -i -a'
61
62
63 # Make sure there is no alias named ls as it causes problems with the
64 # following ls function on (at least) bash 4.0.35.
65 unalias ls 2>/dev/null
66 # Improved ls which displays the files in columns (-C), visualizes
67 # directories, links and other special files (-F), uses human file sizes (-h)
68 # and pages everything through less.
69 #
70 # If available use GNU ls with colorized output. If it isn't available try
71 # normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
72 # pager. If none work no colors are used.
73 #
74 # See `setup.sh` for details. LS_* are replaced with the appropriate values
75 # when this file is generated.
76 ls() {
77     LS_ARGS -C -F -h "$@" 2>&1 | less
78 }
79
80 unalias ll lt la lal lat 2>/dev/null
81 # List the files in list format with access rights, etc.
82 alias ll='ls -l'
83 # List the files sorted by last modification date.
84 alias lt='ls -l -t'
85 # List all files.
86 alias la='ls -a'
87 # List all files in list format with access rights, etc.
88 alias lal='ls -al'
89 # List all files sorted by last modification date.
90 alias lat='ls -al -t'
91
92
93 # Make going up directories simple.
94 alias ..='cd ..'
95 alias ...='cd ../..'
96 alias ....='cd ../../..'
97 alias .....='cd ../../../..'
98
99 # Automatically use unified diffs.
100 alias diff='diff -u'
101
102 # COLUMN is set to `| column -t` if it's available, empty otherwise.
103
104 # Display all files (-s), use human readable sizes (-h) and display the
105 # complete size (-c).
106 alias du='du -shc'
107 # Use human readable sizes and format it nicely, thanks to climagic
108 # (http://twitter.com/climagic/status/49623386762129408).
109 df() {
110     command df -hP "$@" COLUMN
111 }
112
113 # Highlight matched strings. Doesn't work with a pager!
114 alias grep='grep --color=auto'
115
116 # Pipe output through less.
117 tree() {
118     command tree -C "$@" | less
119 }
120
121 # Better viewer for info pages .. just pipe everything into less.
122 info() {
123     command info "$@" 2>/dev/null | less
124 }
125
126 # Using su (or sudo) as root to a less privileged user might allow the other
127 # user to run arbitrary commands as root. See also Debian bugs #628843 and
128 # #657784.
129 if test "`id -u`" -eq 0; then
130     su() {
131         echo 'never su as root' >&2
132         return 1
133     }
134 fi
135
136 # Use short `ip` output per default.
137 alias ip='ip -br'
138
139 # vim: ft=sh