-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
120 lines (105 loc) · 2.89 KB
/
.zshrc
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
# exports
export AWS_PAGER=""
export CONTAINER_NAME=bastion-ssh
export EDITOR=vim
export GIT_EDITOR=/usr/bin/vim
export GIT_PAGER=cat
export HOSTNAME=$CONTAINER_NAME
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
export LC_CTYPE=utf-8
export PATH="${PATH}:${HOME}/.krew/bin"
export TERM=xterm-256color
export TILLER_NAMESPACE=tiller
export UPDATE_ZSH_DAYS=30
export ZSH_THEME=inspiration
export ZSH=~/.oh-my-zsh
export ZSHZ_CMD='j'
export RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'
# env, not exported
SSH_ENV=$HOME/.ssh/environment
CASE_SENSITIVE="true"
DISABLE_CORRECTION="true"
# zsh plugins
plugins=(git colorize pip python zsh-z zsh-kubectl-prompt)
# load oh-my-zsh
source $ZSH/oh-my-zsh.sh
# aliases
alias j=zshz 2>&1
alias k=kubectl
alias ls='exa -la'
alias md=mkdir
alias prettyjson='python -m json.tool'
alias tree="exa -T"
alias clip='xclip'
alias kgp='kubectl get pod'
alias kgs='kubectl get service'
alias kgt='kubectl get secret'
function kg() {
local svc=$1
local greptext=$2
if [ "$#" -ne 2 ]; then
echo "kube-get usage: kg k8-apiobject searchtext"
else
obj=$(kubectl get $svc | grep "$greptext" | head -n 1 | cut -f1 -d ' ')
ret=$?
if [[ $ret -ne 0 ]]; then
echo "$svc with pattern '$greptext' not found."
else
echo "$obj copied to clipboard."
printf $obj | xclip -sel clip
fi
fi
}
# shell functions
function dpod() {
export pod=$(k get po | grep $1 | cut -f1 -d ' ' | head -n 1)
echo $pod
kubectl describe pod $pod
}
function epod() {
export pod=$(k get po | grep $1 | cut -f1 -d ' ' | head -n 1)
echo $pod
kubectl exec -it $pod -- $2
}
function start_agent {
echo "Initializing new SSH agent..."
cd ~/.ssh
eval `/usr/bin/ssh-agent -s` && sleep 2
echo succeeded
chmod 600 "${SSH_ENV}"
ssh-add id_rsa
cd $OLDPWD
}
function connect_to_eks_cluster() {
export AWS_REGION=us-east-2
export AWS_PROFILE=nca
export EKS_CLUSTER_NAME=$(aws eks list-clusters --region $AWS_REGION | jq -r '.clusters[0]')
aws sts get-caller-identity && aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION
kubectl config set-context --current --namespace=$DEFAULT_NAMESPACE
chmod 600 ~/.kube/config
}
# start the ssh agent
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
# more zsh stuff
autoload colors; colors;
autoload -U compinit && compinit -u
autoload zmv
zmodload -a colors
zmodload -a autocomplete
zmodload -a complist
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
bindkey -v
bindkey "^R" history-incremental-search-backward
# setup syntax highlighting (valid commands turn green as you type)
source ~/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
eval "$(direnv hook zsh)"
# linode
export KUBECONFIG=~/.kube/k8s-kubeconfig.yaml