Repository navigation
Expand file tree
/
Copy pathaliases
More file actions
161 lines (145 loc) · 4.51 KB
/
Copy pathaliases
File metadata and controls
161 lines (145 loc) · 4.51 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
# NeoVim FTW
alias vim='nvim'
alias n='nvim'
alias v='nvim'
# General
alias grep='grep --color'
alias rm='rm -i'
alias ..="cd .."
alias sd='shred -vuz'
alias l='ls -lFha'
alias lt='ls -ltr'
alias h='history'
alias tree='tree -C'
if [[ -n "${WAYLAND_DISPLAY:-}" ]] && command -v wl-copy &>/dev/null; then
alias c='wl-copy'
elif command -v xclip &>/dev/null; then
alias c='xclip -selection clipboard'
fi
# Fat finger mistakes
alias valut='vault'
# Select a shared AppSRE Vault and authenticate through OIDC. This is a
# function (rather than a subprocess) so VAULT_ADDR remains set in this shell.
vlogin() {
local target=${1:-}
if [[ -z "$target" ]]; then
local choices=(
commercial-stage
commercial-prod
fedramp-stage
fedramp-prod
)
if command -v fzf &>/dev/null; then
target=$(printf '%s\n' "${choices[@]}" | fzf \
--height=40% --layout=reverse --border \
--prompt='Vault environment> ')
[[ -n "$target" ]] || return 130
else
local PS3='Vault environment (blank to cancel): '
select target in "${choices[@]}"; do
[[ -n "$target" ]] && break
return 130
done
fi
fi
local chrome_profile
case "$target" in
commercial-stage|cs)
export VAULT_ADDR=https://vault.stage.devshift.net
chrome_profile='Profile 1'
;;
commercial-prod|cp)
export VAULT_ADDR=https://vault.devshift.net
chrome_profile='Profile 1'
;;
fedramp-stage|fs)
export VAULT_ADDR=https://vault.stage.appsre.devshiftusgov.com
chrome_profile='Profile 3'
;;
fedramp-prod|fp)
export VAULT_ADDR=https://vault.appsre.devshiftusgov.com
chrome_profile='Profile 3'
;;
*)
printf 'Usage: vlogin {commercial-stage|commercial-prod|fedramp-stage|fedramp-prod}\n' >&2
return 2
;;
esac
# Vault's OIDC plugin calls xdg-open directly and ignores $BROWSER. Put a
# private xdg-open shim first in PATH for this login only, so Chrome receives
# the profile directory along with the authorization URL.
local launcher_dir launcher_status
launcher_dir=$(mktemp -d "${XDG_RUNTIME_DIR:-/tmp}/vault-browser.XXXXXX") || return
cat >"$launcher_dir/xdg-open" <<'EOF'
#!/bin/sh
exec /opt/google/chrome/google-chrome \
--profile-directory="$VAULT_CHROME_PROFILE" "$@"
EOF
chmod 700 "$launcher_dir/xdg-open"
printf 'Logging into %s with Chrome profile %s\n' "$VAULT_ADDR" "$chrome_profile"
VAULT_CHROME_PROFILE="$chrome_profile" \
PATH="$launcher_dir:$PATH" \
command vault login -method=oidc
launcher_status=$?
rm -rf "$launcher_dir"
return "$launcher_status"
}
alias vcs='vlogin commercial-stage'
alias vcp='vlogin commercial-prod'
alias vfs='vlogin fedramp-stage'
alias vfp='vlogin fedramp-prod'
# kubectl aliases
alias k='kubectl'
alias ka='kubectl apply -f'
alias kd='kubectl describe'
alias ke='kubectl exec -ti'
alias kg='kubectl get'
alias kga='kubectl get ing,svc,deploy,rc,pods,cm,pv,pvc,crd,jobs'
alias kwa='watch kubectl get ing,svc,deploy,rc,pods,cm,pv,pvc'
alias kgcm='kubectl get configmap'
alias kgd='kubectl get deployment'
alias kgds='kubectl get daemonset'
alias kgp='kubectl get pods'
alias kgj='kubectl get jobs'
alias kgi='kubectl get ingress'
alias kgn='kubectl get nodes'
alias kgns='kubectl get namespaces'
alias kgs='kubectl get secrets'
alias kgsvc='kubectl get service'
alias kgsa='kubectl get serviceaccounts'
alias kgpv='kubectl get pv'
alias kgpvc='kubectl get pvc'
alias kgss='kubectl get statefulset'
alias kgcrd='kubectl get crd'
alias kl='kubectl logs'
alias krm='kubectl delete'
alias kutil='kubectl run -i --tty debian-util --image=debian:stable-slim --restart=Never -- sh'
# oc (OpenShift CLI) aliases
alias o='oc'
alias oca='oc get'
alias oa='oc apply -f'
# change ordering on the terminal to show the most recent first
alias ocgp='oc get pods --sort-by=.metadata.creationTimestamp'
alias ocge='oc get events --sort-by=.metadata.creationTimestamp'
# tkn (tekton cli) aliases
alias ttl='tkn task list'
alias tpl='tkn pipeline list'
alias tprl='tkn pipelinerun list'
# Docker aliases
alias d='docker'
alias de='docker exec -ti'
alias dps='docker ps'
# Podman aliases
alias pm='podman'
alias pmps='podman ps'
# Vagrant aliases
alias vu='vagrant up'
alias vf='vagrant up --provider=vmware_fusion'
alias vv='vagrant up --provider=virtualbox'
alias vpp='vagrant up --provider=parallels'
alias vkvm='vagrant up --provider=libvirt'
alias vs='vagrant status'
alias vd='vagrant destroy --force'
alias vgs='vagrant global-status'
alias vssh='vagrant ssh'
alias vp='vagrant provision'