From e292eb508413b9174684a8e75c93474a7f5351ee Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 23 Aug 2021 23:07:31 -0500 Subject: Initial --- bash/please.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 bash/please.bash (limited to 'bash/please.bash') diff --git a/bash/please.bash b/bash/please.bash new file mode 100644 index 0000000..179ed17 --- /dev/null +++ b/bash/please.bash @@ -0,0 +1,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 "$@" +} -- cgit 1.4.1-21-gabe81