-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_packages-asdf.sh.tmpl
executable file
·50 lines (43 loc) · 1.62 KB
/
02_packages-asdf.sh.tmpl
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
#!/bin/bash
{{ $workMode := eq (output "sysctl" "-n" "hw.model" | trim) "MacBookPro16,4" }}
asdf update >/dev/null 2>&1 || true && echo "~ asdf has been updated"
echo "~ asdf (installations)"
# TODO: Move some of this into Chezmoi templates for readability
{{ range sortAlpha (keys .asdf) -}}
{{ $version := get $.asdf . }}
{{- if eq (kindOf $version) "map" }}
{{ $env := "home" }}
{{- if $workMode }}
{{ $env = "work" }}
{{ end -}}
{{ $version = get $version $env }}
{{ end -}}
{{ if ne (kindOf $version) "invalid" }}
# You can skip a plugin by setting it to null for an environment
# which is parsed internally as "invalid" weirdly
# I use this to cut down the install time by skipping plugins
# I only use at home and vice versa
asdf plugin-add {{ . }} >/dev/null 2>&1 || true
asdf install {{ . }} {{ $version }} >/dev/null 2>&1 || true && echo "~~ {{ . }} {{ $version }} is installed"
asdf global {{ . }} {{ $version }} >/dev/null 2>&1 || true
{{ end -}}
{{ end -}}
# -- Globally installed packages -- #
# TODO: Make a template for getting environment
{{ range sortAlpha (keys .libraries) -}}
echo "~~ {{ . }} libraries"
{{ $langLibMap := (get $.libraries .) }}
{{ $installer := $langLibMap.installer }}
{{ $libs := $langLibMap.global }}
{{ $env := "home" }}
{{- if $workMode }}
{{ $env = "work" }}
{{ end -}}
{{ $envLibs := get $langLibMap $env }}
{{- if $envLibs }}
{{ $libs = concat $libs $envLibs }}
{{ end -}}
{{ range sortAlpha $libs -}}
{{ $installer }} {{ . }} >/dev/null 2>&1 || true && echo "~~~ {{ . }} is installed"
{{ end -}}
{{ end -}}