From 8f5765638bea0aed7e44bb4ddab93ab6000b7bb5 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Tue, 23 Feb 2021 11:10:23 -0500 Subject: [PATCH] install: Create symlinks relative to $HOME, if possible This is purely cosmetic (makes `ls -la` a bit more narrow, without $HOME prefixing each symlink). --- bin/lnkdot | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/lnkdot b/bin/lnkdot index ad63617..501d3b3 100755 --- a/bin/lnkdot +++ b/bin/lnkdot @@ -12,13 +12,18 @@ if [ "$#" = "0" ]; then fi DIR="$(dirname "$(dirname "$(readlink -f "$0")")")" +RELDIR="$(echo $DIR | sed "s#^$HOME/##")" lnk() { printf "$1 ... " if [ -e "$HOME/$1" -a ! -L "$HOME/$1" ]; then echo "failed" else - ln -snf $DIR/$1 $HOME/$1 + root=$RELDIR + case $1 in + */*) root=$DIR ;; + esac + ln -snf $root/$1 $HOME/$1 echo "linked" fi } -- libgit2 0.28.4