1
0
This commit is contained in:
Jeff Lance 2024-02-28 21:38:45 +01:00
parent f39c05693b
commit 579c84dd5d
10 changed files with 500 additions and 131 deletions

View File

@ -0,0 +1,118 @@
#
# common.lib
#
# Common libray for local scripts
#
# CONSTANT VARIABLES
RESET=$(tput sgr0)
F_BOLD=$(tput bold)
F_UNDL=$(tput sgr 0 1)
C_BLK=$(tput setaf 0)
C_RED=$(tput setaf 1)
C_GRE=$(tput setaf 2)
C_YEL=$(tput setaf 3)
C_BLU=$(tput setaf 4)
C_MAG=$(tput setaf 5)
C_CYA=$(tput setaf 6)
C_WHI=$(tput setaf 7)
# common errors will cause the script to
# immediately fail, explicitly and loudly.
set -euxo pipefail
# function used to display colored message
cecho () {
declare -A colors;
declare -A formats;
colors=(\
['black']=$(tput setaf 0)\
['red']=$(tput setaf 1)\
['green']=$(tput setaf 2)\
['yellow']=$(tput setaf 3)\
['blue']=$(tput setaf 4)\
['magenta']=$(tput setaf 5)\
['cyan']=$(tput setaf 6)\
['white']=$(tput setaf 7)\
);
formats=(\
['default']=$(tput sgr0)\
['inverse']=$(tput smso)\
['bold']=$(tput bold)\
);
local defaultMSG="No message passed.";
local defaultColor="white";
local defaultFormat="default";
local defaultNewLine=true;
while [[ $# -gt 1 ]];
do
key="$1";
case $key in
-c|--color)
color="$2";
shift;
;;
-f|--format)
format="$2";
shift;
;;
-n|--noline)
newLine=false;
;;
*)
# unknown option
;;
esac
shift;
done
color=${color:-$defaultColor}; # Defaults to default color, if not specified.
format=${format:-$defaultFormat}; # Defaults to default color, if not specified.
newLine=${newLine:-$defaultNewLine};
message=${1:-$defaultMSG}; # Defaults to default message.
echo -en "${formats[$format]}${colors[$color]}";
echo -en "$message";
if [ "$newLine" = true ] ; then
echo;
fi
tput sgr0; # Reset text attributes to normal without clearing screen.
return;
}
info1() {
cecho -c 'blue' -f 'bold' "$@";
}
info2() {
cecho -c 'cyan' -f 'bold' "$@";
}
success() {
cecho -c 'green' "$@";
}
error() {
cecho -c 'red' -f 'bold' "$@";
}
warning() {
cecho -c 'yellow' "$@";
}
/* vim: set filetype=bash : */

View File

@ -1,24 +1,25 @@
#!/usr/bin/env bash
set -euxo pipefail
# Load local library
. ./common.lib
packages=(
curl
direnv
ranger
starship
tmux
trash-cli
unzip
wget
zip
zoxide
zsh
)
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
echo -e "\033[0;32m>>>>> Begin Arch/Manjaro Linux packages installation <<<<<\033[0m"
info1 ">>>>> Begin Arch/Manjaro Linux packages installation <<<<<"
## Update system
{{- if ne .chezmoi.username "root" }}
@ -29,7 +30,7 @@ packages=(
## Install yay
if [ ! $(command -v yay) ]; then
echo "installing yay"
info2 "installing yay"
{{- if ne .chezmoi.username "root" }}
sudo pacman -S --needed --noconfirm git base-devel
{{- else}}
@ -44,23 +45,18 @@ packages=(
## Install packages
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
echo "installing ${package}..."
{{- if ne .chezmoi.username "root" }}
sudo yay -S --noconfirm $package
{{- else }}
info2 "installing ${package}..."
yay -S --noconfirm $package
{{- end }}
fi
done
echo -e "\033[0;32m>>>>> Finish Arch/Manjaro Linux packages installation <<<<<\033[0m"
info1 ">>>>> Finish Arch/Manjaro Linux packages installation <<<<<"
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
echo -e "\033[0;32m>>>>> Begin Debian/Ubuntu Linux packages installation <<<<<\033[0m"
info1 ">>>>> Begin Debian/Ubuntu Linux packages installation <<<<<"
export DEBIAN_FRONTEND=noninteractive
DEBIAN_FRONTEND=noninteractive
## Add repositories and update system
{{- if ne .chezmoi.username "root" }}
@ -95,13 +91,12 @@ packages=(
doxygen
libtool
libtool-bin
mist
ninja-build
pkg-config
)
for package in ${packages[@]}; do
echo "installing ${package}..."
info2 "installing ${package}..."
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing $package
@ -110,9 +105,7 @@ packages=(
{{- end }}
done
mist install starship-bin
echo -e "\033[0;32m>>>>> Finish Debian/Ubuntu Linux packages installation <<<<<\033[0m"
info1 ">>>>> Finish Debian/Ubuntu Linux packages installation <<<<<"
{{- end }}

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
ZIMDIR=${HOME}/.zim
echo -e "\033[0;32m>>>>> Installing Zim Framework <<<<<\033[0m"
$(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q"
echo -e "\033[0;32m>>>>> Finish zsh installation <<<<<\033[0m"
exit 0

View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Load local library
. ./common.lib
ZIMDIR=${HOME}/.zim
packages=(
starship
zsh
)
### Install Zsh ###
info1 ">>>>> Begin Zsh installation <<<<<"
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
## install packages
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
info2 "installing ${package}..."
yay -S --noconfirm $package
fi
done
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
DEBIAN_FRONTEND=noninteractive
packages=(${packages[@]//starship/})
## install packages
for package in ${packages[@]}; do
info2 "installing ${package}..."
{{- 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
info2 "installing starship..."
mist install starship-bin
{{- end }}
info1 ">>>>> Finish Zsh installation <<<<<"
### Config Zsh ###
info1 ">>>>> Installing Zim Framework <<<<<"
$(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q"
info1 ">>>>> Finish zsh installation <<<<<"

View File

@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -euxo pipefail
# Load local library
. ./common.lib
packages=(
cargo
@ -12,33 +15,26 @@ packages=(
ripgrep
)
echo -e "\033[0;32m>>>>> Begin LVim installation <<<<<\033[0m"
info1 ">>>>> Begin LVim installation <<<<<"
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
## Update system
{{- if ne .chezmoi.username "root" }}
sudo pacman -Syu --noconfirm
{{- else }}
pacman -Syu --noconfirm
{{- end}}
yay -Syu --noconfirm
## Install packages
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
echo "installing packages"
{{- if ne .chezmoi.username "root" }}
sudo yay -S --noconfirm $package
{{- else }}
info2 "installing ${package}..."
yay -S --noconfirm $package
{{- end }}
fi
done
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
export DEBIAN_FRONTEND=noninteractive
DEBIAN_FRONTEND=noninteractive
## Update system
{{- if ne .chezmoi.username "root" }}
@ -55,7 +51,7 @@ echo -e "\033[0;32m>>>>> Begin LVim installation <<<<<\033[0m"
packages=(${packages[@]//neovim/})
for package in ${packages[@]}; do
echo "installing ${package}..."
info2 "installing ${package}..."
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing $package
@ -64,10 +60,14 @@ echo -e "\033[0;32m>>>>> Begin LVim installation <<<<<\033[0m"
{{- end }}
done
info2 "installing neovim..."
mist install neovim
{{- end }}
info2 "installing lvim..."
LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s 'https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh')
echo -e "\033[0;32m>>>>> Finish LVim installation <<<<<\033[0m"
info1 ">>>>> Finish LVim installation <<<<<"

View File

@ -0,0 +1,118 @@
#
# common.lib
#
# Common libray for local scripts
#
# CONSTANT VARIABLES
RESET=$(tput sgr0)
F_BOLD=$(tput bold)
F_UNDL=$(tput sgr 0 1)
C_BLK=$(tput setaf 0)
C_RED=$(tput setaf 1)
C_GRE=$(tput setaf 2)
C_YEL=$(tput setaf 3)
C_BLU=$(tput setaf 4)
C_MAG=$(tput setaf 5)
C_CYA=$(tput setaf 6)
C_WHI=$(tput setaf 7)
# common errors will cause the script to
# immediately fail, explicitly and loudly.
set -euxo pipefail
# function used to display colored message
cecho () {
declare -A colors;
declare -A formats;
colors=(\
['black']=$(tput setaf 0)\
['red']=$(tput setaf 1)\
['green']=$(tput setaf 2)\
['yellow']=$(tput setaf 3)\
['blue']=$(tput setaf 4)\
['magenta']=$(tput setaf 5)\
['cyan']=$(tput setaf 6)\
['white']=$(tput setaf 7)\
);
formats=(\
['default']=$(tput sgr0)\
['inverse']=$(tput smso)\
['bold']=$(tput bold)\
);
local defaultMSG="No message passed.";
local defaultColor="white";
local defaultFormat="default";
local defaultNewLine=true;
while [[ $# -gt 1 ]];
do
key="$1";
case $key in
-c|--color)
color="$2";
shift;
;;
-f|--format)
format="$2";
shift;
;;
-n|--noline)
newLine=false;
;;
*)
# unknown option
;;
esac
shift;
done
color=${color:-$defaultColor}; # Defaults to default color, if not specified.
format=${format:-$defaultFormat}; # Defaults to default color, if not specified.
newLine=${newLine:-$defaultNewLine};
message=${1:-$defaultMSG}; # Defaults to default message.
echo -en "${formats[$format]}${colors[$color]}";
echo -en "$message";
if [ "$newLine" = true ] ; then
echo;
fi
tput sgr0; # Reset text attributes to normal without clearing screen.
return;
}
info1() {
cecho -c 'blue' -f 'bold' "$@";
}
info2() {
cecho -c 'cyan' -f 'bold' "$@";
}
success() {
cecho -c 'green' "$@";
}
error() {
cecho -c 'red' -f 'bold' "$@";
}
warning() {
cecho -c 'yellow' "$@";
}
/* vim: set filetype=bash : */

View File

@ -1,10 +1,25 @@
#!/usr/bin/env bash
set -euxo pipefail
# Load local library
. ./common.lib
packages=(
curl
direnv
ranger
tmux
trash-cli
unzip
wget
zip
zoxide
)
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
echo -e "\033[0;32m>>>>> Begin Arch/Manjaro Linux packages installation <<<<<\033[0m"
info1 ">>>>> Begin Arch/Manjaro Linux packages installation <<<<<"
## Update system
{{- if ne .chezmoi.username "root" }}
@ -15,16 +30,12 @@ set -euxo pipefail
## Install yay
if [ ! $(command -v yay) ]; then
echo "installing yay"
{{ range .packages_base.archlinux.pacman }}
info2 "installing yay"
{{- if ne .chezmoi.username "root" }}
sudo pacman -S --needed --noconfirm {{ . | quote }}
sudo pacman -S --needed --noconfirm git base-devel
{{- else}}
pacman -S --needed --noconfirm {{ . | quote }}
pacman -S --needed --noconfirm git base-devel
{{- end }}
{{ end }}
git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay
makepkg -si --noconfirm
@ -32,18 +43,20 @@ set -euxo pipefail
fi
## Install packages
{{ range .packages_base.archlinux.yay -}}
echo "installing {{ . | quote }}..."
yay -S --needed --noconfirm {{ . | quote }}
{{ end -}}
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
info2 "installing ${package}..."
yay -S --noconfirm $package
fi
done
echo -e "\033[0;32m>>>>> Finish Arch/Manjaro Linux packages installation <<<<<\033[0m"
info1 ">>>>> Finish Arch/Manjaro Linux packages installation <<<<<"
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
echo -e "\033[0;32m>>>>> Begin Debian/Ubuntu Linux packages installation <<<<<\033[0m"
info1 ">>>>> Begin Debian/Ubuntu Linux packages installation <<<<<"
export DEBIAN_FRONTEND=noninteractive
DEBIAN_FRONTEND=noninteractive
## Add repositories and update system
{{- if ne .chezmoi.username "root" }}
@ -69,16 +82,30 @@ set -euxo pipefail
mist update
## Install packages
{{ range .packages_base.debian.apt -}}
echo "installing {{ . | quote }}..."
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{- else}}
apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{- end }}
{{ end -}}
packages=(${packages[@]//starship/makedeb})
packages+=(
apt-utils
autoconf
automake
cmake
doxygen
libtool
libtool-bin
ninja-build
pkg-config
)
echo -e "\033[0;32m>>>>> Finish Debian/Ubuntu Linux packages installation <<<<<\033[0m"
for package in ${packages[@]}; do
info2 "installing ${package}..."
{{- 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
info1 ">>>>> Finish Debian/Ubuntu Linux packages installation <<<<<"
{{- end }}

View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Load local library
. ./common.lib
ZIMDIR=${HOME}/.zim
packages=(
starship
zsh
)
### Install Zsh ###
info1 ">>>>> Begin Zsh installation <<<<<"
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
## install packages
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
info2 "installing ${package}..."
yay -S --noconfirm $package
fi
done
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
DEBIAN_FRONTEND=noninteractive
packages=(${packages[@]//starship/})
## install packages
for package in ${packages[@]}; do
info2 "installing ${package}..."
{{- 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
info2 "installing starship..."
mist install starship-bin
{{- end }}
info1 ">>>>> Finish Zsh installation <<<<<"
### Config Zsh ###
info1 ">>>>> Installing Zim Framework <<<<<"
$(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q"
info1 ">>>>> Finish zsh installation <<<<<"

View File

@ -1,35 +0,0 @@
#!/usr/bin/env bash
set -euxo pipefail
ZIMDIR=${HOME}/.zim
echo -e "\033[0;32m>>>>> Begin Zsh installation <<<<<\033[0m"
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
## Install packages
{{ range .packages_shell.archlinux.yay -}}
echo "installing {{ . | quote }}..."
yay -S --needed --noconfirm {{ . | quote }}
{{ end -}}
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
## Install packages
{{ range .packages_shell.debian.mist -}}
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{- else}}
apt-get install --yes --no-install-recommends --ignore-missing
{{- end }}
{{ end -}}
{{- end }}
echo -e "\033[0;32m>>>>> Installing Zim Framework <<<<<\033[0m"
$(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q"
echo -e "\033[0;32m>>>>> Finish Zim Framework <<<<<\033[0m"
echo -e "\033[0;32m>>>>> Finish zsh installation <<<<<\033[0m"

View File

@ -1,38 +1,73 @@
#!/usr/bin/env bash
set -euxo pipefail
# Load local library
. ./common.lib
echo -e "\033[0;32m>>>>> Begin LVim installation <<<<<\033[0m"
packages=(
cargo
go
neovim
npm
python-pip
python-pynvim
ripgrep
)
info1 ">>>>> Begin LVim installation <<<<<"
{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}
## Update system
yay -Syu --noconfirm
## Install packages
{{ range .packages_lvim.archlinux.yay -}}
echo "installing {{ . | quote }}..."
yay -S --needed --noconfirm {{ . | quote }}
{{ end -}}
for package in ${packages[@]}; do
if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then
info2 "installing ${package}..."
yay -S --noconfirm $package
fi
done
{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}
export DEBIAN_FRONTEND=noninteractive
DEBIAN_FRONTEND=noninteractive
## Update system
{{- if ne .chezmoi.username "root" }}
sudo -E apt update
sudo -E apt upgrade --yes
{{- else }}
apt update
apt upgrade --yes
{{- end}}
## Install packages
{{ range .packages_base.debian.apt -}}
echo "installing {{ . | quote }}..."
{{- if ne .chezmoi.username "root" }}
sudo -E apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{- else}}
apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{- end }}
{{ end -}}
packages=(${packages[@]//go/golang})
packages=(${packages[@]//python/python3})
packages=(${packages[@]//neovim/})
{{ range .packages_base.debian.mist -}}
echo "installing {{ . | quote }}..."
apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
{{ end -}}
for package in ${packages[@]}; do
info2 "installing ${package}..."
{{- 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
info2 "installing neovim..."
mist install neovim
{{- end }}
info2 "installing lvim..."
LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s 'https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh')
echo -e "\033[0;32m>>>>> Finish LVim installation <<<<<\033[0m"
info1 ">>>>> Finish LVim installation <<<<<"