about summary refs log tree commit diff stats
path: root/home-manager/config/lf/cmds
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-04-16 09:08:06 +0200
committerSoispha <soispha@vhack.eu>2023-05-09 19:30:52 +0200
commitd5b17f14ab6100d41d9aea9f6b36685ba69c3487 (patch)
tree2e5b22f95bce1d2610fc645b1b5c2dc7a68a786c /home-manager/config/lf/cmds
parentFix(hm/conf/mail): Allow mbsync to create maildirs (diff)
downloadnixos-config-d5b17f14ab6100d41d9aea9f6b36685ba69c3487.tar.gz
nixos-config-d5b17f14ab6100d41d9aea9f6b36685ba69c3487.zip
Fix(hm/conf/lf/cmds/archive): Rework script
Diffstat (limited to '')
-rwxr-xr-xhome-manager/config/lf/cmds/archive16
1 files changed, 11 insertions, 5 deletions
diff --git a/home-manager/config/lf/cmds/archive b/home-manager/config/lf/cmds/archive
index 4ea86787..fd032dd4 100755
--- a/home-manager/config/lf/cmds/archive
+++ b/home-manager/config/lf/cmds/archive
@@ -12,22 +12,28 @@ set -f
 
 archivers=$(tmp 'echo "gzip xz 7z zip"');
 
-readp "File Name: " name
+readp "File Name: " name;
 
+FX="$(awk -v Root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)" '{
+for (i=1; i<=NF; i++) {
+    gsub(Root, "", $i);
+    print $i;
+}
+}' "$(tmp "echo \"$fx\" | tr '\n' ' '")")";
 
 case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in
     "gzip")
-        tar -czf "$name".tar.gz "$fx"
+        tar -czf "$name".tar.gz $FX
         ;;
     "xz")
-        tar -cf "$name".tar "$fx"
+        tar -cf "$name".tar $FX
         xz -z -9 -e -T0 "$name".tar
         ;;
     "7z")
-        7z a "$name".7z "$fx"
+        7z a "$name".7z $FX
         ;;
     "zip")
-        zip -r "$name".zip "$fx"
+        zip --symlinks -r "$name".zip $FX
         ;;
 esac
 # vim: ft=sh