-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmacos_shell_aliases.sh
executable file
·98 lines (67 loc) · 2.47 KB
/
macos_shell_aliases.sh
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
#!/bin/zsh
# append to end of file with awk
function append_to_file_awk() {
echo "$1" | awk '{print $0 >> "'$2'"}'
}
# remove everything
function remove_aliases() {
sed -i '' '/# ### ALIASES ###/,/# ### ALIASES ###/d' "$1"
}
# get current date in string
d=$(date +%Y-%m-%d)
ALIASES="# ### ALIASES ###
# ### updated: $d ###
alias recent=\"find . -type d -mtime -30 -maxdepth 1 -mindepth 1\"
alias recent.day=\"find . -type d -mtime -1 -maxdepth 1 -mindepth 1\"
alias recent.week=\"find . -type d -mtime -7 -maxdepth 1 -mindepth 1\"
# add string to the end of the file
alias append=\"echo '\$1' >>\"
# javascript
alias next=\"npx next\"
alias npm-list-globals=\"npm list -g --depth 0\"
alias npm-check-globals=\"npm outdated -g --depth=0\"
# alias npm-upgrade-globals='echo \"upgrade individual with: npm update -g <package_name>\"'
alias npm-upgrade-globals='npm update -g'
alias npm-list-dev-dependencies=\"npm list --depth=0 --dev\"
alias npm-version=\"echo '[node version]' && nvm ls current && echo '[npm version]' && npm --version && echo '[where is npm]' && which npm\"
# check npx is installed
alias npx-check=\"npx --version\"
# write out .nvmrc file
alias nvmrc=\"node -v > .nvmrc\"
# python
# php, composer, laravel
alias php-version=\"echo '[php -v]' && php -v && echo '[where is php]' && ls -al /opt/homebrew/bin/php\"
# list composer global packages
alias composer-list-globals=\"composer global show\"
# composer global update everything
alias composer-global-update=\"composer global update\"
# composer install global packages
alias composer-global=\"composer global require\"
# composer search global packages
alias composer-search-global=\"composer-list-globals | grep\"
# composer global remove a package
alias composer-global-remove=\"composer global remove\"
# DevOps
# kube-land
alias k=\"kubectl\"
alias kcontexts=\"kubectl config get-contexts\"
alias kinfo=\"kubectl cluster-info\"
alias knodes=\"kubectl get nodes\"
alias ks=\"kubectl get services\"
alias kp=\"kubectl get pods\"
alias kd=\"kubectl describe\"
# terraform
alias tf=\"terraform\"
alias tfa=\"terraform apply -auto-approve\"
alias tfdestroy=\"terraform destroy -auto-approve\"
alias tfmt=\"terraform fmt -recursive\"
alias tfplan=\"terraform plan\"
alias tfshow=\"terraform show\"
alias tfstate=\"terraform state list\"
# ### ALIASES ###
"
# if file .zshrc exists append to end of the file
if [ -f ~/.zshrc ]; then
remove_aliases "$HOME/.zshrc"
append_to_file_awk "$ALIASES" "$HOME/.zshrc"
fi