-
Notifications
You must be signed in to change notification settings - Fork 3
/
zshrc.local
97 lines (80 loc) · 3.29 KB
/
zshrc.local
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
PATH="./bin:/usr/local/bin:/usr/local/sbin:/usr/local/git/bin:$PATH"
cdpath=($HOME/Sites $HOME/projects $HOME/repos)
export IDF_CCACHE_ENABLE=1
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
export PATH="$HOME/.bin:$PATH"
export PATH="$HOME/Library/Python/3.8/bin:$PATH"
# NOTE: This is the default location for pipx:
export PATH="$HOME/.local/bin:$PATH"
# Go Repos
export GOPATH=$HOME/repos/go_repos
export PATH=$PATH:$GOPATH/bin
# Kubernetes Config
export KUBECONFIG="$HOME/.kube/config:$HOME/.kube/test-config:$HOME/.kube/rh-primary-config:$HOME/.kube/rh-management-bootstrap-config:$HOME/.kube/rh-management-config"
eval "$(/opt/homebrew/bin/brew shellenv)"
# TODO: Move these functions into a functions directory.
function pwpush {
readonly password=${1:?"The password must be specified."}
link=$(
curl -X POST --silent \
--data "password[payload]=$password&password[expire_after_days]=2&password[expire_after_views]=3" https://pwpush.com/p.json | \
python3 -c "import sys, json; print(f'https://pwpush.com/p/{json.load(sys.stdin)[\"url_token\"]}')"
)
print $link
echo $link | pbcopy
}
function kill_spotify {
ps -ax | grep -m1 Spotify | awk '{kill $1}'
}
# NOTE: Set username and password variables and run with
# `add_aws_access $AWS_USER $PASSWORD`
function add_aws_access {
readonly username=${1:?"The username must be specified."}
readonly password=${2:?"The password must be specified."}
# NOTE: AWS users should be created in terraform, not here.
# aws iam create-user --user-name $username
aws iam create-login-profile --user-name $username --password $password --no-password-reset-required
AWS_ACCOUNT_ALIAS=$(aws --output text iam list-account-aliases --query 'AccountAliases[0]')
print "Console access:"
print "Link:"
print "https://${AWS_ACCOUNT_ALIAS}.signin.aws.amazon.com/console/"
print "Username: $username"
print "Password:"
pwpush $password
print ""
print "CLI Access:"
creds=$(aws iam create-access-key --user-name $username | \
python3 -c "import sys, json; key = json.load(sys.stdin)['AccessKey']; print(f'Key: {key[\"AccessKeyId\"]}\nSecret: {key[\"SecretAccessKey\"]}')"
)
pwpush $creds
}
function rm_aws_access {
readonly username=${1:?"The username must be specified."}
aws iam delete-login-profile --user-name $username
}
#
# Kubernetes Functions
#
# Asset Platform: Kubernetes Get Remote Pod
function kgrp {
kubectl get pods --field-selector=status.phase=Running --namespace verumex --selector=app.kubernetes.io/instance=verumex | grep Running | grep -m1 verumex | cut -d' ' -f1 | awk "{print $1;}"
}
# Asset Platform: Remote Console
function rmc {
readonly shard=${1:?"The default shard must be specified."}
local podname=$(kgrp)
local remote_command="export DEFAULT_SHARD=${shard} && bundle exec rails c"
kubectl exec -it "$podname" --namespace verumex --container verumex -- bash -c "$remote_command"
}
#
# End Kubernetes Functions
#
# NOTE: The laptop script does attempt to insert asdf into this file but it ties
# to a specific user and doesn't include completions. Perhaps best to include
# it here directly instead of relying on the laptop script. Reference:
#
# https://asdf-vm.com/#/core-manage-asdf-vm
. $HOME/.asdf/asdf.sh
fpath=(${ASDF_DIR}/completions $fpath)
autoload -Uz compinit
compinit