home/shell: add shellscript for preparing backup of file

This commit is contained in:
2025-11-05 09:12:48 +09:00
parent be70280f18
commit 31c4434627

View File

@@ -443,6 +443,20 @@ in {
# "which \"$@\""
# "xargs realpath --"
# ];
# move $1 into $1.bak, copy $1.bak into $1.
(pkgs.writeShellApplication {
name = "bak";
runtimeInputs = [ pkgs.coreutils ];
text = ''
if [[ "$#" != 1 ]]; then
(>&2 echo "Usage: bak <PATH>")
exit 2
fi
mv "$1" "$1.bak" && cp "$1.bak" "$1"
'';
})
];
# local.shell.variables = {