]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/aliases
c508f6ffb97346c8a3184d6b9138b6354d29f628
[config/dotfiles.git] / shell / aliases
1 # Aliases and similar functions which can be used by all shells (supporting
2 # them).
3
4
5 # Shortcuts for often used programs.
6 alias c=clear
7 alias d=cd
8 alias e=elinks
9 alias g=git
10 alias l=ls
11 alias m=mutt
12 alias p=less # p for pager
13 alias s=mpc  # s for sound, m is already used
14 alias v=vim
15
16
17 # Improved ls which displays the files in columns (-C), visualizes
18 # directories, links and other special files (-F) and pages everything through
19 # less.
20 #
21 # If available use GNU ls with colorized output. If it isn't available try
22 # normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
23 # pager. If none work no colors are used.
24
25 # Check if colors are available.
26 ls --color > /dev/null 2>&1
27 if [ $? -eq 0 ]; then
28     ls_color=gnu
29 else
30     ls -G > /dev/null 2>&1
31     if [ $? -eq 0 ]; then
32         ls_color=cli
33     else
34         ls_color=
35     fi
36 fi
37
38 # Main ls function, separated to prevent code duplication.
39 ls_path=`which ls`
40 my_ls() {
41     "$ls_path" -C -F "$@" 2>&1 | less
42 }
43 # Make sure there is no alias named ls as it causes problems with the
44 # following ls function on (at least) bash 4.0.35.
45 unalias ls 2> /dev/null
46 # GNU ls with colors.
47 if [ x$ls_color = xgnu ]; then
48     ls() {
49         my_ls --color "$@"
50     }
51 # Normal ls with colors.
52 elif [ x$ls_color = xcli ]; then
53     ls() {
54         CLICOLOR_FORCE=1 my_ls -G "$@"
55     }
56 # Simple ls with no colors.
57 else
58     ls() {
59         my_ls "$@"
60     }
61 fi
62 unset ls_color
63 # Helper function to list all files.
64 la() {
65     ls -a "$@"
66 }
67 # Helper function to list the files in list format with access rights, etc.
68 ll() {
69     ls -l "$@"
70 }
71 # Helper function to list all files in list format with access rights, etc.
72 lal() {
73     la -l "$@"
74 }
75
76
77 # Make going up directories simple.
78 alias ..='cd ..'
79 alias ...='cd ../..'
80 alias ....='cd ../../..'
81 alias .....='cd ../../../..'
82
83 # I sometimes confuse editor and shell, print a warning to prevent I exit the
84 # shell.
85 alias :q='echo "This is not Vim!" >&2'
86
87 # Automatically use unified diffs.
88 alias diff='diff -u'
89
90 # Display all files and use human readable sizes.
91 alias du='du -sh'
92 # Use human readable sizes.
93 alias df='df -h'
94
95 # Edit the mercurial patch queue series file for the current mercurial
96 # repository in Vim. Also change Vim's pwd to the patches directory so other
97 # patches can easily be opened.
98 alias vqs='vim -c "cd `hg root`/.hg/patches/" "`hg root`/.hg/patches/series"'
99
100 # vim: ft=sh