diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-20 11:08:20 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-05-05 19:05:41 -0300 |
commit | 1b9d01dd5219e4547eaa3847f49ec94960bb491b (patch) | |
tree | 5555b615099665949ef3b36bbb43840caab2bf06 /.zshrc | |
parent | 7ec3e2724ff6b43e3da88815fd1d47e6e59bdfcd (diff) |
zsh: relink utility
Diffstat (limited to '.zshrc')
-rw-r--r-- | .zshrc | 16 |
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 |