adds helper to "install" aka symlink scripts
This commit is contained in:
parent
72a5b7fbe1
commit
2a588c9ab5
1 changed files with 23 additions and 0 deletions
23
contrib/symlinkTo.sh
Executable file
23
contrib/symlinkTo.sh
Executable file
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue