-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_profile
99 lines (82 loc) · 3.48 KB
/
bash_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
alias cat=bat
alias pcra='pre-commit run --all-files'
alias pcau='pre-commit autoupdate'
alias grb='goreleaser build --clean --snapshot --single-target'
[ -s /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
[ -s /usr/local/share/liquidprompt ] && . /usr/local/share/liquidprompt
[ -s /usr/local/share/chtf/chtf.sh ] && . /usr/local/share/chtf/chtf.sh
# [ -s /usr/local/share/chruby/chruby.sh ] && . /usr/local/share/chruby/chruby.sh
# [ -s /usr/local/share/chruby/auto.sh ] && . /usr/local/share/chruby/auto.sh
[ -s /usr/local/opt/nvm/nvm.sh ] && . /usr/local/opt/nvm/nvm.sh
[ -s /usr/local/opt/nvm/etc/bash_completion.d/nvm ] && . /usr/local/opt/nvm/etc/bash_completion.d/nvm
[ -s ~/work/.bash_profile ] && . ~/work/.bash_profile
complete -C /usr/local/bin/terraform terraform
if [ ! $(command -v kctx) ]; then
brew unlink kubectx
version=$(brew info kubectx --json | jq -r '.[].installed[].version' | tail -1)
ln -sf "../Cellar/kubectx/${version}/bin/kubectx" /usr/local/bin/kctx
ln -sf "../../Cellar/kubectx/${version}/etc/bash_completion.d/kubectx" /usr/local/etc/bash_completion.d/kctx
fi
if [ ! $(command -v kspy) ]; then
brew unlink kubespy
version=$(brew info kubespy --json | jq -r '.[].installed[].version' | tail -1)
ln -sf "../Cellar/kubespy/${version}/bin/kubespy" /usr/local/bin/kspy
fi
shopt -s globstar
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
export PS1="\u@\h:\w \$ "
export HISTFILESIZE=
export HISTSIZE=
export HISTCONTROL=ignoreboth
export HISTTIMEFORMAT="%F %T "
export DOCKER_SCAN_SUGGEST=false
export GOPATH=$HOME/.go
export NVM_DIR=$HOME/.nvm
export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
export HOMEBREW_NO_INSTALL_CLEANUP=1
rg() {
if [ -t 1 ]; then
command rg -p "$@" | less -RFX
else
command rg "$@"
fi
}
envpod() {
namespace=$1
pod=$2
if [[ $# -ne 2 ]]; then
echo "usage: $FUNCNAME <namespace> <pod>"
return 1
fi
kubectl exec -n "$namespace" "$pod" -- sh -c 'tr "\0" "\n" < /proc/$(pgrep -P 1)/environ'
}
ssm() {
environment=$1
region=$2
instance=$3
case $# in
2)
echo "Listing instances in $environment $region ..."
# ssm is quicker but doesn't show instance Name tags
# AWS_PROFILE="$environment" AWS_REGION="$region" aws ssm get-inventory --filters Key=AWS:InstanceInformation.InstanceStatus,Values=Active | jq -r '.Entities[] | [.Id, .Data["AWS:InstanceInformation"].Content[0].ComputerName] | @tsv'
AWS_PROFILE="$environment" AWS_REGION="$region" aws ec2 describe-instances --filters Name=instance-state-name,Values=running | jq -r '.Reservations[].Instances[] | [.InstanceId, .PrivateDnsName, (.Tags[]|select(.Key=="Name")|.Value)] | @tsv' | column -s "$(printf '\t')" -t
;;
3)
AWS_PROFILE="$environment" AWS_REGION="$region" aws ssm start-session --target "$instance" --document-name AWS-StartInteractiveCommand --parameters command="bash -l"
;;
*)
echo "usage: $FUNCNAME <environment> <region> [<instance-id>]"
return 1
;;
esac
}
ssmk8s() {
nodename=$1
environment=$(kubectl config current-context | cut -d'-' -f4)
providerid=$(kubectl get nodes "$nodename" -o json | jq -r .spec.providerID)
region=$(echo "$providerid" | cut -d'/' -f4 | rev | cut -c2- | rev)
instanceid=$(echo "$providerid" | cut -d'/' -f5)
ssm "$environment" "$region" "$instanceid"
}
export PATH="$(brew --prefix python@3.11)/libexec/bin:$PATH:${KREW_ROOT:-$HOME/.krew}/bin"