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