Dotfiles/link.sh

59 lines
1.6 KiB
Bash
Raw Normal View History

2023-11-29 17:46:22 +01:00
#!/bin/sh
2023-11-30 15:22:23 +01:00
link() {
src="$1"
dst="$2"
if [ "$src" = "" ] || [ "$dst" = "" ]; then
echo "Source or destination parameter missing." >&2
exit 2
fi
if [ ! -e "$src" ]; then
echo "Source file not found." >&2
exit 3
fi
if [ -e "$dst" ] && [ ! -L "$dst" ]; then
echo "Destination exists and is not a symlink." >&2
exit 4
fi
full_src=$(realpath -s "$src")
full_dst=$(realpath -s "$dst")
2023-11-30 20:50:18 +01:00
mkdir -p "$(dirname "$full_dst")"
2023-11-30 15:22:23 +01:00
if [ -L "$dst" ]; then
if [ "$full_dst" != "$full_src" ]; then
ln -s -f "$full_src" "$full_dst"
fi
else
ln -s "$full_src" "$full_dst"
fi
}
cd "$(dirname "$(readlink -f "$0")")" || exit 1
link ./alacritty/alacritty.yml "$HOME/.config/alacritty/alacritty.yml"
2023-11-30 20:50:18 +01:00
link ./alacritty/theme.mustache "$HOME/.local/share/flavours/base16/templates/alacritty/templates/custom.mustache"
2023-11-30 15:22:23 +01:00
link ./fish/abbr.fish "$HOME/.config/fish/abbr.fish"
link ./fish/config.fish "$HOME/.config/fish/config.fish"
2023-11-30 20:50:18 +01:00
link ./fish/theme.mustache "$HOME/.local/share/flavours/base16/templates/fish/templates/custom.mustache"
2023-11-30 15:22:23 +01:00
link ./flavours/config.toml "$HOME/.config/flavours/config.toml"
2023-12-01 11:05:46 +01:00
link ./fontconfig/fonts.conf "$HOME/.config/fontconfig/fonts.conf"
2023-11-30 15:22:23 +01:00
link ./newsboat/config "$HOME/.config/newsboat/config"
link ./nvim/init.lua "$HOME/.config/nvim/init.lua"
link ./nvim/vim_plugins.sh "$HOME/scripts/vim_plugins.sh"
2023-11-30 20:50:18 +01:00
link ./tmux/tmux.conf "$HOME/.config/tmux/tmux.conf"
link "$HOME/.config/tmux/tmux.conf" "$HOME/.tmux.conf"
link ./tmux/theme.mustache "$HOME/.local/share/flavours/base16/templates/tmux/templates/custom.mustache"
link ./vivid/theme.mustache "$HOME/.local/share/flavours/base16/templates/vivid/templates/custom.mustache"