helper/contrib/symlinkTo.sh
2017-11-14 12:06:57 +01:00

23 lines
595 B
Bash
Executable file

#!/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