-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc++
73 lines (63 loc) · 2.15 KB
/
.bashrc++
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
__cmd() {
CMD="${*}"
echo "$ ${CMD}"
eval "${CMD}"
}
nuke-environment() {
echo -e "\e[41m\e[1;37mResetting your environment in 5 seconds. C-c to cancel\e[0m\n"
echo -e "Your files and changes to the cluster will persist.\nTo have a completely fresh environment, create a new Pair instance."
sleep 5s
__cmd kubectl -n "${SHARINGIO_PAIR_USER,,}" rollout restart "statefulset/environment"
echo "Please note: you will disconnect momentarily and will need to reconnect manually."
}
alias nuke-humacs='nuke-environment'
for NUM in $(seq 0 20); do
alias "w${NUM}"="tmate select-window -t ${NUM}"
done
alias sharingio-pair-load-init-env='. <(sudo cat {/var/run/host,}/root/.sharing-io-pair-init.env 2> /dev/null)'
sharingio-pair-add-guest() {
GUEST_NAME="${1}"
if [ -z "${GUEST_NAME}" ]; then
echo "Error: please provide guest name as first arg" > /dev/sderr
fi
FOUND=false
if ! grep -q "ssh-import-id gh:${GUEST_NAME}" < ~/.ssh/authorized_keys; then
ssh-import-id gh:"${GUEST_NAME}" > /dev/null 2>&1
else
echo "Guest already added, found authorized keys"
FOUND=true
fi
if ! grep -q "${GUEST_NAME}@users." < $HOME/.git-commit-template; then
echo "Co-Authored-By: $GUEST_NAME <$GUEST_NAME@users.noreply.github.com>" >> $HOME/.git-commit-template
else
echo "Guest already added, found co-author in git-commit-template"
FOUND=true
fi
if [ "${FOUND}" = true ]; then
return
fi
echo "Added guest '${GUEST_NAME}'"
}
sharingio-pair-remove-guest() {
GUEST_NAME="${1}"
if [ -z "${GUEST_NAME}" ]; then
echo "Error: please provide guest name as first arg" > /dev/sderr
fi
FOUND=false
if grep -q "ssh-import-id gh:${GUEST_NAME}" < ~/.ssh/authorized_keys; then
sed -i -e "/ssh-import-id gh:${GUEST_NAME}/d" ~/.ssh/authorized_keys
else
echo "Guest not found in authorized keys file"
FOUND=true
fi
if grep -q "${GUEST_NAME}@users." < $HOME/.git-commit-template; then
sed -i -e "/"${GUEST_NAME}"/d" $HOME/.git-commit-template
else
echo "Guest not found in git-commit-template file"
FOUND=true
fi
if [ "${FOUND}" = true ]; then
return
fi
echo "Removed guest '${GUEST_NAME}'"
}