#!/bin/sh

set -e

if test -z "$1"; then
	printf "Usage: %s machine\n" "$0" 1>&2
	exit 64 # sysexits.h(3) EX_USAGE
fi

case "$1" in
	"carnation")
		MACHINE="noire-carnation"
		;;
	"rose")
		MACHINE="noire-rose"
		;;
esac

for item in "$MACHINE"/config/*
do
	inst_path="$(printf "%s\n" "$item" | sed "s/$MACHINE\/config\///g")"

	printf "Creating symlink from %s to %s\n" "$PWD/$item" "$XDG_CONFIG_HOME/$inst_path" 1>&2
	ln -sf "$PWD/$item" "$XDG_CONFIG_HOME/$inst_path"
done

ln -sf "$PWD/$MACHINE/functions" "$HOME/.functions"
ln -sf "$PWD/$MACHINE/profile" "$HOME/.profile"
ln -sf "$PWD/$MACHINE/zprofile" "$HOME/.zprofile"
ln -sf "$PWD/$MACHINE/zshrc" "$HOME/.zshrc"
