-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset_up_mac.py
254 lines (219 loc) · 7.48 KB
/
set_up_mac.py
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
from pyinfra.operations import brew, files, git, server
from common import (cwd_path, home_path_str, notes_path_str,
personal_projects_path_str, projects_path_str,
work_projects_path_str, zshrc_path_str)
def setup_mac_using_brew():
"""
Install must-have packages I use almost every day.
"""
brew.packages(
packages=[
"ast-grep",
"bat",
"bison",
"cmake",
"colima",
"curl",
"docker",
"docker-compose",
"ffmpeg",
"fzf",
"gh",
"go",
"neovim",
"ollama",
"openjdk",
"pmd",
"pre-commit",
"pyenv",
"python",
"ripgrep",
"rust",
"sqlite",
"tmux",
"tree",
"vim",
"wget",
],
)
brew.casks(
casks=[
"alacritty",
"amethyst",
"betterdisplay",
"discord",
"ghostty",
"google-chrome",
"iina",
"intellij-idea-ce",
"karabiner-elements",
"libreoffice",
"netnewswire",
"obsidian",
"telegram",
"vial",
],
)
def setup_basic_directories():
"""
Here I craate basic directories I use every day.
"""
for path in [
projects_path_str,
personal_projects_path_str,
work_projects_path_str
]:
files.directory(
path=path,
present=True,
)
def setup_my_project():
git.repo(
src="[email protected]:IlyasYOY/obs.nvim.git",
dest=f"{personal_projects_path_str}/obs.nvim",
)
git.repo(
src="[email protected]:IlyasYOY/coredor.nvim.git",
dest=f"{personal_projects_path_str}/coredor.nvim",
)
git.repo(
src="[email protected]:IlyasYOY/git-link.nvim.git",
dest=f"{personal_projects_path_str}/git-link.nvim",
)
def setup_notes():
"""
Download and install all my notes so I can use them as I work.
"""
git.repo(
src="[email protected]:IlyasYOY/Notes.git",
dest=notes_path_str,
)
files.link(
path=f"{home_path_str}/vimwiki",
target=notes_path_str
)
def setup_links_to_config_files():
"""
Put all my configs in places they belong.
"""
dot_config_path_str = f'{home_path_str}/.config'
files.directory(path=dot_config_path_str,
present=True)
files.link(path=f'{dot_config_path_str}/nvim',
target=cwd_path / 'config/nvim')
files.link(path=f'{dot_config_path_str}/nvim-minimal',
target=cwd_path / 'config/nvim-minimal')
files.link(path=f'{dot_config_path_str}/zentile',
target=cwd_path / 'config/zentile')
files.directory(path=f"{dot_config_path_str}/git",
present=True)
files.link(path=f"{dot_config_path_str}/git/ignore",
target=cwd_path / '.gitignore-global')
files.link(path=f"{dot_config_path_str}/alacritty",
target=cwd_path / 'config/alacritty')
files.link(path=f"{dot_config_path_str}/ghostty",
target=cwd_path / 'config/ghostty')
files.link(path=f"{home_path_str}/.golangci.yml",
target=cwd_path / "config/.golangci.yml")
files.link(path=f"{home_path_str}/.tmux.conf",
target=cwd_path / ".tmux.conf")
files.link(path=f"{home_path_str}/.ideavimrc",
target=cwd_path / ".ideavimrc")
files.link(path=f"{home_path_str}/.vimrc",
target=cwd_path / ".vimrc")
files.link(path=f"{home_path_str}/.amethyst.yml",
target=cwd_path / ".amethyst.yml")
def setup_zshrc():
"""
Put all my settin in .zshrc.
"""
files.file(path=zshrc_path_str)
files.line(path=zshrc_path_str,
line='export EDITOR=nvim')
files.line(path=zshrc_path_str,
line='alias mnvim="NVIM_APPNAME=nvim-minimal nvim"')
files.line(path=zshrc_path_str,
line='alias nvims="nvim -S"')
files.line(path=zshrc_path_str,
line='alias vimconfig="vim ~/.vimrc"')
files.line(path=zshrc_path_str,
line='alias nvimconfig="nvim ~/.config/nvim/init.lua"')
files.line(path=zshrc_path_str,
line='alias mnvim="NVIM_APPNAME=nvim-minimal nvim"')
files.line(path=zshrc_path_str,
line='alias cdfzf=\'cd "$(find . -type d | fzf )"\'')
files.line(path=zshrc_path_str,
line='alias cdfzfgit=\'cd "$(find . -name .git -type d -prune | fzf)/.."\'')
files.line(path=zshrc_path_str,
line=f'export ILYASYOY_DOTFILES_DIR="{cwd_path}"')
files.line(path=zshrc_path_str,
line='export PATH="${ILYASYOY_DOTFILES_DIR}/bin:$PATH"')
files.line(path=zshrc_path_str,
line='alias ilyasyoy-dotfiles="cd ${ILYASYOY_DOTFILES_DIR}"')
files.line(path=zshrc_path_str,
line='alias ilyasyoy-notes="cd ~/vimwiki"')
files.line(path=zshrc_path_str,
line='export PATH="$HOME/go/bin:$PATH"')
def setup_sdkman():
"""
Download SDKMAN to manage java.
"""
server.shell(commands=['curl -s "https://get.sdkman.io" | bash'])
def setup_node_version_manager():
"""
Install NVM to manage node & npm.
"""
server.shell(commands=[
'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'])
nvm_source_script = ('export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"\n' +
'[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh" # This loads nvm')
files.block(path=zshrc_path_str,
marker='## {mark} nvm ##',
content=nvm_source_script,
try_prevent_shell_expansion=True)
server.shell(commands=[nvm_source_script + '&& nvm install --lts'])
def setup_go_version_manager():
"""
Install GVM to manage go.
"""
server.shell(commands=[
'sh -c "$(curl -fsSL https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)" | grep -e "Already installed" -e "Installed"'])
def setup_ohmyzsh():
"""
No comments here, everybody knows this.
"""
server.shell(commands=[
'sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | grep -e "already exists" -e "is now installed"'])
def setup_git_config():
"""
Some basic git configuration
"""
git.config(key='alias.st',
value='status --short')
git.config(key='alias.c',
value='commit')
git.config(key='alias.co',
value='checkout')
git.config(key='alias.lg',
value='log --all --decorate --graph --oneline')
git.config(key='diff.algorithm',
value='histogram')
git.config(key='core.quotePath',
value='false')
def setup_tmux_plugin_manger():
git.repo(src="https://github.com/tmux-plugins/tpm",
dest=f'{home_path_str}/.tmux/plugins/tpm')
server.shell(commands=[
f'{home_path_str}/.tmux/plugins/tpm/bin/install_plugins',
])
setup_mac_using_brew()
setup_basic_directories()
setup_notes()
setup_links_to_config_files()
setup_zshrc()
setup_git_config()
setup_sdkman()
setup_go_version_manager()
setup_node_version_manager()
setup_ohmyzsh()
setup_tmux_plugin_manger()