-
Notifications
You must be signed in to change notification settings - Fork 109
/
shared.lib
70 lines (54 loc) · 1.38 KB
/
shared.lib
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
# vi: ft=bash
# since this is sourced from ANYWHERE, we need to know the root to be able to
# source other files
error(){
if ! command -v dark_red; then
printf "ERROR: %s\n" "$@" >> /dev/stderr
else
printf "ERROR: %s\n" "$(dark_red "$@")" >> /dev/stderr
fi
exit 1
}
if [[ "$ROOT" == "" ]]; then
error "Missing ROOT environment variable (in ${BASH_SOURCE[0]}). Should point to git repo root"
return 1
fi
BASH_D="$ROOT/common-setup/bash.d"
BIN_DIR="$ROOT/utils/scripts"
source "$BASH_D/colors"
source "$BASH_D/aliases_functions"
shopt -s expand_aliases
# header1
h1() {
printf "%s\n" "$(green "$@")"
}
h2(){
printf "%s\n" "$(blue "$@")"
}
h3(){
printf "%s %s\n" "-->" "$(blue "$@")"
}
info(){
printf "%s\n" "$(pink "$@")"
}
warn(){
printf "%s\n" "$(dark_yellow "$@")" >> /dev/stderr
}
banner(){
printf "\n################################################################################\n"
printf "## %s\n" "$(dark_red "$@")"
printf "################################################################################\n"
}
fail(){
banner "$@"
exit 1
}
add_1password_identity_agent_ssh_config(){
if ! grep IdentityAgent.*1password/agent.sock ~/.ssh/config > /dev/null; then
h2 "Configuring 1Password as SSH Agent"
cat >> ~/.ssh/config << EOF
Host *
IdentityAgent ~/.1password/agent.sock
EOF
fi
}