dotfiles/run_onchange_before_install_main_deps.sh.tmpl
2024-05-18 00:38:19 +03:00

171 lines
6.4 KiB
Bash

#!/usr/bin/env bash
BASE_PACKAGES="gnupg curl wget git gcc"
ACT_PACKAGES="ripgrep unzip htop fzf bat gawk jq nnn tmux mc nethogs ngrep mtr"
USER=$(whoami)
Green='\033[0;32m' # Green
NC='\033[0m' # No Color
cd ~
echo -e "
$Green###############################################################################
## ##
## Update caches and upgrade packages ##
## ##
###############################################################################$NC"
{{ if eq .chezmoi.os "darwin" -}}
if ! type brew; then
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew update
{{ else if eq .chezmoi.osRelease.id "fedora" -}}
sudo dnf update -y
{{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}}
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -o "Dpkg::Options::=--force-confold" -o "Dpkg::Options::=--force-confdef" upgrade -y --allow-downgrades --allow-remove-essential --allow-change-held-packages
sudo apt-get install software-properties-common -y
{{ else if eq .chezmoi.osRelease.id "arch" -}}
sudo pacman -Syu --noconfirm
{{ end -}}
echo -e "
$Green###############################################################################
## ##
## Install base packages ##
## ##
###############################################################################$NC"
{{ if eq .chezmoi.os "darwin" -}}
brew install -q $BASE_PACKAGES python difftastic
{{ else if eq .chezmoi.osRelease.id "fedora" -}}
sudo dnf install $BASE_PACKAGES difftastic kitty-terminfo util-linux-user python3-pip -y
{{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}}
sudo apt install $BASE_PACKAGES kitty-terminfo direnv python3-pip -y
{{ else if eq .chezmoi.osRelease.id "arch" -}}
sudo pacman -Sy --noconfirm $BASE_PACKAGES difftastic kitty-terminfo python3-pip
{{ end -}}
################################################################################
################################################################################
{{ if eq .chezmoi.os "linux" -}}
if ! type nix &> /dev/null
then
echo -e "
$Green###############################################################################
## ##
## Install nix packet manager (single user) ##
## ##
###############################################################################$NC"
bash <(curl -L https://nixos.org/nix/install) --no-daemon
. ~/.nix-profile/etc/profile.d/nix.sh
fi
################################################################################
################################################################################
{{ if eq .chezmoi.osRelease.id "debian" "ubuntu" -}}
echo -e "
$Green################################################################################
## ##
## Subscribe to PPA for fish, lazygit, neovim in ubuntu/debian ##
## ##
################################################################################$NC"
{{ if eq .chezmoi.osRelease.id "debian" -}}
## Setup fish repo in debian
VERS={{ .chezmoi.osRelease.versionID }}
echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_$VERS/ /" | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list
curl -fsSL "https://download.opensuse.org/repositories/shells:fish:release:3/Debian_$VERS/Release.key" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null
{{ else -}}
## Setup fish repo in ubuntu
sudo apt-add-repository ppa:fish-shell/release-3 -y
## Neovim ppa
sudo add-apt-repository ppa:neovim-ppa/unstable
{{ end -}}
sudo apt-get update
{{ end -}}
{{ end -}}
echo -e "
$Green###############################################################################
## ##
## Install neovim, fish, fisher, atuin, jump, and the rest of packages ##
## ##
###############################################################################$NC"
sleep 3
{{ if eq .chezmoi.os "darwin" -}}
brew install -q fish neovim $ACT_PACKAGES atuin jump fd sk dust lazygit
{{ else if eq .chezmoi.osRelease.id "fedora" -}}
sudo dnf install neovim fish $ACT_PACKAGES fd-find skim pam_ssh_agent_auth -y
nix-env -iA nixpkgs.atuin nixpkgs.jump nixpkgs.du-dust nixpkgs.lazygit
{{ else if eq .chezmoi.osRelease.id "arch" -}}
sudo pacman -Sy --noconfirm neovim fish atuin $ACT_PACKAGES fd skim lazygit
nix-env -iA nixpkgs.jump nixpkgs.du-dust
{{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}}
sudo apt install fish neovim $ACT_PACKAGES libpam-ssh-agent-auth -y
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
nix-env -iA nixpkgs.jump nixpkgs.skim nixpkgs.du-dust
if ! fish -c atuin &>/dev/null
then
bash <(curl https://raw.githubusercontent.com/ellie/atuin/main/install.sh)
fi
{{ end -}}
## Install shell-gpt
echo
echo -e "$Green""Installing shell-gpt$NC"
pip install shell-gpt -q --break-system-packages
## Install fisher plugin manager for fish, so that we may update in after plugin list sync by chezmoi
if ! fish -c fisher &>/dev/null
then
fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher"
fi
## Change default shell to fish
if [ "$(basename $SHELL)" != "fish" ]
then
echo
echo
echo "Changing shell to fish for user $USER"
sudo chsh -s $(command -v fish) $USER
fi