dotfiles/lib/helper/mk_link
James Patrick e49934c99d Adding shared makefile logic and helper scripts
Shared logic can be imported via `include ../lib/shared.mk`
Helper functions include 3 current opperations

1. mk_link:: This will create a symbolic link if the file doesn't already exist.
2. rm_link:: Will remove the link if it is a symlink.
3. report :: This color codes the status of a message and adds a leading symbol.

report also can be called with `LAST_RETURN=$? report "message"`
and will expand this to be either `report info "message"` Or `report error
"message"` based on the last return value.
Current status are info, warn, and error.
2019-04-27 18:09:36 -04:00

15 lines
307 B
Bash
Executable File

#! env zsh
REPORT=`dirname $0`/report
if [ -z "$1" ] || [ -z "$2" ] ; then
$REPORT error "ERROR: Both to and from string must be defined.\n source: $1 \n symlnk: $2"
exit
fi
if [[ -e $2 ]] ; then
$REPORT warn "$2 already exist. Skipping."
exit
fi
$REPORT info "Symlinked `ln -svf $1 $2`"