about summary refs log tree commit diff stats
path: root/bash/please.bash
blob: 179ed173aff29d333c8d09b4e8317b1f028bf229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# PLEASE
# if run without arguments, run the last command with 'sudo' (aka sudo !!)
# if run WITH arguments, alias as sudo

please() {
	history -d -1
	if [ -z "$1" ]; then
		#set --	$(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
		set -- $(fc -lnr | sed 1q)
	fi
	echo >&2 sudo "$@"
	history -s sudo "$@"
	"${DEBUG:-false}" || sudo "$@"
}