-
Notifications
You must be signed in to change notification settings - Fork 2
/
.aliases
362 lines (278 loc) · 17.2 KB
/
.aliases
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/bin/bash
# Set aliases for some generic scripts
WORKSPACE_REPO_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
################################################################################
# docker
alias docker-images-prune='docker images prune'
alias docker-rm-exited='docker rm $(docker ps -q -f status=exited)'
alias docker-rmi-dangling='docker rmi $(docker images -f "dangling=true" -q)'
alias docker-secret-list='docker secret list'
alias docker-system-prune-a='docker system prune -a'
################################################################################
# helm
alias helm-install='helm install'
alias helm-ls='helm ls'
alias helm-ls-pending-='helm ls -a -A | grep -i pending'
# helm uninstall kube-apps -n kube-apps
alias helm-package='helm package'
alias helm-repo-update='helm repo update'
alias helm-rollback='helm rollback'
alias helm-search-hub='helm search hub'
alias helm-search-repo='helm search repo'
alias helm-show-all='helm show all'
alias helm-status='helm status'
alias helm-uninstall='helm uninstall'
alias helm-upgrade='helm upgrade'
################################################################################
# git / gh
alias git-branch-default='gh repo view --json defaultBranchRef --jq .defaultBranchRef.name'
alias git-branch-current='git branch --show-current'
alias git-branch-rename-main2master='git branch -m main master && git push -u origin master && git push origin -d main'
alias git-branch-rename-master2main='git branch -m master main && git push -u origin main && git push origin -d master'
alias git-chmod='sh -c '\''git update-index --chmod="$@"'\'' _'
alias git-config-core-ignorecase-false='git config core.ignorecase false'
alias git-config-core-ignorecase-true='git config core.ignorecase true'
alias git-config-fileMode-false='git config core.fileMode false'
alias git-config-fileMode-true='git config core.fileMode true'
alias git-config-list='git config --list'
alias git-config-show-user='git config user.name && git config user.email'
alias git-fetch='git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --prune origin'
alias git-secrets-list-config-current-repo='git secrets --list'
alias git-secrets-list-config-global='git secrets --list --global'
alias git-secrets-scan='git secrets --scan -r'
alias git-secrets-scan-history='git secrets --scan-history'
alias git-rm-reflog='git reflog expire --expire=now --all'
alias git-pull-all='. ${WORKSPACE_REPO_HOME}/useful-tools/git/run_git_pull.sh'
alias git-repo-latest-release='. ${WORKSPACE_REPO_HOME}/useful-tools/github/get_github_repo_latest_release.sh'
alias git-repo-latest-tag='. ${WORKSPACE_REPO_HOME}/useful-tools/github/get_github_repo_latest_tag.sh'
alias git-squash-new-start='. ${WORKSPACE_REPO_HOME}/useful-tools/git/squash_all_git_commits_into_latest.sh'
alias git-checkout--='git checkout -- .'
alias git-checkout-default='git checkout $(git-branch-default)'
alias git-clean-dfx='git clean -dfx'
alias git-ls-branch-all='. ${WORKSPACE_REPO_HOME}/useful-tools/git/run_git_branch.sh'
alias git-ls-files='git ls-files'
alias git-ls-files-untracked='git ls-files --others --exclude-standard'
alias gh-aliases='gh alias list'
alias gh-aliases-reimport='gh alias import --clobber ${WORKSPACE_REPO_HOME}/.aliases-gh.yml'
alias gh-extension-list='gh extension list'
alias gh-api-rate-limit='gh api -H "Accept: application/vnd.github.v3+json" /rate_limit'
alias gh-oidc-thumbprint-for-actions='. ${WORKSPACE_REPO_HOME}/useful-tools/github/get_github_oidc_thumbprint_for_actions.sh'
alias gh-oidc-thumbprint-for-audit-log='. ${WORKSPACE_REPO_HOME}/useful-tools/github/get_github_oidc_thumbprint_for_audit_log.sh'
alias gh-auth-login='gh auth login'
alias gh-auth-logout='gh auth logout'
alias gh-auth-setup-git='git auth setup-git'
alias gh-auth-status='gh auth status'
alias gh-auth-switch='gh auth switch'
alias gh-login-current='gh api /user | jq .login'
alias gh-pr-create='gh pr create --assignee @me --fill'
alias gh-pr-merge-squash='gh pr merge --squash'
alias gh-delete-workflow-runs='python3 ${WORKSPACE_REPO_HOME}/useful-tools/github/gh_delete_workflow_runs.py'
alias gh-force-cancel-workflow-runs='python3 ${WORKSPACE_REPO_HOME}/useful-tools/github/gh_force_cancel_workflow_runs.py'
alias git-auto-commit-merge='git add . && git commit -m "Updated" && git push'
alias git-auto-branch='function _(){ if [[ -z "$1" ]]; then echo "Missing branch name"; else git branch $1 && git checkout $1; fi; }; _'
alias git-auto-pr-merge='function _(){ ORI_BRANCH=$(git-branch-current) && gh-pr-create && gh-pr-merge-squash --admin && git-checkout-default && git-pull-all && git branch -D ${ORI_BRANCH}; }; _'
alias git-auto-commit-pr-merge='function _(){ if [[ -z "$1" ]]; then echo "Missing commit message"; else git commit -m "$1" && git push --set-upstream origin $(git-branch-current) && git-auto-pr-merge; fi; }; _'
alias git-auto-ci-all-changes='function _(){ if [[ -z "$1" ]] || [[ -z "$2" ]] ; then echo "Arguments: [BRANCH_NAME] [COMMIT_MESSAGE]"; else git-auto-branch "$1" && git add . && git-auto-commit-pr-merge "$2"; fi; }; _'
################################################################################
# gitleaks
alias gitleaks-detect='gitleaks detect --report-path gitleaks-report.json'
################################################################################
# go
alias go-build='go build'
alias go-clean-modcache='go clean -modcache'
alias go-get-aws='go get github.com/aws/aws-sdk-go-v2 && go get github.com/aws/aws-sdk-go-v2'
alias go-install='go install'
alias go-mod-init='go mod init'
alias go-mod-tidy='go mod tidy'
alias go-run='go run'
alias go-test='go test -v'
################################################################################
# k9s
alias k9s-info='k9s info'
alias k9s-readonly='k9s --readonly'
################################################################################
# kubectl
alias kubectl-describe-configmap-n-kube-system-aws-auth='kubectl describe configmap -n kube-system aws-auth'
alias kubectl-describe-pod='sh -c '\''kubectl describe pod "$@"'\'' _'
alias kubectl-describe-secret-eks-admin='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/kubectl_describe_secret_eks_admin.sh'
alias kubectl-get-clusterrolebindings='kubectl get clusterrolebindings'
alias kubectl-get-clusterroles='kubectl get clusterroles'
alias kubectl-get-deployment='kubectl get deployment'
alias kubectl-get-deployment-a='kubectl get deployment -A'
alias kubectl-get-events='kubectl get events'
alias kubectl-get-endpoints-a='kubectl get endpoints -A'
alias kubectl-get-ingress='kubectl get ingress'
alias kubectl-get-ingress-a='kubectl get ingress -A'
alias kubectl-get-namespace='kubectl get namespace'
alias kubectl-get-pods='kubectl get pods'
alias kubectl-get-pods-a='kubectl get pods -A'
alias kubectl-get-pods-o-wide='kubectl get pods -o wide'
alias kubectl-get-pods-o-wide-a='kubectl get pods -o wide -A'
alias kubectl-get-pods-show-labels='kubectl get pods --show-labels'
alias kubectl-get-pods-show-labels-a='kubectl get pods --show-labels -A'
alias kubectl-get-rolebindings-a='kubectl get rolebindings -A'
alias kubectl-get-roles-a='kubectl get roles -A'
alias kubectl-get-svc='kubectl get svc'
alias kubectl-get-svc-a='kubectl get svc -A'
alias kubectl-logs-aws-load-balancer-controller='kubectl logs -n kube-system deployment.apps/aws-load-balancer-controller'
alias kubectl-logs-cluster-autoscaler='kubectl logs -n kube-system deployment.apps/cluster-autoscaler'
alias kubectl-validate-yaml='kubectl create --dry-run --validate=true -f'
################################################################################
# npm
alias npm-audit='npm audit'
alias npm-audit-fix='npm audit fix'
alias npm-audit-signatures='npm audit signatures'
alias npm-install='npm install'
################################################################################
# nvm
alias nvm-install-latest='nvm install node --reinstall-packages-from=node'
alias nvm-install-latest-lts='nvm install --lts'
alias nvm-install-latest-npm='nvm install-latest-npm'
alias nvm-ls='nvm ls'
alias nvm-ls-remote-lts-14='nvm ls-remote --lts=Fermium'
alias nvm-ls-remote-lts-16='nvm ls-remote --lts=Gallium'
alias nvm-ls-remote-lts-18='nvm ls-remote --lts=Hydrogen'
alias nvm-use-latest='nvm use node'
alias nvm-use-latest-lts='nvm use --lts'
alias nvm-use-system='nvm use system'
alias nvm-which-current='nvm which current'
################################################################################
# pip
alias pip-list-not-required='pip list --not-required'
alias pip-list-outdated='pip list --outdated'
alias pip-upgrade-all='. ${WORKSPACE_REPO_HOME}/useful-tools/python/run_pip_upgrade_all.sh'
################################################################################
# pre-commit
alias pre-commit-install='pre-commit install'
################################################################################
# pyenv
alias pyenv-commands='pyenv commands'
alias pyenv-global-system='pyenv global system'
alias pyenv-install-list='pyenv install --list'
alias pyenv-versions='pyenv versions'
alias pyenv-which='pyenv which'
################################################################################
# python
alias python-zoneinfo-available-timezones='python3 -c "import zoneinfo; print(\"\n\".join(tz for tz in sorted(zoneinfo.available_timezones())))"'
#alias python-timezones='python3 -c "import pytz;print(\"\n\".join(tz for tz in pytz.all_timezones))"'
################################################################################
# skaffold
alias skaffold-apply='skaffold apply'
alias skaffold-build='skaffold build'
alias skaffold-deploy='skaffold deploy'
alias skaffold-dev='skaffold dev'
alias skaffold-render='skaffold render'
alias skaffold-run='skaffold run'
################################################################################
# trufflehog
alias trufflehog-filesystem='trufflehog filesystem'
alias trufflehog-git-only-verified='trufflehog git -only-verified --json'
################################################################################
# yarn
# see https://thomaschaplin.medium.com/how-to-fix-yarn-audit-issues-ff5840f712d1
alias yarn-audit-fix='npm i --package-lock-only && rm yarn.lock && npm audit fix && yarn import && rm package-lock.json'
alias yarn-upgrade='yarn upgrade'
################################################################################
# rm-
alias rm-cache='. ${WORKSPACE_REPO_HOME}/scripts/sh/cleanup_cache.sh'
alias rm-cache-apt='sudo du -sh /var/cache/apt && sudo apt-get clean'
alias rm-dev-env='. ${WORKSPACE_REPO_HOME}/scripts/sh/cleanup_dev_env.sh'
alias rm-unpurged-packages="sudo apt purge $(dpkg --list | grep ^rc | awk '{ print $2; }')"
################################################################################
# synk
alias snyk-code-test='snyk code test'
alias snyk-monitor='snyk monitor -d -insecure --all-projects --fail-fast --strict-out-of-sync=true --detection-depth=6'
alias snyk-test='snyk test --all-projects --fail-fast --detection-depth=6'
alias snyk-run-all='. ${WORKSPACE_REPO_HOME}/useful-tools/snyk/run-snyk.sh'
################################################################################
# update
alias update-brew='brew update'
alias update-git='. ${WORKSPACE_REPO_HOME}/useful-tools/git/install_git.sh'
alias update-git-sizer='. ${WORKSPACE_REPO_HOME}/useful-tools/git/install_git_sizer.sh'
# github related
alias update-act='. ${WORKSPACE_REPO_HOME}/useful-tools/github/install_act.sh'
alias update-gh='. ${WORKSPACE_REPO_HOME}/useful-tools/github/install_gh.sh'
# docker related
alias update-dive='. ${WORKSPACE_REPO_HOME}/useful-tools/docker/install_dive.sh'
alias update-lazydocker='. ${WORKSPACE_REPO_HOME}/useful-tools/docker/install_lazydocker.sh'
# k8s related
alias update-helm='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_helm.sh'
alias update-k9s='curl -sS https://webinstall.dev/k9s | bash'
alias update-kops='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_kops.sh'
alias update-krew='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_krew.sh'
alias update-kubectl='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_kubectl.sh'
alias update-kubectx-and-kubens='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_kubectx_and_kubens.sh'
alias update-kustomize='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_kustomize.sh'
alias update-minikube='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_minikube.sh'
alias update-skaffold='. ${WORKSPACE_REPO_HOME}/useful-tools/kubernetes/install_skaffold.sh'
alias update-golang='. ${WORKSPACE_REPO_HOME}/useful-tools/golang/install_golang.sh'
alias update-pyenv='pyenv update'
alias update-ncc='sudo npm i -g @vercel/ncc'
alias update-nodejs='. ${WORKSPACE_REPO_HOME}/useful-tools/nodejs/install_nodejs.sh'
alias update-npm='sudo npm i -g npm@latest'
alias update-npx='sudo npm i -g npx --force'
alias update-nvm='. ${WORKSPACE_REPO_HOME}/useful-tools/nodejs/install_nvm.sh'
alias update-typescript='sudo npm i -g typescript && echo "INFO: tsc version: $(tsc --version)"'
alias update-pathpicker='. ${WORKSPACE_REPO_HOME}/useful-tools/install_fpp_Facebook_PathPicker.sh'
alias update-serverless='. ${WORKSPACE_REPO_HOME}/useful-tools/install_serverless.sh'
alias update-gitleaks='. ${WORKSPACE_REPO_HOME}/useful-tools/sec/install_gitleaks.sh'
alias update-osv-scanner='. ${WORKSPACE_REPO_HOME}/useful-tools/sec/install_osv_scanner.sh'
alias update-snyk-cli='. ${WORKSPACE_REPO_HOME}/useful-tools/sec/install_snyk_cli.sh'
alias update-trufflehog='. ${WORKSPACE_REPO_HOME}/useful-tools/sec/install_trufflehog.sh'
alias update-ubuntu='sudo apt-get update && sudo apt install ca-certificates && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove && sudo apt-get -y autoclean'
################################################################################
# custom scripts or commands
alias k-check-workspace='. ${WORKSPACE_REPO_HOME}/ubuntu/check_workspace.sh'
alias k-degreen='. ${WORKSPACE_REPO_HOME}/scripts/sh/degreen.sh'
alias k-dos2unix='find . -type f ! -iname "*.ps1" ! -name "*.bat" ! -path "*/.git/*" ! -path "*/.idea/*" ! -path "*/node_modules/*" -print0 | xargs -0 dos2unix'
alias k-grep='sh -c '\''grep -R --exclude-dir=.git --exclude-dir=cdk.out --exclude-dir=dist --exclude-dir=node_modules "$@"'\'' _'
alias k-rename-files='python3 ${WORKSPACE_REPO_HOME}/scripts/py/rename_files.py'
alias k-repo-setup='. ${WORKSPACE_REPO_HOME}/ubuntu/setup_repo.sh'
####
# System
alias k-du-hs='du -hs'
alias k-du-h-max-depth-1='du -h --max-depth=1'
alias k-df-h='df -h'
alias k-lsb-release-a='lsb_release -a'
alias k-lsb-release-d='lsb_release -d'
alias k-reset-clock='. ${WORKSPACE_REPO_HOME}/ubuntu/reset_clock.sh'
####
# Conversion
alias k-oidc-thumbprint='. ${WORKSPACE_REPO_HOME}/useful-tools/oidc/get_oidc_thumbprint.sh'
alias k-pem2crt='_func(){ openssl x509 -inform PEM -in "$1" -out $(basename "${1%.*}.crt"); }; _func'
alias k-timestamp2datetime='function _(){ if [[ -z "$1" ]]; then echo "Missing timestamp"; else date -d@$1; fi; }; _'
####
# Linting
alias k-black='black --line-length=99'
# W605 Invalid escape sequence
alias k-flake8='flake8 --ignore W605 --max-line-length 99'
alias k-yamllint='yamllint -d "{extends: default, rules: {document-start: disable, line-length: disable, truthy: disable}}" -f parsable .'
####
# ls
alias k-ls-common-ip-protocols='cat ${WORKSPACE_REPO_HOME}/quick-notes/common-ip-protocols.txt'
alias k-ls-common-ip-ranges='cat ${WORKSPACE_REPO_HOME}/quick-notes/common-ip-ranges.txt'
alias k-ls-common-ports='cat ${WORKSPACE_REPO_HOME}/quick-notes/common-ports.txt'
alias k-ls-mult-byte-units='cat ${WORKSPACE_REPO_HOME}/quick-notes/multi-byte-units.txt'
alias k-ls-timezones='. ${WORKSPACE_REPO_HOME}/scripts/sh/ls_timezones.sh'
alias k-ls-unpurged-packages='dpkg --list | grep ^rc'
####
# Networking
alias k-ip-in-range-check='python3 ${WORKSPACE_REPO_HOME}/useful-tools/networking/is_ip_in_range.py'
# what the outside world thinks your ip address is
# or curl ifconfig.me
# https://askubuntu.com/questions/430853/how-do-i-find-my-internal-ip-address
alias k-ip-external='curl --silent http://checkip.amazonaws.com'
# what your computer thinks its ip address is
alias k-ip-local='. ${WORKSPACE_REPO_HOME}/ubuntu/get_local_ip.sh'
alias k-whatismy-ipaddress='browser https://whatismyipaddress.com/'
alias k-whatismy-proxy='browser http://www.whatismyproxy.com/'
alias k-ipam-helper='python3 ${WORKSPACE_REPO_HOME}/../phpipam-api-helper/phpipam_api_helper.py'
alias k-panos-helper='python3 ${WORKSPACE_REPO_HOME}/../panos-api-helper/panos_api_helper.py'
alias k-disable-apt-ocsp-verification='. ${WORKSPACE_REPO_HOME}/ubuntu/disable_apt_ocsp_verification.sh'
alias k-reset-apt-ocsp-verification='. ${WORKSPACE_REPO_HOME}/ubuntu/reset_apt_ocsp_verification.sh'
alias k-add-registry-yarnpkg-to-etc-hosts='registryYarnpkgComIpAddress=$(host registry.yarnpkg.com | awk '"'"'/has address/ { print $4 }'"'"' | head -n1) ; echo "${registryYarnpkgComIpAddress} registry.yarnpkg.com" | sudo tee -a /etc/hosts'
# Cheatsheets
alias k-cheatsheet-aws-network='browser https://github.com/kyhau/aws-notebook/blob/master/Networking.md'
alias k-cheatsheet-docker='browser https://github.com/kyhau/docker-notebook/blob/master/README.md'
alias k-cheatsheet-kubectl='browser https://kubernetes.io/docs/reference/kubectl/cheatsheet/'
alias k-cheatsheet-python='browser https://github.com/gto76/python-cheatsheet/blob/master/README.md'