configs  Artifact [40abe8329e]

Artifact 40abe8329e3b4f600b531896f3106c0dcbe4dc5177c4918ed3390ccf1f9a5b91:

  • Executable file create_symlinks.sh — part of check-in [dfc76a33b7] at 2020-02-16 18:09:33 on branch trunk — create_symlinks.sh: Only symlink as needed (user: js size: 1256)

#!/bin/sh
rel_dir="${PWD#$HOME/}"
echo "Configs relative to home in $rel_dir."

link_file() {
	if [ ! -e "$HOME/$2" ]; then
		echo "Symlinking $HOME/$2 -> $3$rel_dir/$1…"
		ln -s "$3$rel_dir/$1" "$HOME/$2"
	else
		echo "$HOME/$2 already exists, skipping…"
	fi
}

mkdir -p $HOME/.config
which git >/dev/null 2>&1 && link_file gitconfig .gitconfig
if which gpg >/dev/null 2>&1 || which gpg2 >/dev/null 2>&1; then
	mkdir -p $HOME/.gnupg
	link_file gpg.conf .gnupg/gpg.conf ../
fi
which tmux >/dev/null 2>&1 && link_file tmux.conf .tmux.conf
if which vim >/dev/null 2>&1; then
	link_file vim .vim
	link_file vimrc .vimrc
fi
which fish >/dev/null 2>&1 && link_file config/fish .config/fish ../
which youtube-dl >/dev/null 2>&1 && link_file config/youtube-dl .config/youtube-dl ../
which zsh >/dev/null 2>&1 && link_file zshrc .zshrc

if test x"$(uname -s)" = x"Darwin"; then
	dest="$HOME/Library/Keyboard Layouts/eu_US.keylayout"
	# This does not like being symlinked…
	if [ ! -e "$dest" ]; then
		echo "Hardlinking eu_US.keylayout -> $dest"
		ln eu_US.keylayout "$dest"
	else
		echo "$dest already exists, skipping…"
	fi
elif which startx >/dev/null 2>&1; then
	link_file Xdefaults .Xdefaults
	link_file Xmodmap .Xmodmap
	link_file xinitrc .xinitrc
fi