aboutsummaryrefslogtreecommitdiffstats
path: root/bash/aliases
blob: d978492ea9d9078512024d8ad26992e54ee13181 (plain) (blame)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- shell-script -*-

# DESCRIPTION:  Create directories and parents, if missing, and move into the first one
# USAGE:        mkcd <directory> [<additional directories to create>]
mkcd () {
	mkdir -p -- "$@"
	cd -- "$1"
}

# DESCRIPTION:  Start bash in a temporary directory and destroy it after exiting the new bash instance
# USAGE:        tmpsh
tmpsh () (
	local tmpdir
	tmpdir="${XDG_RUNTIME_DIR}"
	if test -z "$tmpdir"; then
	tmpdir=/tmp
	fi
	tmpdir="$tmpdir/tmpsh-$$.d"
	mkdir -p -- "$tmpdir"
	cd -- "$tmpdir"
	bash
	cd /
	rm -rf -- "$tmpdir"
	test ! -e "$tmpdir"
)

#DESCRIPTION:  Reload the shell configurations
#USAGE:        resh
resh () {
	. ~/.bashrc
}

#DESCRIPTION:  Edit the shell configurations
#USAGE:        edsh
edsh () {
	if [ -z "$EDITOR" ]; then
		echo 'No default editor is set, please configure the environment variable EDITOR'
	else
		$EDITOR ~/.bashrc
	fi
}

# DESCRIPTION:  Run a command in a infinite loop with a sleep between executions
# USAGE:        forever "<arguments for sleep>" <command>
forever () {
	time="$1"
	shift 1
	while true; do
		"$@"
		sleep $time
	done
}

# DESCRIPTION:  Recursive touch all files in the current working directory
# USAGE:        touch-all <extra arguments for find>
touch-all () {
	find -print0 "$@" | xargs -0 touch
}

#DESCRIPTION:  ls with long listing, classification with appendix character, hidden files and the . and .. directories
alias ll='ls -alF'

#DESCRIPTION:  ls with hidden files
alias la='ls -A'

#DESCRIPTION:  ls with classification with appendix character
alias l='ls -CF'

#DESCRIPTION:  Go to the parent directory
alias ..="cd .."



#libnotify
# DESCRIPTION:  Add an "alert" alias for long running commands.  Use like so:  sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history | tail -n1 | sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'



for __script in ~/.config/bash/aliases.d/*; do
	if test -r "${__script}"; then
		. "${__script}"
	fi
done
unset __script

if test -r ~/.config/bash/"aliases-$(hostname)"; then
	. ~/.config/bash/"aliases-$(hostname)"
fi

if test -r ~/work/.config/bash/aliases; then
	. ~/work/.config/bash/aliases
fi