owenrusk.dev

dotfiles

shell, editor, ssh.

git clone https://owenrusk.dev/dotfiles.git

commit 371936e023b495d260d75cd3cc3d15bfd3f07241
parent 35514bff8446901a109544d996beefe8e0823e9d
author Owen Rusk <owen@papermothgames.com>
date   2024-05-22 11:55:30 -0500
install: move real files aside instead of linking into them

a real ~/.config/nvim got a link inside it, which did nothing.
install.sh+9-2
diff --git a/install.sh b/install.sh
index 62f8b94..e4e051b 100755
--- a/install.sh
+++ b/install.sh
@@ -4,8 +4,15 @@ set -eu
 here=$(cd "$(dirname "$0")" && pwd)
 
 link() {
-    mkdir -p "$(dirname "$2")"
-    ln -sfn "$here/$1" "$2"
+    src=$here/$1
+    dst=$2
+    mkdir -p "$(dirname "$dst")"
+    # a real file in the way gets moved aside, not linked into
+    if [ -e "$dst" ] && [ ! -L "$dst" ]; then
+        mv "$dst" "$dst.orig"
+        echo "moved $dst to $dst.orig"
+    fi
+    ln -sfn "$src" "$dst"
 }
 
 link zsh/zshenv "$HOME/.zshenv"