diff options
Diffstat (limited to 'hm/soispha/conf/lf/commands/scripts/archive.sh')
-rwxr-xr-x | hm/soispha/conf/lf/commands/scripts/archive.sh | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh index 9ac07898..bee9c341 100755 --- a/hm/soispha/conf/lf/commands/scripts/archive.sh +++ b/hm/soispha/conf/lf/commands/scripts/archive.sh @@ -17,12 +17,28 @@ fx="$fx" fs="$fs" archivers="$(tmp echo gzip xz 7z zip)" +archiver="$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" + +case "$archiver" in +"gzip") + ext=tar.gz + ;; +"xz") + ext=tar.xz + ;; +"7z") + ext=7z + ;; +"zip") + ext=zip + ;; +esac prompt "Archive name: " name="" -while [ -z "$name" ] || [ -e "$name" ]; do +while [ -z "$name" ] || [ -e "$name.$ext" ]; do read -r name - if [ -e "$name" ]; then + if [ -e "$name.$ext" ]; then prompt "Archive already exists, overwrite [y|N]: " read -r ans @@ -42,7 +58,7 @@ while read -r raw_file; do set -- "$@" "$file" done <"$(tmp echo "$fx")" -case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in +case "$archiver" in "gzip") tar -czf "$name".tar.gz "$@" ;; |