dotfiles/install.sh

77 lines
2.3 KiB
Bash
Raw Normal View History

2022-12-30 18:46:00 +00:00
#!/bin/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 [ "$(. /etc/os-release && echo $ID)" = "artix" ]; then
2023-02-08 16:39:04 +00:00
set -- "alacritty" "git" "mako" "nvim" "scripts" "sway" "swaylock" "swaynag" "waybar" "zsh"
2023-01-29 18:38:42 +00:00
INSTALL="sudo pacman -S"
elif [ "$(. /etc/os-release && echo $ID)" = "fedora" ]; then
set -- "alacritty" "nvim" "scripts" "zsh"
INSTALL="sudo dnf install"
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
2023-05-11 18:03:49 +00:00
[ "$pkg" = "nvim" ] && NVIM=1 && mkdir -p "$HOME/.config/$pkg"
2022-06-18 20:34:04 +00:00
[ "$pkg" = "scripts" ] && DASH=1 && mkdir -p "$HOME/.local/bin"
2023-05-11 18:03:49 +00:00
[ "$pkg" = "zsh" ] && ZSH=1 && mkdir -p "$HOME/.config/$pkg"
2022-03-05 19:51:07 +00:00
2022-11-12 16:07:17 +00:00
LC_ALL="C" stow -t "$HOME" --ignore="README.md" "$pkg"
2022-03-05 19:51:07 +00:00
done
2023-05-11 18:03:49 +00:00
if [ -n "$NVIM" ] && [ ! -d "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/pack/packer/start/packer.nvim" ]; then
command -v nvim >/dev/null 2>&1 ||
{ sleep 0.5;
echo "=> Installing Neovim";
$INSTALL nvim; }
sleep 0.5
echo "=> Installing packer for Neovim"
git clone --quiet --depth 1 "https://github.com/wbthomason/packer.nvim" \
"${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/pack/packer/start/packer.nvim"
echo " :: The LSP servers will be installed automatically when you open a file in Neovim."
echo " :: Please run the following Normal mode command in Neovim to install the plugins:"
echo " :PackerSync"
fi
if [ -n "$DASH" ] && ! command -v dash >/dev/null 2>&1; then
sleep 0.5
echo "=> Installing Dash"
$INSTALL dash
fi
2022-06-18 20:34:04 +00:00
if [ -n "$ZSH" ]; then
if ! grep -q "$(id -nu).*/zsh$" /etc/passwd; then
2023-05-11 18:03:49 +00:00
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:"
2023-05-11 18:03:49 +00:00
echo " $ fast-theme ~/.config/zsh/fast-theme.ini"
2022-06-18 20:34:04 +00:00
fi
2022-03-05 19:51:07 +00:00
sleep 0.5
echo "=> Done!"