Files
dotfiles/dots
T

85 lines
2.0 KiB
Bash
Raw Normal View History

2025-09-24 16:42:00 +01:00
#!/bin/sh
set -e
2025-09-24 23:03:16 +01:00
pushd "$(dirname $0)" > /dev/null
2025-09-25 16:30:14 +01:00
Install() {
2025-09-24 23:03:16 +01:00
# Installs current dotfiles onto the system
#
echo "[Info] :: Installing dotfiles into $1"
[[ ! -d "$1" ]] && mkdir -p "$1"
2025-09-25 18:08:46 +01:00
cp "bashrc" "$1/.bashrc"
cp "bash_profile" "$1/.bash_profile"
cp "bash_aliases" "$1/.bash_aliases"
2025-09-25 21:01:22 +01:00
mkdir -p "$1/.config"
cp -r "config/nvim" "$1/.config"
cp "config/starship.toml" "$1/.config"
2025-09-29 17:44:50 +01:00
sed -i "s/#$HOSTNAME //" "$1/.config/starship.toml"
2025-09-25 21:01:22 +01:00
# Graphical setups
#
case $HOSTNAME in
kanto|tokyo)
mkdir -p "$1/.config/sway"
2025-09-26 22:33:19 +01:00
mkdir -p "$1/.config/swaylock"
mkdir -p "$1/.config/foot"
2025-09-25 21:01:22 +01:00
2025-09-29 17:44:50 +01:00
cp "config/sway/$HOSTNAME.sway" "$1/.config/sway/config"
cp "config/swaylock/config" "$1/.config/swaylock"
cp "config/foot/foot.ini" "$1/.config/foot/foot.ini"
cp -r "config/rofi" "$1/.config"
sed -i "s/#$HOSTNAME //" "$1/.config/foot/foot.ini"
sed -i "s/\\/\\*$HOSTNAME//" "$1/.config/rofi/theme.rasi"
sed -i "s/$HOSTNAME\\*\\///" "$1/.config/rofi/theme.rasi"
2025-09-25 21:01:22 +01:00
;;
esac
2025-09-24 23:03:16 +01:00
}
2025-09-24 16:42:00 +01:00
Pull() {
# Allows system changes to be pulled into the repository to be committed
#
echo "[Info] :: Pulling dotfile changes from $1"
2025-09-25 18:08:46 +01:00
cp "$1/.bashrc" "bashrc"
cp "$1/.bash_profile" "bash_profile"
cp "$1/.bash_aliases" "bash_aliases"
2025-09-25 23:36:12 +01:00
cp -r "$1/.config/nvim" "config/"
cp "$1/.config/starship.toml" "config/starship.toml"
case $HOSTNAME in
kanto|tokyo)
cp "$1/.config/sway/config" "config/sway/$HOSTNAME.sway"
cp "$1/.config/rofi/config.rasi" "config/rofi/$HOSTNAME.rofi"
cp "$1/.config/rofi/$HOSTNAME.rasi" "config/rofi/$HOSTNAME.theme"
2025-09-26 22:33:19 +01:00
cp "$1/.config/swaylock/config" "config/swaylock"
cp "$1/.config/foot/foot.ini" "config/foot/foot.ini"
2025-09-25 23:36:12 +01:00
;;
esac
2025-09-24 16:42:00 +01:00
}
INSTALL_DIR=${2:-$HOME}
2025-09-24 23:03:16 +01:00
ACTION=$1
2025-09-24 16:42:00 +01:00
[[ -z $INSTALL_DIR ]] && echo "[Error] :: Installation directory not set" && exit 1
case $ACTION in
2025-09-25 16:30:14 +01:00
install)
Install $INSTALL_DIR
2025-09-24 23:03:16 +01:00
;;
2025-09-24 16:42:00 +01:00
pull)
Pull $INSTALL_DIR
;;
*)
2025-09-25 21:01:22 +01:00
echo "usage: $0 <install|pull|diff> [dir]"
2025-09-24 16:42:00 +01:00
;;
esac
2025-09-24 23:03:16 +01:00
popd > /dev/null