mirror of
https://github.com/mitchell/dotfiles.git
synced 2026-08-10 08:09:35 +00:00
refactor(install_utils): convert to bash
This commit is contained in:
parent
4ddcc04e96
commit
11d574fae2
1 changed files with 81 additions and 85 deletions
166
install_utils
166
install_utils
|
|
@ -1,96 +1,92 @@
|
||||||
#!/usr/bin/env fish
|
#!/bin/bash
|
||||||
|
|
||||||
function log -a message
|
set -euo pipefail
|
||||||
echo \n"--- $message ---"\n
|
|
||||||
end
|
|
||||||
|
|
||||||
set -l distro
|
# Function to log messages
|
||||||
set -l uname (uname)
|
log() {
|
||||||
|
echo -e "\n--- $1 ---\n"
|
||||||
|
}
|
||||||
|
|
||||||
if test $uname = Darwin
|
distro=""
|
||||||
set distro mac
|
uname_val=$(uname)
|
||||||
else if test -f /etc/os-release
|
|
||||||
set distro (grep '^ID=' /etc/os-release | string replace 'ID=' '' | string trim -c '"')
|
if [ "$uname_val" = "Darwin" ]; then
|
||||||
|
distro="mac"
|
||||||
|
elif [ -f /etc/os-release ]; then
|
||||||
|
source /etc/os-release
|
||||||
|
distro=$ID
|
||||||
else
|
else
|
||||||
echo 'Your OS is unsupported. Supported: Arch, Debian, Fedora, Mac (Brew)'
|
echo 'Your OS is unsupported. Supported: Arch, Debian, Fedora, Mac (Brew)'
|
||||||
return 1
|
exit 1
|
||||||
end
|
fi
|
||||||
|
|
||||||
set -l base_pkgs \
|
# Base packages array
|
||||||
fish \
|
base_pkgs=(
|
||||||
git \
|
git
|
||||||
neovim \
|
neovim
|
||||||
tmux \
|
tmux
|
||||||
rsync \
|
rsync
|
||||||
curl \
|
curl
|
||||||
less \
|
less
|
||||||
fzf \
|
fzf
|
||||||
mosh \
|
mosh
|
||||||
lsd \
|
lsd
|
||||||
ripgrep \
|
ripgrep
|
||||||
bat \
|
bat
|
||||||
tree-sitter-cli \
|
tree-sitter-cli
|
||||||
nodejs \
|
zoxide
|
||||||
zoxide \
|
git-delta
|
||||||
git-delta \
|
stow
|
||||||
stow
|
)
|
||||||
|
|
||||||
set -l mac_pkgs \
|
# OS specific arrays
|
||||||
$base_pkgs \
|
mac_pkgs=("${base_pkgs[@]}" fd yazi)
|
||||||
fd \
|
arch_pkgs=("${base_pkgs[@]}" fd yazi ttf-nerd-fonts-symbols ttf-nerd-fonts-symbols-common ttf-nerd-fonts-symbols-mono)
|
||||||
yazi
|
debian_pkgs=("${base_pkgs[@]}" fd-find extrepo)
|
||||||
|
fedora_pkgs=("${base_pkgs[@]}" fd-find)
|
||||||
|
|
||||||
set -l arch_pkgs \
|
case "$distro" in
|
||||||
$base_pkgs \
|
mac)
|
||||||
fd \
|
log 'Installing packages with Homebrew'
|
||||||
yazi \
|
brew install "${mac_pkgs[@]}"
|
||||||
ttf-nerd-fonts-symbols \
|
;;
|
||||||
ttf-nerd-fonts-symbols-common \
|
arch)
|
||||||
ttf-nerd-fonts-symbols-mono
|
log 'Installing yay'
|
||||||
|
|
||||||
set -l debian_pkgs \
|
sudo pacman --sync --refresh --sysupgrade --noconfirm
|
||||||
$base_pkgs \
|
sudo pacman --sync --needed --noconfirm base-devel go bat
|
||||||
fd-find \
|
|
||||||
extrepo
|
|
||||||
|
|
||||||
set -l fedora_pkgs \
|
if [ ! -d "yay" ]; then
|
||||||
$base_pkgs \
|
git clone https://aur.archlinux.org/yay.git
|
||||||
fd-find
|
fi
|
||||||
|
|
||||||
switch $distro
|
cd yay
|
||||||
case mac
|
bat PKGBUILD
|
||||||
log 'Installing packages with Homebrew'
|
read -p 'Continue? (y/N): ' ready
|
||||||
brew install $mac_pkgs
|
if [[ "$ready" =~ ^[yY] ]]; then
|
||||||
case arch
|
makepkg --syncdeps --install --noconfirm
|
||||||
log 'Installing yay'
|
else
|
||||||
|
echo "Installation aborted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
|
||||||
sudo pacman --sync --refresh --sysupgrade --noconfirm
|
log 'Installing packages with yay'
|
||||||
and sudo pacman --sync --needed --noconfirm base-devel go bat
|
yay --sync --noconfirm "${arch_pkgs[@]}"
|
||||||
or return
|
;;
|
||||||
|
debian | ubuntu)
|
||||||
test -d yay
|
log 'Installing packages with APT'
|
||||||
or git clone https://aur.archlinux.org/yay.git
|
sudo apt-get --quiet --yes update
|
||||||
and cd yay
|
sudo apt-get --quiet --yes upgrade
|
||||||
and bat PKGBUILD
|
sudo apt-get --quiet --yes install "${debian_pkgs[@]}"
|
||||||
and read -P 'Continue? (y/N): ' -l ready
|
;;
|
||||||
and test "$ready" = y; or test "$ready" = Y
|
fedora | rhel | rocky | almalinux | centos)
|
||||||
and makepkg --syncdeps --install --noconfirm
|
log 'Installing packages with DNF'
|
||||||
and cd ..
|
sudo dnf upgrade --assumeyes
|
||||||
or return
|
sudo dnf install --assumeyes --skip-broken "${fedora_pkgs[@]}"
|
||||||
|
;;
|
||||||
log 'Installing packages with yay'
|
*)
|
||||||
|
echo 'Your OS is unsupported. Supported: Arch, Debian, Fedora, Mac (Brew)'
|
||||||
yay --sync --noconfirm $arch_pkgs
|
exit 1
|
||||||
case debian
|
;;
|
||||||
log 'Installing packages with APT'
|
esac
|
||||||
sudo apt-get --quiet --yes update
|
|
||||||
and sudo apt-get --quiet --yes upgrade
|
|
||||||
and sudo apt-get --quiet --yes install $debian_pkgs
|
|
||||||
case fedora
|
|
||||||
log 'Installing packages with DNF'
|
|
||||||
sudo dnf upgrade --assumeyes
|
|
||||||
and sudo dnf --assumeyes install $fedora_pkgs
|
|
||||||
case '*'
|
|
||||||
echo 'Your OS is unsupported. Supported: Arch, Debian, Fedora, Mac (Brew)'
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue