-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkbash_profile
188 lines (157 loc) · 5.13 KB
/
workbash_profile
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
source ~/.bashrc # aliases kept in ~/.bashrc
## Role assumeption ##
export AWS_DEV_TOKEN="INYOKQ47OQBTKPMNDSE5EMSVG57AMLBYSMZD3XFRDXZUYRBQEZOZPNBCICKTYEJO"
export AWS_PROD_TOKEN="E63TTCJ5SRTEPXHD63WQPWWCJJDDIHMGUKDJQS2T6QNKRWLNS7ODOWAZJ7LKG6ER"
function ec2metadatadev {
curl -X POST -d "profile=dev&profile_mfa=$(oathtool --totp -b $AWS_DEV_TOKEN)&profile_mfa_time=86400" http://169.254.169.254/profile
}
function ec2metadataprod {
curl -X POST -d "profile=prod&profile_mfa=$(oathtool --totp -b $AWS_PROD_TOKEN)&profile_mfa_time=86400" http://169.254.169.254/profile
}
function ec2AssumeRole {
curl -X POST -d "role=$1&duration=3600&serial=arn:aws:iam::056684691971:mfa/[email protected]&autorefresh=on" http://169.254.169.254/authenticate
unsetcreds
awsrole
}
function unsetprofile {
curl -X POST -d "role=Unset Profile" http://169.254.169.254/profile
awsrole
}
function devrole {
ec2metadatadev
ec2AssumeRole arn:aws:iam::056684691971:role/admin/credstash/commerce-translator/dev/dev-commerce-translator-credsta-CredstashAdminRole-14ZJAUOHBLMD8
}
function prodrole {
ec2metadataprod
ec2AssumeRole arn:aws:iam::104966627370:role/admin/credstash/commerce-translator/prod/prod-commerce-translator-credst-CredstashAdminRole-9YFMKVFQHLBM
}
function t2role {
ec2metadatadev
ec2AssumeRole arn:aws:iam::056684691971:role/admin/resources/transformation-team-access-T2Role-AGGYUOSQFQBE
}
function arole {
ec2metadatadev
ec2AssumeRole arn:aws:iam::056684691971:role/app/dev-ct-outbound-data-analysis-AppInstanceRole-1CBKX7OAS8PL
}
function grole {
ec2metadatadev
ec2AssumeRole arn:aws:iam::056684691971:role/app/dev-ct-outbound-data-gatherer-AppInstanceRole-1S3SGEZLEMI55
}
## some utility functions ##
function d2f {
oathtool --totp -b $AWS_DEV_TOKEN | pbcopy
}
function p2f {
oathtool --totp -b $AWS_PROD_TOKEN | pbcopy
}
function awsdev {
awsenv=dev
setawsenv
awsrole
}
function awsprod {
awsenv=prod
setawsenv
awsrole
}
function setawsenv {
export AWS_ACCESS_KEY_ID=$(aws configure get ${awsenv}.aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get ${awsenv}.aws_secret_access_key)
export AWS_DEFAULT_REGION=us-east-1
#PS1=(aws${awsenv})${PS1}
echo "AWS env to ${awsenv}"
}
function la {
ls -A
}
function vimrc {
vi ~/.vimrc
}
function bashrc {
vi ~/.bashrc
}
function bashp {
vi ~/.bash_profile
}
function srcbash {
source ~/.bash_profile
}
function backupbash {
cp ~/.bash_profile ~/backup
cp ~/.bashrc ~/backup
printf '\nbash configurations have been backed up to ~/backup...\n\n'
}
function restorebash {
cp ~/backup/.bash_profile ~
cp ~/backup/.bashrc ~
printf '\nbash configurations have been restored by the backup...\n\n'
}
function importconfigs {
echo pulling configs from github...
git -C ~/github/configsForTmux/ pull
cp ~/github/configsForTmux/.tmuxinator/default.yml ~/.tmuxinator/default.yml
cp ~/github/configsForTmux/.tmux.conf ~/.tmux.conf
cp ~/github/configsForTmux/.vimrc ~/.vimrc
echo 'configs have been imported...'
}
function exportconfigs {
cp ~/.tmuxinator/default.yml ~/github/configsForTmux/.tmuxinator/default.yml
cp ~/.tmux.conf ~/github/configsForTmux/.tmux.conf
cp ~/.vimrc ~/github/configsForTmux/.vimrc
cp ~/.bashrc ~/github/configsForTmux/workbashrc
cp ~/.bash_profile ~/github/configsForTmux/workbash_profile
cd ~/github/configsForTmux
git add .
gcm "foo"
git push
echo 'configs have been exported...'
cd
}
function javae () {
JAVA='.java'
CLASS='.class'
javac $1$JAVA
java $1
rm $1$CLASS
}
function findjdkhome {
/usr/libexec/java_home
}
function restore {
cd ~/github/ct-outbound-testing && cp analysisMake data-analysis/Makefile &&
cp gatheringMake data-gathering/Makefile &&
cp properties data-analysis/conf/majortest.properties &&
cp properties data-gathering/conf/majortest.properties
}
# Set up some useful bash functions
if [ -r $HOME/functions.sh ]; then
source $HOME/functions.sh
fi
###############################
## set some environment vars ##
# enable colors
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# set env
export TERM=xterm
export EDITOR='vim'
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
export SCALA_HOME=/usr/local/share/scala
export JUNIT_HOME=/Library/JUNIT
export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit4.10.jar:.
export PATH=$JAVA_HOME/bin/:$SCALA_HOME/bin:$HOME/.jenv/bin:$PATH
#OPAM configuration
. /Users/btpeterson/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
eval "$(jenv init -)"
# export Mockito_HOME=/Library/Mockito
# export CLASSPATH=$CLASSPATH:$Mockito_HOME/mockito-all-2.0.2-beta.jar:.
# change user icon, add git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
#export PS1="\[\033[35m\]\w\[\033[93m\]$(parse_git_branch)\[\033[00m\] $ "
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
#export PS1="\[\033[35m\]\w\[\033[93m\]$(__git_ps1)\[\033[00m\] $ "
#PS1="[\[\033[32m\]\w]\[\033[0m\]\$(__git_ps1)\n\[\033[1;36m\]\u\[\033[32m\]$ \[\
#\033[0m\]"
PS1="\[\033[35m\]\w\[\033[0m\]\$(__git_ps1)\[\033[35m\] $ \[\033[0m\]"