This repository was archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
206 lines (171 loc) · 3.93 KB
/
bashrc
File metadata and controls
206 lines (171 loc) · 3.93 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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Enable ctrl-s and ctrl-q
stty -ixon -ixoff
GIT_PROMPT_THEME=Custom
# shellcheck source=.dotfiles/bash-git-prompt/gitprompt.sh
source ~/.dotfiles/bash-git-prompt/gitprompt.sh
if [ -f /usr/local/etc/bash_completion ]; then
source /usr/local/etc/bash_completion
fi
if [[ -f ~/.fzf.bash ]]; then
# shellcheck source=.fzf.bash
source ~/.fzf.bash
export FZF_DEFAULT_COMMAND='fd --type f --hidden'
export FZF_CTRL_T_COMMAND='fd --hidden'
export FZF_ALT_C_COMMAND='fd --type d --exclude Library'
bind -x '"\C-q": fzf-file-widget'
bind '"\C-t": transpose-chars'
_fzf_compgen_path() {
fd --hidden --follow . "$1"
}
_fzf_compgen_dir() {
fd --type d --hidden --follow . "$1"
}
fi
# enable gpg to prompt for password
GPG_TTY=$(tty)
export GPG_TTY
# Aliases and functions
alias ll='ls -lG --color=auto --group-directories-first'
alias l='ll -h'
alias la='ll -a'
alias grep='grep --color=auto'
alias gri='rg -i'
alias ccut='cookiecutter gh:RobbieClarken/cookiecutter-python-min'
alias dc='cd'
alias oepn='open'
alias vmi='vim'
pwdc () {
if (( $# > 0 )); then
the_path=$PWD/$1
else
the_path=$PWD
fi
echo "$the_path"
echo -n "$the_path" | pbcopy
}
alias kx=kubectx
alias kns=kubens
alias knss='kubens kube-system'
alias knsd='kubens default'
alias ktail=kubetail
alias kga='kubectl get --all-namespaces daemonset,ingress,all'
kgaa () {
local -r resource_types=(
apiservices
certificatesigningrequests
clusterrolebindings
clusterroles
configmaps
controllerrevisions
cronjobs
customresourcedefinition
daemonsets
deployments
endpoints
horizontalpodautoscalers
ingresses
jobs
limitranges
namespaces
networkpolicies
nodes
persistentvolumeclaims
persistentvolumes
poddisruptionbudget
pods
podsecuritypolicies
podtemplates
replicasets
replicationcontrollers
resourcequotas
rolebindings
roles
secrets
serviceaccounts
services
statefulsets
storageclasses
)
kubectl get --all-namespaces "$(echo "${resource_types[*]}" | tr ' ' ,)" "$@"
}
case "$(uname)" in
Darwin*)
alias chrome="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
;;
Linux*)
alias pbcopy='xsel -bi'
alias pbpaste='xsel -bo'
;;
esac
g () {
if (( $# > 0 )); then
git "$@"
else
git status --short --branch
fi
}
k () {
if (( $# > 0 )); then
kubectl "$@"
else
kubectl get daemonset,ingress,all
fi
}
tm () {
tmux "$@"
# if user leaves tmux by exiting bash automatically reattach to next session
while tmux attach | { read -r msg; [[ $msg == *exited* ]]; }; do :; done
}
tox () {
# require confirmation before recreating a tox environment to avoid accidentally doing
# so when recalling commands from history
if [[ -n ${VIRTUAL_ENV:-} ]]; then
echo "virtual env detected: aborting."
return 1
fi
if [[ $* =~ (^| )-[a-zA-Z]*r ]]; then
read -rp 'tox env will be recreated. Hit enter to continue or ctrl-c to cancel. '
fi
$(type -fp tox) "$@"
}
pipvenv () {
PIPENV_VENV_IN_PROJECT=1 pipenv "$@"
}
f8 () {
mapfile -t files < <(flake8 -q)
if (( ${#files[@]} > 0 )); then vim "${files[@]}"; fi
}
mkcd () {
mkdir -p "$1"
# shellcheck disable=SC2164
cd "$1"
}
cm () {
git add .
git status
git commit -m "$*"
}
vwhich () { vim "$(command -v "$@")"; }
complete -c vwhich
if hash __git_wrap__git_main 2>/dev/null; then
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main g
fi
if hash _rg 2>/dev/null; then
complete -o bashdefault -o default -F _rg gr
fi
if hash _docker 2>/dev/null; then
complete -F _docker d
fi
if hash __start_kubectl 2>/dev/null; then
complete -o default -F __start_kubectl k
fi
if hash _kube_contexts 2>/dev/null; then
complete -F _kube_contexts kx
fi
if hash _kubetail 2>/dev/null; then
complete -F _kubetail ktail
fi
if [ -f ~/.bashrc.local ]; then
# shellcheck source=.bashrc.local
source ~/.bashrc.local
fi