about summary refs log tree commit diff stats
path: root/bash/functions.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/functions.bash')
-rw-r--r--bash/functions.bash15
1 files changed, 15 insertions, 0 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}