« get me outta code hell

dotfiles - Miscellaneous configuration files of my personal use
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.zshrc16
1 files changed, 16 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index 3c92d3b..6f01d13 100644
--- a/.zshrc
+++ b/.zshrc
@@ -115,6 +115,22 @@ export PATH
 
 # //// aliases & non-script functions //////////////////////// <alias-fns> // #
 
+relink() {
+  inode1=$(ls -i $1 | cut -d " " -f 1) &&
+  inode2=$(ls -i $2 | cut -d " " -f 1) &&
+  if [[ $inode1 == $inode2 ]]; then
+    echo files are already same inode >&2
+  else
+    sha1=$(sha256sum $1 | cut -d " " -f 1) &&
+    sha2=$(sha256sum $2 | cut -d " " -f 1) &&
+    if [[ $sha1 != $sha2 ]]; then
+      echo files have different checksums >&2
+    else
+      rm $2 && ln $1 $2
+    fi
+  fi
+}
+
 # -- hooks into third-party stuff --
 
 if [[ -v DEVICE_HAS_VIM ]]; then