dotfiles/install.sh

76 lines
2.1 KiB
Bash
Raw Normal View History

2022-03-06 15:22:37 +00:00
#!/usr/bin/env sh
2022-03-05 19:51:07 +00:00
2022-04-27 13:50:13 +00:00
cd -P -- "$(readlink -e "$(dirname "$0")")" || exit 255
echo "=> Checking dependencies..."
2022-04-27 13:50:13 +00:00
command -v stow >/dev/null 2>&1 || { echo "Please install GNU Stow!"; exit 1; }
sleep 0.5
2022-03-05 19:51:07 +00:00
echo "=> Determining OS..."
if [ "$(lsb_release -si)" = "Fedora" ]; then
2022-06-06 10:26:40 +00:00
set -- "alacritty" "nvim" "scripts" "zsh"
2022-05-24 16:17:38 +00:00
INSTALL="pkg install"
2022-03-05 19:51:07 +00:00
elif [ "$(lsb_release -si)" = "Debian" ] || [ "$(lsb_release -si)" = "Ubuntu" ]; then
set -- "scripts" "zsh"
2022-05-24 16:17:38 +00:00
INSTALL="sudo apt install"
2022-03-05 19:51:07 +00:00
elif [ "$(lsb_release -si)" = "Artix" ]; then
set -- "alacritty" "mako" "nvim" "scripts" "sway" "swaylock" "swaynag" "waybar" "zsh"
INSTALL="doas pacman -S"
2022-03-05 19:51:07 +00:00
else
echo "OS not supported!"
2022-05-22 16:08:26 +00:00
exit 1
2022-03-05 19:51:07 +00:00
fi
sleep 0.5
echo "=> Installing dotfile packages..."
for pkg in "$@"; do
sleep 0.1
echo " -> Stowing $pkg"
2022-05-22 16:08:26 +00:00
# Symlink only the individual files instead of the entire directory
2022-06-18 20:34:04 +00:00
[ "$pkg" = "zsh" ] && ZSH=1 && mkdir -p "$HOME/.config/$pkg"
[ "$pkg" = "scripts" ] && DASH=1 && mkdir -p "$HOME/.local/bin"
2022-05-24 16:17:38 +00:00
[ "$pkg" = "nvim" ] && NVIM=1
2022-03-05 19:51:07 +00:00
stow -t "$HOME" --ignore="README.md" "$pkg"
done
2022-06-18 20:34:04 +00:00
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
2022-06-18 20:34:04 +00:00
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"
2022-06-18 20:34:04 +00:00
fi
2022-06-22 15:11:07 +00:00
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
2022-06-18 20:34:04 +00:00
2022-05-24 16:17:38 +00:00
sleep 0.5
echo "=> Installing vim-plug and plugins for Neovim"
2022-06-18 20:34:04 +00:00
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"
2022-05-24 16:17:38 +00:00
nvim --headless +PlugInstall +qa
fi
2022-06-18 20:34:04 +00:00
if [ -n "$DASH" ] && ! command -v dash >/dev/null 2>&1; then
sleep 0.5
echo "=> Installing Dash"
$INSTALL dash
fi
2022-03-05 19:51:07 +00:00
sleep 0.5
echo "=> Done!"
2022-06-18 20:34:04 +00:00