Add separate relink command

Also rejigged install to accomodate FreeBSD, and update before installing.
This commit is contained in:
2024-11-19 10:59:09 +00:00
parent 57ec2feb3d
commit ec1ec2bbfb
2 changed files with 66 additions and 12 deletions

42
relink Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
#
# Adapted from Junegunn Choi (junegunn.c@gmail.com)
# https://github.com/junegunn/dotfiles/blob/master/install
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
BASE=$(pwd)
IS_MAC=0
IS_LINUX=0
IS_FREEBSD=0
case $(uname -s) in
Darwin) IS_MAC=1 ;;
Linux) IS_LINUX=1 ;;
FreeBSD) IS_FREEBSD=1 ;;
*) echo "Unknown OS" ;;
esac
# RC files
mkdir -pv bak
for rc in *rc *profile tmux.conf bashrc.d mutt ; do
if [ ! -r $rc ] ; then
continue
fi
[ "$(realpath ~/."$rc")" == "$BASE/$rc" ]
if [ $? -ne 0 ] ; then
[ -e ~/."$rc" ] && mv -v ~/."$rc" bak/."$rc"
ln -sfv "$BASE/$rc" ~/."$rc"
fi
done
# scripts
mkdir -p ~/bin
for bin in $BASE/bin/*; do
BIN_NAME=$(basename $bin)
[ "$(realpath ~/bin/$BIN_NAME)" == "$bin" ]
if [ $? -ne 0 ] ; then
ln -svf "$bin" ~/bin
fi
done