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