]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/aliases.in
shell/aliases: Run `unalias` for mv and cp.
[config/dotfiles.git] / shell / aliases.in
1 # Aliases and similar functions which can be used by all shells (supporting
2 # them).
3
4 # Copyright (C) 2011-2013  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 l=ls
26 alias m=mutt
27 alias p=less # p for pager
28 alias s=mpc  # s for sound, m is already used
29 alias v=vim
30
31
32 unalias mv cp 2> /dev/null
33 # Ask for confirmation before overwriting files. Especially useful when moving
34 # to a different directory. No alias for `rm` because I specify the files to
35 # remove directly, so I know what will happen.
36 alias mv='mv -i'
37 # Additionally preserve all file attributes when copying, this includes
38 # copying symbolic links as is without dereferencing them.
39 alias cp='cp -i -a'
40
41
42 # Make sure there is no alias named ls as it causes problems with the
43 # following ls function on (at least) bash 4.0.35.
44 unalias ls 2> /dev/null
45 # Improved ls which displays the files in columns (-C), visualizes
46 # directories, links and other special files (-F) and pages everything through
47 # less.
48 #
49 # If available use GNU ls with colorized output. If it isn't available try
50 # normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
51 # pager. If none work no colors are used.
52 #
53 # See `setup.sh` for details. LS_ENV, LS_PATH, LS_COLOR are replaced with the
54 # correct values when this file is generated.
55 ls() {
56     LS_ENV LS_PATH LS_COLOR -C -F "$@" 2>&1 | less
57 }
58
59 unalias ll la lal 2> /dev/null
60 # List the files in list format with access rights, etc.
61 alias ll='ls -l'
62 # List all files.
63 alias la='ls -a'
64 # List all files in list format with access rights, etc.
65 alias lal='ls -al'
66
67
68 # Make going up directories simple.
69 alias ..='cd ..'
70 alias ...='cd ../..'
71 alias ....='cd ../../..'
72 alias .....='cd ../../../..'
73
74 # I sometimes confuse editor and shell, print a warning to prevent I exit the
75 # shell.
76 alias :q='echo "This is not Vim!" >&2'
77
78 # Automatically use unified diffs.
79 alias diff='diff -u'
80
81 # COLUMN is set to `| column -t` if it's available, empty otherwise.
82
83 # Display all files (-s), use human readable sizes (-h) and display the
84 # complete size (-c).
85 alias du='du -shc'
86 # Use human readable sizes and format it nicely, thanks to climagic
87 # (http://twitter.com/climagic/status/49623386762129408).
88 alias df='df -hP COLUMN'
89
90 # Highlight matched strings. Doesn't work with a pager!
91 alias grep='grep --color=auto'
92
93 # vim: ft=sh