dotfiles/install.sh

49 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
set -e
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CONFIG_DIR="$HOME/.config"
# Create config directory if it doesn't exist
mkdir -p "$CONFIG_DIR"
# Function to backup existing config and create symlink
install_config() {
local name=$1
local target="$CONFIG_DIR/$name"
# Backup existing config if it exists and is not a symlink
if [ -e "$target" ] && [ ! -L "$target" ]; then
echo "Backing up existing $name config to ${target}.bak"
mv "$target" "${target}.bak"
elif [ -L "$target" ]; then
echo "Removing existing $name symlink"
rm "$target"
fi
# Create symlink
echo "Creating symlink for $name"
ln -s "$DOTFILES_DIR/$name" "$target"
}
# Install each config
echo "Installing dotfiles..."
install_config "fish"
install_config "mc"
install_config "nvim"
install_config "kitty"
# Install starship.toml
if [ -e "$CONFIG_DIR/starship.toml" ] && [ ! -L "$CONFIG_DIR/starship.toml" ]; then
echo "Backing up existing starship.toml to ${CONFIG_DIR}/starship.toml.bak"
mv "$CONFIG_DIR/starship.toml" "${CONFIG_DIR}/starship.toml.bak"
elif [ -L "$CONFIG_DIR/starship.toml" ]; then
echo "Removing existing starship.toml symlink"
rm "$CONFIG_DIR/starship.toml"
fi
echo "Creating symlink for starship.toml"
ln -s "$DOTFILES_DIR/starship.toml" "$CONFIG_DIR/starship.toml"
echo "Dotfiles installation complete!"