-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions
82 lines (69 loc) · 1.58 KB
/
functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/echo Do not execute/subshell me. Source me instead.
__IS_YES='y|Y'
SCRIPT_DIR=${SCRIPT_DIR:-$(dirname $0)}
. $SCRIPT_DIR/os-cli/functions
. $SCRIPT_DIR/os-cli/os_dock
. $SCRIPT_DIR/docker.bash.functions
. $SCRIPT_DIR/git.bash.functions
. $SCRIPT_DIR/gpg.functions
. $SCRIPT_DIR/kube.functions
. $SCRIPT_DIR/aws.functions
. $SCRIPT_DIR/compdef/_aws
function add-secret() {
read -rs TMP
export $1=$TMP
unset TMP
}
function jq-reformat() {
cp $1{,.bak}
echo Backed up to $1.bak
cat $1 | jq . > $1
}
function ssh-clear() {
sed -i '' "/$1/d" $HOME/.ssh/known_hosts
}
function ssh-id() {
ssh-add $HOME/.ssh/${1:?specify a key}
}
function ssh-passwd {
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no
}
OUTPUT="echo -e"
if which cowsay 2>/dev/null >/dev/null ; then
function random-cowsay {
cowsay --random $@
}
# why not map command not found to cowsay?
function command_not_found_handler() {
random-cowsay $@
}
fi
function __find_output {
if which cowsay 2>/dev/null >/dev/null ; then
OUTPUT="random-cowsay"
elif which toilet &2>/dev/null >/dev/null ; then
OUTPUT="toilet"
fi
}
function confirm
{
if [ $# -gt 2 ] ; then
$OUTPUT "Too many arguments for 'confirm()'" >&2
exit 1
fi
local default=${2:-N}
$OUTPUT "${1}? [${default}]" >&2
read answer
if [[ "${answer:-$default}" =~ $__IS_YES ]] ; then
$OUTPUT "Okay..." >&2
__find_output
return 0
else
$OUTPUT Cancelling >&2
__find_output
return 1
fi
}
function aws-vault-exec(){
aws-vault exec $1 -- ${@:2}
}