-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_profile.sh
More file actions
142 lines (110 loc) · 2.95 KB
/
bash_profile.sh
File metadata and controls
142 lines (110 loc) · 2.95 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/local/bin/bash
# Add python for aws
export PATH="/Users/tommycouzens/Library/Python/3.8/bin:$PATH"
git_branch() {
git branch 2> /dev/null | grep '*' | awk '{print $2}' | sed 's/.*/(&)/'
}
get_aws_profile() {
cat ~/.awsp
}
prompt() {
# echo '$(get_aws_profile) \w\[\033[32m\] $(git_branch)\[\033[00m\] '
echo '\w\[\033[32m\] $(git_branch)\[\033[00m\] '
}
set_aliases() {
## Alias to go to and edit the bash profile
alias prof='vi ~/.bash_profile'
alias loadprof='source ~/.bash_profile'
alias minictl='minikube kubectl'
alias drm='docker rm $(docker ps -aq)'
alias drmi='docker rmi `docker images -q`'
# Docker exec to the one container running
alias dexec='docker exec -it $(docker ps -q) sh'
# restart docker
alias drestart='killall Docker && open /Applications/Docker.app'
alias tf='terraform'
alias gr='git-run'
alias g='grep'
alias lsg='ls | grep'
# https://itnext.io/pimp-my-kubernetes-shell-f144710232a0
alias k=kubectl
alias kg='kubectl get'
alias kl='kubectl logs '
alias kx='kubectl exec -i -t'
}
# aws profile
awsp() {
AWS_PROFILE=$1
# set a condition to return 0 if AWS_PROFILE = ~/.awsp as to not run the rest of this command for no point
# Set the cluster name
case "$AWS_PROFILE" in
stage) EKS_CLUSTER=dzing-dev-use1
;;
stageoh) EKS_CLUSTER=dzing-kpdt7zx-use2
;;
prod) EKS_CLUSTER=dzing-prod-euw1
;;
*) echo "Invalid aws profile. Options are: stage stageoh prod"
return 0
;;
esac
export EKS_CLUSTER
echo $AWS_PROFILE > ~/.awsp
for tool in aws kubectl helm terraform; do
alias $tool="aws-profile -p $AWS_PROFILE $tool"
done
if [ -z $2 ]; then
aws-profile -p $AWS_PROFILE aws eks update-kubeconfig --name $EKS_CLUSTER
fi
export PS1=$(prompt)
}
mcd () {
mkdir $1
cd $1
}
## Does all the steps for a push, with an optional input for commit message, otherwise defaults to "editing"
git-run() {
git add .
if (( $# > 0 )); then
git commit -m "$1"
else
git commit -m "editing" # default message for no commit
fi
git push
}
git-set-config() {
git config user.name "tommy-couzens"
git config user.email "tom.czns@gmail.com"
}
# Deletes a branch locally and remotely
git-delete() {
git branch -D "$1"
git push -d origin "$1"
}
## Does a git pull for all repos below your current directory
git-pull-all () {
for dir in $(ls -d */); do
cd $dir
if [ -d .git ]; then
echo "$dir is a git respository:"
git pull
fi
cd ..
done
}
wifirestart() {
sudo ifconfig en0 down
sudo ifconfig en0 up
}
main() {
# bash-completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
set_aliases
GATLING_HOME=/Users/tommycouzens/dzing/dz_infrastructure/gatling
awsp $(cat ~/.awsp) no_eks_config
}
main
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH