dotfiles/install.sh

72 lines
2 KiB
Bash
Executable file

#!/bin/sh
cd -P -- "$(readlink -e "$(dirname "$0")")" || exit 255
echo "=> Checking dependencies..."
command -v stow >/dev/null 2>&1 || { echo "Please install GNU Stow!"; exit 1; }
sleep 0.5
echo "=> Determining OS..."
if [ "$(. /etc/os-release && echo $ID)" = "artix" ]; then
set -- "alacritty" "git" "mako" "nvim" "scripts" "sway" "swaylock" "swaynag" "waybar" "zsh"
INSTALL="sudo pacman -S"
elif [ "$(. /etc/os-release && echo $ID)" = "fedora" ]; then
set -- "alacritty" "nvim" "scripts" "zsh"
INSTALL="sudo dnf install"
else
echo "OS not supported!"
exit 1
fi
sleep 0.5
echo "=> Installing dotfile packages..."
for pkg in "$@"; do
sleep 0.1
echo " -> Stowing $pkg"
# Symlink only the individual files instead of the entire directory
[ "$pkg" = "zsh" ] && ZSH=1 && mkdir -p "$HOME/.config/$pkg"
[ "$pkg" = "scripts" ] && DASH=1 && mkdir -p "$HOME/.local/bin"
[ "$pkg" = "nvim" ] && NVIM=1
LC_ALL="C" stow -t "$HOME" --ignore="README.md" "$pkg"
done
if [ -n "$ZSH" ]; then
if ! grep -q "$(id -nu).*/zsh$" /etc/passwd; then
command -v zsh >/dev/null 2>&1 || sleep 0.5 &&
echo "=> Installing Zsh" && $INSTALL zsh
sleep 0.5
chsh -s /bin/zsh
fi
sleep 0.5
echo "=> Initializing Zsh"
echo " :: Please run the following command from Zsh:"
echo " $ fast-theme ~/.config/zsh/fast-theme.ini"
fi
if [ -n "$NVIM" ] && [ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/autoload/plug.vim" ]; then
command -v nvim >/dev/null 2>&1 || sleep 0.5 &&
echo "=> Installing Neovim" && $INSTALL nvim
sleep 0.5
echo "=> Installing vim-plug and plugins for Neovim"
curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/autoload/plug.vim" --create-dirs \
"https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
nvim --headless +PlugInstall +qa
fi
if [ -n "$DASH" ] && ! command -v dash >/dev/null 2>&1; then
sleep 0.5
echo "=> Installing Dash"
$INSTALL dash
fi
sleep 0.5
echo "=> Done!"