-
Notifications
You must be signed in to change notification settings - Fork 0
/
.apply
executable file
·170 lines (130 loc) · 3.98 KB
/
.apply
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
source ./.colors
if [[ -z "${__}" ]]; then
export __="$(pwd)"
fi
function log_cmd() {
_info "$1..." " "
eval $4 >> /dev/null 2>&1
val=$?
_cr
if [[ "$val" == "0" ]]; then
_success "$2!" " "
else
_fail "$3" " "
fi
_nl
}
function section() {
_title $1 && _nl
}
function apply_stuff() {
log_cmd "applying $1" "$1 applied" "$1 failed" "$2"
}
function install_stuff() {
log_cmd "installing $1" "$1 installed" "$1 install failed" "$2"
}
function update_stuff() {
log_cmd "updating $1" "$1 updated" "$1 update failed" "$2"
}
function apply_files() {
section "files"
files=(.secrets)
for file in "${files[@]}"; do
apply_stuff $file 'touch "${HOME}/${file}"'
done
}
function apply_symlinks() {
mkdir -p "${HOME}/.config" > /dev/null
section "symlinks"
links=(.aliases .apply .bash_profile .bashrc .colors .editorconfig .fdignore .gitcommit .gitconfig .y_nk.gitconfig .pro.gitconfig .gitignore .mackup.cfg .macos .shellrc .shortcuts.plist .zshrc .config/mise)
for link in "${links[@]}"; do
apply_stuff $link 'ln -fs "${__}/${link}" "${HOME}/${link}"'
done
}
function apply_secrets() {
section "secrets"
secrets=(gnupg ssh)
for secret in "${secrets[@]}"; do
apply_stuff $secret 'rm -fr "${HOME}/.${secret}" && ln -fs "${__}/../${secret}" "${HOME}/.${secret}"'
done
}
function apply_xcode() {
section "xcode"
install_stuff "xcode" "sudo xcode-select --install"
}
function apply_omz() {
section "omz"
if [ ! -d "$HOME/.oh-my-zsh" ]; then
install_stuff "omz" '/bin/bash -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'
else
update_stuff "omz" "omz update"
fi
}
function apply_brew() {
section "brew"
if ! type "brew" > /dev/null; then
install_stuff "brew" '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
else
update_stuff "brew" "brew update"
fi
}
function apply_cli_apps() {
section "cli apps"
packages=(asciinema awscli bash bat chafa coreutils curl fd fortune fzf gh git git-delta glow
httpie jq kubectl m-cli mackup macos-trash mas mise ncdu nmap pnpm
sdm telnet watch rodionovd/taps/shortcuts superfly/tap/flyctl)
for package in "${packages[@]}"; do
install_stuff "$package" "brew install $package"
done
}
function apply_cask_apps() {
section "cask apps"
casks=(1password 1password-cli android-platform-tools arc bambu-studio blender
fork gpg-suite-no-mail gitify iterm2 licecap maestral notion ngrok notion-calendar orbstack rectangle sdm shottr slack tableplus todoist unnaturalscrollwheels visual-studio-code vyprvpn homebrew/cask-fonts/font-anonymous-pro
homebrew/cask-fonts/font-martian-mono)
for cask in "${casks[@]}"; do
install_stuff "$cask" "brew install --cask $cask"
done
}
function apply_macstore_apps() {
section "macstore apps"
apps=( hiddenbar-1452453066 line-539883307 screenbrush-1233965871 tasktab-1395414535 )
for app in "${apps[@]}"; do
install_stuff "${app%%-*}" "mas install ${app#*-}"
done
}
function apply_iterm_components() {
section "iterm"
install_path="${HOME}/Library/Application Support/iTerm2"
scripts_path="${install_path}/Scripts/AutoLaunch"
rm -fr $scripts_path >> /dev/null
mkdir -p $scripts_path >> /dev/null
scripts=$(cd ${__}/.iterm && ls *.py)
for script in "${scripts[@]}"; do
echo ln -fs "${__}/.iterm/${script}" "${scripts_path}/${script}"
apply_stuff "script: $script" 'ln -fs "${__}/.iterm/${script}" "${scripts_path}/${script}"'
done
}
function apply_postinstall() {
section "postinstall"
apply_stuff "fzf" "$(brew --prefix)/opt/fzf/install --all"
apply_stuff "mackup" "mackup restore"
apply_stuff "shortcuts" "shortcuts import ~/.shortcuts.plist"
}
function apply_macos() {
section "macOS"
apply_stuff "macOS settings" "source ./.macos"
}
function apply_all() {
apply_files
apply_symlinks
apply_secrets
apply_omz
apply_brew
apply_cli_apps
apply_cask_apps
apply_macstore_apps
apply_postinstall
#apply_macos
}