]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/aliases.in
8f05c85fe105812a4621aba85341c360286505bb
[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-2014  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 t=tig
30 alias v=vim
31 # Shortcuts for a little less used programs.
32 alias mu=mutt
33
34
35 unalias mv cp 2>/dev/null
36 # Ask for confirmation before overwriting files. Especially useful when moving
37 # to a different directory. No alias for `rm` because I specify the files to
38 # remove directly, so I know what will happen.
39 alias mv='mv -i'
40 # Additionally preserve all file attributes when copying, this includes
41 # copying symbolic links as is without dereferencing them.
42 alias cp='cp -i -a'
43
44
45 # Make sure there is no alias named ls as it causes problems with the
46 # following ls function on (at least) bash 4.0.35.
47 unalias ls 2>/dev/null
48 # Improved ls which displays the files in columns (-C), visualizes
49 # directories, links and other special files (-F) and pages everything through
50 # less.
51 #
52 # If available use GNU ls with colorized output. If it isn't available try
53 # normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
54 # pager. If none work no colors are used.
55 #
56 # See `setup.sh` for details. LS_* are replaced with the appropriate values
57 # when this file is generated.
58 ls() {
59     LS_ENV command ls LS_COLOR LS_OPTIONS -C -F "$@" 2>&1 | less
60 }
61
62 unalias ll lt la lal lat 2>/dev/null
63 # List the files in list format with access rights, etc.
64 alias ll='ls -l'
65 # List the files sorted by last modification date.
66 alias lt='ls -l -t'
67 # List all files.
68 alias la='ls -a'
69 # List all files in list format with access rights, etc.
70 alias lal='ls -al'
71 # List all files sorted by last modification date.
72 alias lat='ls -al -t'
73
74
75 # Make going up directories simple.
76 alias ..='cd ..'
77 alias ...='cd ../..'
78 alias ....='cd ../../..'
79 alias .....='cd ../../../..'
80
81 # Automatically use unified diffs.
82 alias diff='diff -u'
83
84 # COLUMN is set to `| column -t` if it's available, empty otherwise.
85
86 # Display all files (-s), use human readable sizes (-h) and display the
87 # complete size (-c).
88 alias du='du -shc'
89 # Use human readable sizes and format it nicely, thanks to climagic
90 # (http://twitter.com/climagic/status/49623386762129408).
91 df() {
92     command df -hP "$@" COLUMN
93 }
94
95 # Highlight matched strings. Doesn't work with a pager!
96 alias grep='grep --color=auto'
97
98 # Pipe output through less.
99 tree() {
100     command tree -C "$@" | less
101 }
102
103 # Better viewer for info pages .. just pipe everything into less.
104 info() {
105     command info "$@" 2>/dev/null | less
106 }
107
108 # vim: ft=sh