-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.nu
220 lines (147 loc) · 4.54 KB
/
install.nu
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
#!/usr/bin/env nu
rm -rf .tmp
mkdir .tmp;
let cargo_bin_path = ($nu.home-path | path join .cargo/bin);
# before running this script, make sure you installed the following:
# git, github cli, rustup (rust, rustup, cargo), wezterm, neovim
# then open wezterm and run
# `cargo install cargo-binstall ; cargo binstall nu`
# TODO: backup config files to .cache/np/bak/
# TODO: lock-file
# TODO: clean local data (nvim-data, .local/share/nushell, .local/share/nvim, .cache/nvim ..)
# TODO: cleanup tmp (.cargo/bin, .cache/nu, .cache/np ..)
def --env mv_cfg [] {
print "fetching latest toolkit";
curl https://raw.githubusercontent.com/nushell/nushell/main/toolkit.nu | save -f ./config/nushell/toolkit.nu;
print "moving config files";
let nu_config_dir = if $nu.os-info.name == "windows" {
($nu.home-path | path join "AppData/Roaming")
} else {
($nu.home-path | path join ".config/nushell")
}
let nvim_config_dir = if $nu.os-info.name == "windows" {
($nu.home-path | path join "AppData/Local/nvim")
} else {
($nu.home-path | path join ".config/nvim")
}
cp ./config/nushell $nu_config_dir -r;
cp ./config/.wezterm.lua $"($nu.home-path)/.wezterm.lua";
# nvim cfg
git clone $"https://github.com/whysosergious/pocketnvim.np" .tmp/nvim;
cp .tmp/nvim ($nu.home-path | path join AppData/Local/nvim) -r
print "finished moving config files";
}
def --env install_packages [] {
print "installing packages";
let packages = [
# "nu",
# "zoxide",
# "starship",
# "broot",
# "btm",
# "jaq",
# "ripgrep",
# "ast-grep",
## group: [ watch -> act ]
# "checkexec",
# "systemfd",
# "watchexec-cli",
## - 🌟🌟🌟
# "bun",
# "deno",
# __________________
# #
#! - "carapace" - !# - https://github.com/carapace-sh/carapace-bin/releases
# #
# - -------------- -
# #
#! - "fzf" - !# - installed through nvim
# #
# ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
]
# install packages
$packages | each { |pkg|
print $"installing ($pkg)";
cargo-binstall $pkg -y -v --force --json-output
}
}
def --env build_nu_plugins [] {
let plugins = [
nu_plugin_inc,
nu_plugin_gstat,
nu_plugin_query,
nu_plugin_example,
nu_plugin_custom_values,
nu_plugin_formats,
]
## clone nushell repo
rm -rf .tmp;
git clone $"https://github.com/nushell/nushell.git" .tmp/nushell;
cargo install --path .tmp/nushell --all-features;
if (pwd | path join ./tmp/nvim | path exists) == false {
}
let installed_plugins = (ls $cargo_bin_path | where name =~ "nu_plugin")
print $installed_plugins;
$installed_plugins | where modified < (date now | $in - 1day) | each { |plugin|
print $'(char nl)Installing ($plugin | get name)';
print '----------------------------';
cargo install --path $".tmp/nushell/crates/($plugin | get name)" --locked;
}
# add nushell plugins
$installed_plugins | each { |p|
try {
print $"> plugin add ($p | get name)";
plugin add ($p | get name);
} catch { |err|
print -e $"(ansi rb)Failed to add ($p):\n($err.msg)(ansi reset)";
}
}
print $"\n(ansi gb)installation done, restart your terminal(ansi reset)"
}
# git_bin_or_build "*.np"
def git_bin_or_build [name: string] {
let local_repo = (pwd | path join $".tmp/($name)");
if (pwd | path join $local_repo | path exists) == false {
git clone ($'http://github.com/($name)') $local_repo;
}
# let realease_path = ($local_repo | path join $"releases/($nu.os-info.name)");
# print $realease_path;
# let bin_release = (ls $realease_path | where name =~ $name | get name);
# print $bin_release;
# if ($bin_release | path exists) {
# cp $bin_release $cargo_bin_path;
# }
cargo install --path $local_repo
print "done --------------"
}
def custom_bins [] {
## git clone https://github.com/whysosergious/pocketnvim.np .tmp/nvim
let np_modules = [
"whysosergious/run-with-monitor.np",
"whysosergious/shelly-jogger.np",
]
$np_modules | each { |module|
git_bin_or_build $module
}
print "finished installing custom bins";
}
# main
def --env main [--cfg, --pkg, --nu-plg, --np-bin] { # nui - nu install
let all = $cfg == false and $pkg == false and $nu_plg == false and $np_bin == false;
## if (ls | where ) {
## $env.CARGO_BIN_PATH = ($nu.home-path | path join ~/.cargo/bin);
## }
# install custom binaries
if $all or $np_bin {
custom_bins
}
if $all or $cfg {
mv_cfg
}
if $all or $pkg {
install_packages
}
if $all or $nu_plg {
build_nu_plugins
}
}