From 8b352cf25190e877a00343153fd74a3c59d93066 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:31:16 +0000 Subject: Move please to functions.bash --- bash/functions.bash | 15 +++++++++++++++ bash/please.bash | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 bash/please.bash diff --git a/bash/functions.bash b/bash/functions.bash index 058e0f9..5e99a82 100644 --- a/bash/functions.bash +++ b/bash/functions.bash @@ -1,3 +1,5 @@ +# Functions + memq() { # memq ITEM ARRAY # Test whether an ITEM is a member of ARRAY. # Pass ARRAY as ${ARRAY[@]}. @@ -9,3 +11,16 @@ memq() { # memq ITEM ARRAY done return 1 } + +please() { # please [COMMAND...] + # if run without arguments, run the last command with 'sudo' (aka sudo !!) + # if run WITH arguments, alias as sudo + 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 "$@" +} diff --git a/bash/please.bash b/bash/please.bash deleted file mode 100644 index 179ed17..0000000 --- a/bash/please.bash +++ /dev/null @@ -1,14 +0,0 @@ -# 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