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