about summary refs log tree commit diff stats
path: root/bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash')
-rw-r--r--bash/functions.bash15
-rw-r--r--bash/please.bash14
2 files changed, 15 insertions, 14 deletions
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 @@
1# Functions
2
1memq() { # memq ITEM ARRAY 3memq() { # memq ITEM ARRAY
2 # Test whether an ITEM is a member of ARRAY. 4 # Test whether an ITEM is a member of ARRAY.
3 # Pass ARRAY as ${ARRAY[@]}. 5 # Pass ARRAY as ${ARRAY[@]}.
@@ -9,3 +11,16 @@ memq() { # memq ITEM ARRAY
9 done 11 done
10 return 1 12 return 1
11} 13}
14
15please() { # please [COMMAND...]
16 # if run without arguments, run the last command with 'sudo' (aka sudo !!)
17 # if run WITH arguments, alias as sudo
18 history -d -1
19 if [ -z "$1" ]; then
20 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
21 set -- $(fc -lnr | sed 1q)
22 fi
23 echo >&2 sudo "$@"
24 history -s sudo "$@"
25 "${DEBUG:-false}" || sudo "$@"
26}
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 @@
1# PLEASE
2# if run without arguments, run the last command with 'sudo' (aka sudo !!)
3# if run WITH arguments, alias as sudo
4
5please() {
6 history -d -1
7 if [ -z "$1" ]; then
8 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
9 set -- $(fc -lnr | sed 1q)
10 fi
11 echo >&2 sudo "$@"
12 history -s sudo "$@"
13 "${DEBUG:-false}" || sudo "$@"
14}