diff --git a/contrib/symlinkTo.sh b/contrib/symlinkTo.sh new file mode 100755 index 0000000..9ab634c --- /dev/null +++ b/contrib/symlinkTo.sh @@ -0,0 +1,23 @@ +#!/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 +