From 068b3c5770898387b574f888eac64749e9851fca Mon Sep 17 00:00:00 2001 From: Pavel Egorov Date: Fri, 9 Jan 2026 22:13:03 +0300 Subject: [script] scripts are moved into separate repo --- .local/bin/compress | 96 ------------------------------------------ .local/bin/decompress | 114 -------------------------------------------------- .local/bin/reclaim | 13 ------ .local/bin/wgkey | 12 ------ 4 files changed, 235 deletions(-) delete mode 100755 .local/bin/compress delete mode 100755 .local/bin/decompress delete mode 100755 .local/bin/reclaim delete mode 100755 .local/bin/wgkey (limited to '.local') diff --git a/.local/bin/compress b/.local/bin/compress deleted file mode 100755 index 83b3eb5..0000000 --- a/.local/bin/compress +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env fish - -set archiver_formats tar -set compressor_formats bz2 gz lz4 xz zstd -set arch_and_comp_formats 7z rar zip -set formats $archiver_formats $compressor_formats $arch_and_comp_formats - -set options 'h/help' 'n/name=' 't/timestamp' 'f/format=!validate_format' - -function validate_format - if not contains $_flag_value $formats - echo "$_flag_value archive is not supported" >&2 - return 1 - end -end - -function print_help - echo -es "Archive and compressor wrapper\n" \ - "Supported formats: $formats" >&2 - echo "Usage: compress" \ - "[-h | --help]" \ - "[-n | --name archive_name]" \ - "[-t | --timestamp]" \ - "[-f | --format archive_format]" \ - "file1 [file2, file3, ...]" >&2 - echo -es \ - "-h, --help\t\tPrint this help\n" \ - "-n, --name\t\tSpecify archive name,\n" \ - "\t\t\tif archive name is not provided, default name will be used; \n" \ - "\t\t\tif $(string join '/' $compressor_formats) format used on single file, name will be ignored\n" \ - "-t, --timestamp\t\tAdd timestamp to filename\n" \ - "-f, --format\t\tSpecify archive format, zip is default" >&2 -end - -function create_tarball - tar --force-local -cvf $tarball $files -end - -# Script main code - -argparse $options -- $argv -or return 1 - -if set -q _flag_help; or test (count $argv) -eq 0 - print_help - return -end - -if not set -q _flag_name - set _flag_name archive -end - -if set -q _flag_timestamp - set _flag_name "$_flag_name@$(date -Iseconds)" -end - -if not set -q _flag_format - echo "No format specified, using zip" >&2 - set _flag_format zip -end - -set tarball "$_flag_name.tar" - -set files $argv - -if contains $_flag_format $compressor_formats - if test (count $files) -gt 1 -o -d $files - echo "Too many files, packing with tar first" >&2 - create_tarball - set _flag_name $tarball - else - set _flag_name $files - end -end - -switch $_flag_format - case tar - create_tarball - case bz2 - bzip2 $_flag_name - case gz - gzip $_flag_name - case lz4 - lz4 $_flag_name - case xz - xz $_flag_name - case zstd - zstd $_flag_name - case 7z - 7z a "$_flag_name" $files - case rar - rar a "$_flag_name" $files - case zip - zip "$_flag_name" $files -end - diff --git a/.local/bin/decompress b/.local/bin/decompress deleted file mode 100755 index a2023c3..0000000 --- a/.local/bin/decompress +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env fish - -set options 'h/help' -set archiver_formats tar -set bzip2 bz2 tar.bz2 tbz -set gzip gz tar.gz tgz -set lz4 lz4 tar.lz4 -set xz xz tar.xz txz -set zstd zst tar.zst tzst -set compressor_formats $bzip2 $gzip $lz4 $xz $zstd -set arch_and_comp_formats 7z rar zip -set formats $archiver_formats $compressor_formats $arch_and_comp_formats - -function print_help - echo -es "Unarchive and uncompress wrapper\n" \ - "Supported formats: $formats\n" \ - "Also able to use MIME types and detect ZIP magic sequence" - echo "Usage: uncompress" \ - "[-h | --help]" \ - "file1 [file2, file3, ...]" >&2 - echo -es \ - "-h, --help\t\tPrint this help" -end - -function get_extension -a file - set bname (basename $file) - set extension (string join '.' (string split '.' $bname)[2..]) - echo $extension -end - -function extract_by_extension -a archive extension - switch $extension - case tar - tar --force-local -xvf $archive - case tar.bz2 tbz - bzcat $archive | tar xf - - case bz2 - bzip2 -d $archive - case tar.gz tgz - zcat $archive | tar xf - - case gz - gzip -d $archive - case tar.lz4 - lz4cat $archive | tar xf - - case lz4 - lz4 $archive - case tar.xz txz - xzcat $archive | tar xf - - case xz - xz -d $archive - case tar.zst tzst - zstdcat $archive | tar xf - - case zst - zstd -d $archive - case 7z - 7z x $archive - case rar - if type -q rar - rar x $archive - else - unrar x $archive - end - case zip - unzip $archive - end - or return 1 -end - -function extract_by_mime -a archive - set possible_extensions (string split ' ' (file --extension $archive))[2] - set possible_extensions (string split '/' $possible_extensions) - - for extension in $possible_extensions - extract_by_extension $archive $extension - and return - end - - return 1 -end - -# Script main code - -argparse $options -- $argv -or return 1 - -if set -q _flag_help; or test (count $argv) -eq 0 - print_help - return -end - -set final_status 0 - -for archive in $argv - set extension (get_extension $archive) - - if contains $extension $formats - extract_by_extension $archive $extension - else - echo "Unable to match $archive extension, trying MIME-type detection" >&2 - extract_by_mime $archive - and continue - - echo "Checking if $archive is secretly a ZIP archive" >&2 - if test (head -c 4 $archive | base64) = "UEsDBA==" - unzip $archive - continue - end - - echo "Extraction of $archive failed" >&2 - set final_status 1 - end -end - -return $final_status diff --git a/.local/bin/reclaim b/.local/bin/reclaim deleted file mode 100755 index f754fe5..0000000 --- a/.local/bin/reclaim +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env fish - -switch (rg "^ID" /etc/os-release) - case arch - paccache -rk 1 -end - -journalctl --vacuum-size=500M - -docker volume prune -docker image prune -a -docker buildx prune -docker container prune --filter "until=720h" # remove containers stopped more than 30 days ago diff --git a/.local/bin/wgkey b/.local/bin/wgkey deleted file mode 100755 index 5aa710f..0000000 --- a/.local/bin/wgkey +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env fish - -umask 077 - -set keyname "$argv[1]" - -if test -z "$keyname" - echo "No keyname given" - exit 1 -end - -wg genkey | tee "$keyname" | wg pubkey > "$keyname.pub" -- cgit v1.3