From 14704808f61394f3c3cad0b9d5550f1cbb2be416 Mon Sep 17 00:00:00 2001 From: sadan <117494111+sadan4@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:27:34 -0400 Subject: [PATCH] add detach command --- common/users/homeModules/scripts/default.nix | 8 ++++++++ common/users/homeModules/scripts/detach.sh | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 common/users/homeModules/scripts/detach.sh diff --git a/common/users/homeModules/scripts/default.nix b/common/users/homeModules/scripts/default.nix index d2c5540..ecdc17f 100644 --- a/common/users/homeModules/scripts/default.nix +++ b/common/users/homeModules/scripts/default.nix @@ -19,6 +19,7 @@ let executable = true; destination = "/bin/${name}"; text = '' + export PATH="" for i in ${lib.concatStringsSep " " env}; do export PATH="$i/bin:$PATH" done @@ -78,6 +79,13 @@ in direnv ]; }) + (mkScript { + name = "detach"; + file = ./detach.sh; + env = with pkgs; [ + coreutils + ]; + }) # impl for the cloneRepo command ]; file = { diff --git a/common/users/homeModules/scripts/detach.sh b/common/users/homeModules/scripts/detach.sh new file mode 100644 index 0000000..7277cfe --- /dev/null +++ b/common/users/homeModules/scripts/detach.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -eo pipefail + +function echoe() { + echo $@ 1>&2 +} + +function printUsage() { + echoe "Usage: ${0} FILE" + echoe "Unlink a file by copying the original file to the link path" + echoe "Shorthand for cp -P \$(readlink \$FILE) $FILE" +} + +if [[ -z $1 ]]; then + echoe "${0}: missing file" + printUsage + exit 1 +fi + +cp -P $(readlink $1) $1