summaryrefslogtreecommitdiff
path: root/.config/bash/aliases.sh
blob: 28b9923f7cd4faddf2d844ce750f2ff90cc8fe9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# The above line probably should never be *used* in this file, but it
# lets text editors know that this is BASH syntax.

######################################################################
# Set up colors and settings for ls/dir/vdir                         #
######################################################################
if [ -x "`which dircolors`" ]; then
	eval "$(dircolors -p | cat - "${XDG_CONFIG_HOME}/dir_colors" |
		dircolors -b -)"
	alias ls='ls -1v --color=auto'
	alias dir='dir -v --color=auto'
	alias vdir='vdir -v --color=auto'

	for xgrep in ${PATH//:/\/*grep }/*grep; do
		if [ -f "$xgrep" ]; then
			xgrep=`basename "$xgrep"`
			if [ "$xgrep" != pgrep ]; then
				alias $xgrep="$xgrep --color=auto"
			fi
		fi
	done
else
	alias ls='ls -1v'
	alias dir='dir -v'
	alias vdir='vdir -v'
fi

######################################################################
# Set up the standard aliases for ls                                 #
######################################################################
alias ll='ls -l'
alias la='ls -a'
alias l='ls -CF'

######################################################################
# Some preferences for miscellaneous stuff                           #
######################################################################
#alias rm='gvfs-trash'
#alias sed='sed --follow-symlinks' # breaks sed 4.2.2
alias tree='tree --charset utf8'
alias cd=pushd
alias gitk='gitk --all --date-order'
alias userctl='systemctl --user'

######################################################################
# Some almost-function aliases                                       #
######################################################################
alias lock="clear; away -C 'This terminal is locked'"
alias plock="term-title Terminal Locked;lock"
mvln() { mv $1 $2; ln -s $2 $1; }
jarls() { jar tf "$1" | sed -n 's/\.class$//p' | LC_ALL=C sort | xargs -r -d $'\n' javap -classpath "$1"; }
tarls() { local file; for file in "$@"; do bsdtar tf "$file" | sed "s|^|$file:|"; done; }
jarmain() { jarls "$1" 2>/dev/null | grep -E '(^[a-z]|public static void main\(java\.lang\.String\[\]\))' | grep -B1 '^ '; }