This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
executable file
·199 lines (165 loc) · 5.73 KB
/
setup.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
#!/usr/bin/env python3
import os
import subprocess
import sys
yes = "-y" in sys.argv
IS_DARWIN: bool = sys.platform.startswith("darwin")
def mkdir(path: str):
try:
os.mkdir(os.path.expanduser(path))
except FileExistsError:
pass
def install_packages(packages):
AUR_HELPER = "pikaur"
if "--pkg" in sys.argv or "--packages" in sys.argv:
subprocess.run([AUR_HELPER, "-S"] + packages)
def install_coc_plugins() -> None:
def split_list(ls, n):
for i in range(0, len(ls), n):
yield ls[i : i + n]
pluglist = [
"coc-clangd",
"coc-css",
"coc-diagnostic",
"coc-dictionary",
"coc-emoji",
"coc-git",
"coc-java",
"coc-json",
"coc-lists",
"coc-markdownlint",
"coc-marketplace",
"coc-pairs",
"coc-jedi",
"coc-rust-analyzer",
"coc-sh",
"coc-snippets",
"coc-tag",
"coc-texlab",
"coc-tsserver",
"coc-ultisnips",
"coc-vimtex",
"coc-word",
"coc-yaml",
"coc-yank",
]
for plugs in split_list(pluglist, 10):
subprocess.run(["nvim", "+CocInstall " + " ".join(plugs)])
def link(relative_name: str, filepath: str, /, sudo: bool = False) -> None:
if not os.path.exists(os.getcwd() + relative_name):
raise FileNotFoundError("Local filepath does not exist")
filepath = os.path.expanduser(filepath)
mkdir(filepath if os.path.isdir(filepath) else os.path.dirname(filepath))
if sudo:
subprocess.run(["sudo", "rm", "-rf", filepath])
subprocess.run(["sudo", "ln", "-s", os.getcwd() + relative_name, filepath])
else:
subprocess.run(["rm", "-rf", filepath])
subprocess.run(["ln", "-s", os.getcwd() + relative_name, filepath])
def should(message: str) -> bool:
return yes or ("n" not in input(f"{message} (Y/n) ").lower())
using_nix_cfgs = False
if IS_DARWIN:
using_nix_cfgs = should("Install nix-darwin system configuration")
if using_nix_cfgs:
link("/nix-environment", "~/.nix-environment")
print("Installed nix-environment")
if IS_DARWIN:
if should("Install alacritty config"):
link("/alacritty_macos.yml", "~/.config/alacritty/alacritty.yml")
else:
if should("Install alacritty config"):
link("/alacritty.yml", "~/.config/alacritty/alacritty.yml")
if should("Install archlinx specific configs?"):
link("/makepkg.conf", "/etc/makepkg.conf", sudo=True)
print("Installed makepkg.conf")
link("/makepkg.conf.gcc", "/etc/makepkg.conf.gcc", sudo=True)
print("Installed makepkg.conf.gcc")
link("/pacman.conf", "/etc/pacman.conf", sudo=True)
print("Installed pacman.conf")
if should("Install btop config?"):
install_packages(["btop"])
link("/btop.conf", "~/.config/btop/btop.conf")
print("Installed btop.conf")
if should("Install Haskell GHCi config?"):
mkdir("~/.ghc")
link("/ghci.conf", "~/.ghc/ghci.conf")
print("Installed GHCi config")
if (not using_nix_cfgs) and should("Install Git configs"):
link("/gitignore", "~/.config/git/ignore")
link("/gitignore", "~/.gitignore")
print("Installed global gitignore")
if should("Install mpd configs?"):
link("/mpd/mpd.conf", "~/.config/mpd/mpd.conf")
print("Installed mpd.conf")
link("/mpd/mpDris2.conf", "~/.config/mpDris2/mpDris2.conf")
print("Installed mpDris2.conf")
link("/mpd/ncmpcpp", "~/.ncmpcpp")
print("Installed ncmpcpp configs")
if should("Install neofetch config?"):
mkdir("~/.config/neofetch")
link("/neofetch.conf", "~/.config/neofetch/config.conf")
print("Installed neofetch.conf")
if should("Install Nix configs?"):
link("/nix", "~/.config/nix")
print("Installed nix config")
link("/nixpkgs", "~/.config/nixpkgs")
print("Installed nixpkgs configs and overlays")
if (not using_nix_cfgs) and should("Install nushell config?"):
mkdir("~/.config/nu")
link("/nushell.toml", "~/.config/nu/config.toml")
print("Installed nushell.toml")
if should("Install nvim configs?"):
install_packages(
[
"neovim-nightly",
"vim-plug",
"neovim-symlinks",
"nodejs",
"texlive-bin",
"latex-mk",
"ccls",
]
)
link("/nvim", "~/.config/nvim")
print("Installed nvim configs")
link("/pylintrc", "~/.pylintrc")
print("Installed pylintrc")
install_coc_plugins()
print("Installed coc.nvim plugins")
link("/ultisnips", "~/.config/coc/ultisnips")
print("Installed coc.nvim ultisnips")
if should("Install ptpython configs?"):
mkdir("~/.config/ptpython")
link("/ptpython_config.py", "~/.config/ptpython/config.py")
print("Installed ptpython.py")
mkdir("~/.config/python")
link("/pythonstartup.py", "~/.config/python/startup.py")
print("Installed pythonstartup.py")
if should("Install tmux config?"):
link("/tmux.conf", "~/.tmux.conf")
print("Installed tmux.conf")
if should("Install zsh configs?"):
install_packages(
[
"zsh",
"zsh-syntax-highlighting",
"zsh-autocomplete",
"pkgfile",
"starship-git",
]
)
mkdir("~/.zsh")
link("/zshrc", "~/.zshrc")
print("Installed zshrc")
link("/zsh-plugins", "~/.zsh/plugins")
print("Installed zsh plugins")
link("/functions.zsh", "~/.zsh/functions.zsh")
print("Installed functions.zsh")
link("/aliases.zsh", "~/.zsh/aliases.zsh")
print("Installed aliases.zsh")
if not using_nix_cfgs:
link("/starship.toml", "~/.config/starship.toml")
print("Installed starship.toml")
link("/atuin.toml", "~/.config/atuin/config.toml")
print("Installed atuin.toml")