1
0
chezmoi/home/.chezmoiscripts/run_onchange_after_20-config-zim.sh.tmpl

83 lines
1.6 KiB
Cheetah
Raw Normal View History

2024-02-28 20:38:45 +00:00
#!/usr/bin/env bash
2024-03-01 10:26:26 +00:00
# Logging function
log() {
2024-03-01 10:47:05 +00:00
printf "$(tput setaf 4)$(tput bold)>>>>> %s <<<<<$(tput sgr0)\n" "$1"
}
inf() {
2024-03-01 10:51:03 +00:00
printf "$(tput sgr 0 1)$(tput setaf 2)%s$(tput sgr0)\n" "$1"
2024-03-01 10:26:26 +00:00
}
2024-02-28 20:38:45 +00:00
2024-03-01 10:37:17 +00:00
# Environment variables
2024-03-01 10:26:26 +00:00
ZIMDIR=${HOME}/.zim:
2024-02-28 20:38:45 +00:00
2024-03-01 10:26:26 +00:00
# Packages to install
2024-02-28 20:38:45 +00:00
packages=(
starship
zsh
)
### Install Zsh ###
2024-03-01 10:26:26 +00:00
log ">>>>> Begin Zsh installation <<<<<"
2024-02-28 20:38:45 +00:00
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
2024-03-01 10:47:05 +00:00
## Update system
inf "updating system..."
yay -Syu --noconfirm
2024-02-28 20:38:45 +00:00
## install packages
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
2024-03-01 10:47:05 +00:00
inf "installing ${package}..."
2024-02-28 20:38:45 +00:00
yay -S --noconfirm $package
fi
done
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
DEBIAN_FRONTEND=noninteractive
2024-03-01 10:47:05 +00:00
## Update system
inf "updating system..."
{{- if ne .chezmoi.username "root" }}
sudo -E apt update
sudo -E apt upgrade --yes
{{- else }}
apt update
apt upgrade --yes
{{- end}}
2024-02-28 20:38:45 +00:00
packages=(${packages[@]//starship/})
## install packages
for package in ${packages[@]}; do
2024-03-01 10:47:05 +00:00
inf "installing ${package}..."
2024-02-28 20:38:45 +00:00
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing $package
{{- else }}
apt-get install --yes --no-install-recommends --ignore-missing $package
{{- end }}
done
2024-03-01 10:47:05 +00:00
inf "installing starship..."
2024-02-28 20:38:45 +00:00
mist install starship-bin
{{- end }}
2024-03-01 10:26:26 +00:00
log ">>>>> Finish Zsh installation <<<<<"
2024-02-28 20:38:45 +00:00
### Config Zsh ###
2024-03-01 10:26:26 +00:00
log ">>>>> Installing Zim Framework <<<<<"
2024-02-28 20:38:45 +00:00
$(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q"
2024-03-01 10:26:26 +00:00
log ">>>>> Finish zsh installation <<<<<"
2024-02-28 20:38:45 +00:00