#!/usr/bin/env bash TARGET=${1:-"${HOME}/bin/"} set -e [[ ! -d "${TARGET}" ]] && echo "${TARGET} does not exist" && exit 1 BASEDIR="$(realpath "$(dirname "$(realpath "$0")")/..")" for scriptpath in "${BASEDIR}"/*.sh ; do scriptname="$(basename "$scriptpath")" targetpath="${TARGET}/${scriptname}" if [[ -h "$targetpath" && ! -e "$(realpath "$targetpath")" ]] ; then echo "deleting $targetpath pointing to $(realpath "$targetpath")" rm "$targetpath" fi if [[ ! -e "$targetpath" ]] ; then echo installing "${scriptname}" ln -s "${scriptpath}" "${TARGET}" fi done