diff options
| author | Pavel Egorov <[email protected]> | 2026-01-09 22:13:03 +0300 |
|---|---|---|
| committer | Pavel Egorov <[email protected]> | 2026-01-09 22:13:03 +0300 |
| commit | 068b3c5770898387b574f888eac64749e9851fca (patch) | |
| tree | 7f25abfde7e2c8f8f48ee34fb1a62047fc997b53 /.local/bin | |
| parent | cf61cfc560adbc195e534bff84b55b1828f8fe2f (diff) | |
| download | dotfiles-068b3c5770898387b574f888eac64749e9851fca.tar.gz dotfiles-068b3c5770898387b574f888eac64749e9851fca.zip | |
[script] scripts are moved into separate repo
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/compress | 96 | ||||
| -rwxr-xr-x | .local/bin/decompress | 114 | ||||
| -rwxr-xr-x | .local/bin/reclaim | 13 | ||||
| -rwxr-xr-x | .local/bin/wgkey | 12 |
4 files changed, 0 insertions, 235 deletions
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 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 2 | |||
| 3 | set archiver_formats tar | ||
| 4 | set compressor_formats bz2 gz lz4 xz zstd | ||
| 5 | set arch_and_comp_formats 7z rar zip | ||
| 6 | set formats $archiver_formats $compressor_formats $arch_and_comp_formats | ||
| 7 | |||
| 8 | set options 'h/help' 'n/name=' 't/timestamp' 'f/format=!validate_format' | ||
| 9 | |||
| 10 | function validate_format | ||
| 11 | if not contains $_flag_value $formats | ||
| 12 | echo "$_flag_value archive is not supported" >&2 | ||
| 13 | return 1 | ||
| 14 | end | ||
| 15 | end | ||
| 16 | |||
| 17 | function print_help | ||
| 18 | echo -es "Archive and compressor wrapper\n" \ | ||
| 19 | "Supported formats: $formats" >&2 | ||
| 20 | echo "Usage: compress" \ | ||
| 21 | "[-h | --help]" \ | ||
| 22 | "[-n | --name archive_name]" \ | ||
| 23 | "[-t | --timestamp]" \ | ||
| 24 | "[-f | --format archive_format]" \ | ||
| 25 | "file1 [file2, file3, ...]" >&2 | ||
| 26 | echo -es \ | ||
| 27 | "-h, --help\t\tPrint this help\n" \ | ||
| 28 | "-n, --name\t\tSpecify archive name,\n" \ | ||
| 29 | "\t\t\tif archive name is not provided, default name will be used; \n" \ | ||
| 30 | "\t\t\tif $(string join '/' $compressor_formats) format used on single file, name will be ignored\n" \ | ||
| 31 | "-t, --timestamp\t\tAdd timestamp to filename\n" \ | ||
| 32 | "-f, --format\t\tSpecify archive format, zip is default" >&2 | ||
| 33 | end | ||
| 34 | |||
| 35 | function create_tarball | ||
| 36 | tar --force-local -cvf $tarball $files | ||
| 37 | end | ||
| 38 | |||
| 39 | # Script main code | ||
| 40 | |||
| 41 | argparse $options -- $argv | ||
| 42 | or return 1 | ||
| 43 | |||
| 44 | if set -q _flag_help; or test (count $argv) -eq 0 | ||
| 45 | print_help | ||
| 46 | return | ||
| 47 | end | ||
| 48 | |||
| 49 | if not set -q _flag_name | ||
| 50 | set _flag_name archive | ||
| 51 | end | ||
| 52 | |||
| 53 | if set -q _flag_timestamp | ||
| 54 | set _flag_name "$_flag_name@$(date -Iseconds)" | ||
| 55 | end | ||
| 56 | |||
| 57 | if not set -q _flag_format | ||
| 58 | echo "No format specified, using zip" >&2 | ||
| 59 | set _flag_format zip | ||
| 60 | end | ||
| 61 | |||
| 62 | set tarball "$_flag_name.tar" | ||
| 63 | |||
| 64 | set files $argv | ||
| 65 | |||
| 66 | if contains $_flag_format $compressor_formats | ||
| 67 | if test (count $files) -gt 1 -o -d $files | ||
| 68 | echo "Too many files, packing with tar first" >&2 | ||
| 69 | create_tarball | ||
| 70 | set _flag_name $tarball | ||
| 71 | else | ||
| 72 | set _flag_name $files | ||
| 73 | end | ||
| 74 | end | ||
| 75 | |||
| 76 | switch $_flag_format | ||
| 77 | case tar | ||
| 78 | create_tarball | ||
| 79 | case bz2 | ||
| 80 | bzip2 $_flag_name | ||
| 81 | case gz | ||
| 82 | gzip $_flag_name | ||
| 83 | case lz4 | ||
| 84 | lz4 $_flag_name | ||
| 85 | case xz | ||
| 86 | xz $_flag_name | ||
| 87 | case zstd | ||
| 88 | zstd $_flag_name | ||
| 89 | case 7z | ||
| 90 | 7z a "$_flag_name" $files | ||
| 91 | case rar | ||
| 92 | rar a "$_flag_name" $files | ||
| 93 | case zip | ||
| 94 | zip "$_flag_name" $files | ||
| 95 | end | ||
| 96 | |||
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 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 2 | |||
| 3 | set options 'h/help' | ||
| 4 | set archiver_formats tar | ||
| 5 | set bzip2 bz2 tar.bz2 tbz | ||
| 6 | set gzip gz tar.gz tgz | ||
| 7 | set lz4 lz4 tar.lz4 | ||
| 8 | set xz xz tar.xz txz | ||
| 9 | set zstd zst tar.zst tzst | ||
| 10 | set compressor_formats $bzip2 $gzip $lz4 $xz $zstd | ||
| 11 | set arch_and_comp_formats 7z rar zip | ||
| 12 | set formats $archiver_formats $compressor_formats $arch_and_comp_formats | ||
| 13 | |||
| 14 | function print_help | ||
| 15 | echo -es "Unarchive and uncompress wrapper\n" \ | ||
| 16 | "Supported formats: $formats\n" \ | ||
| 17 | "Also able to use MIME types and detect ZIP magic sequence" | ||
| 18 | echo "Usage: uncompress" \ | ||
| 19 | "[-h | --help]" \ | ||
| 20 | "file1 [file2, file3, ...]" >&2 | ||
| 21 | echo -es \ | ||
| 22 | "-h, --help\t\tPrint this help" | ||
| 23 | end | ||
| 24 | |||
| 25 | function get_extension -a file | ||
| 26 | set bname (basename $file) | ||
| 27 | set extension (string join '.' (string split '.' $bname)[2..]) | ||
| 28 | echo $extension | ||
| 29 | end | ||
| 30 | |||
| 31 | function extract_by_extension -a archive extension | ||
| 32 | switch $extension | ||
| 33 | case tar | ||
| 34 | tar --force-local -xvf $archive | ||
| 35 | case tar.bz2 tbz | ||
| 36 | bzcat $archive | tar xf - | ||
| 37 | case bz2 | ||
| 38 | bzip2 -d $archive | ||
| 39 | case tar.gz tgz | ||
| 40 | zcat $archive | tar xf - | ||
| 41 | case gz | ||
| 42 | gzip -d $archive | ||
| 43 | case tar.lz4 | ||
| 44 | lz4cat $archive | tar xf - | ||
| 45 | case lz4 | ||
| 46 | lz4 $archive | ||
| 47 | case tar.xz txz | ||
| 48 | xzcat $archive | tar xf - | ||
| 49 | case xz | ||
| 50 | xz -d $archive | ||
| 51 | case tar.zst tzst | ||
| 52 | zstdcat $archive | tar xf - | ||
| 53 | case zst | ||
| 54 | zstd -d $archive | ||
| 55 | case 7z | ||
| 56 | 7z x $archive | ||
| 57 | case rar | ||
| 58 | if type -q rar | ||
| 59 | rar x $archive | ||
| 60 | else | ||
| 61 | unrar x $archive | ||
| 62 | end | ||
| 63 | case zip | ||
| 64 | unzip $archive | ||
| 65 | end | ||
| 66 | or return 1 | ||
| 67 | end | ||
| 68 | |||
| 69 | function extract_by_mime -a archive | ||
| 70 | set possible_extensions (string split ' ' (file --extension $archive))[2] | ||
| 71 | set possible_extensions (string split '/' $possible_extensions) | ||
| 72 | |||
| 73 | for extension in $possible_extensions | ||
| 74 | extract_by_extension $archive $extension | ||
| 75 | and return | ||
| 76 | end | ||
| 77 | |||
| 78 | return 1 | ||
| 79 | end | ||
| 80 | |||
| 81 | # Script main code | ||
| 82 | |||
| 83 | argparse $options -- $argv | ||
| 84 | or return 1 | ||
| 85 | |||
| 86 | if set -q _flag_help; or test (count $argv) -eq 0 | ||
| 87 | print_help | ||
| 88 | return | ||
| 89 | end | ||
| 90 | |||
| 91 | set final_status 0 | ||
| 92 | |||
| 93 | for archive in $argv | ||
| 94 | set extension (get_extension $archive) | ||
| 95 | |||
| 96 | if contains $extension $formats | ||
| 97 | extract_by_extension $archive $extension | ||
| 98 | else | ||
| 99 | echo "Unable to match $archive extension, trying MIME-type detection" >&2 | ||
| 100 | extract_by_mime $archive | ||
| 101 | and continue | ||
| 102 | |||
| 103 | echo "Checking if $archive is secretly a ZIP archive" >&2 | ||
| 104 | if test (head -c 4 $archive | base64) = "UEsDBA==" | ||
| 105 | unzip $archive | ||
| 106 | continue | ||
| 107 | end | ||
| 108 | |||
| 109 | echo "Extraction of $archive failed" >&2 | ||
| 110 | set final_status 1 | ||
| 111 | end | ||
| 112 | end | ||
| 113 | |||
| 114 | 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 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 2 | |||
| 3 | switch (rg "^ID" /etc/os-release) | ||
| 4 | case arch | ||
| 5 | paccache -rk 1 | ||
| 6 | end | ||
| 7 | |||
| 8 | journalctl --vacuum-size=500M | ||
| 9 | |||
| 10 | docker volume prune | ||
| 11 | docker image prune -a | ||
| 12 | docker buildx prune | ||
| 13 | 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 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 2 | |||
| 3 | umask 077 | ||
| 4 | |||
| 5 | set keyname "$argv[1]" | ||
| 6 | |||
| 7 | if test -z "$keyname" | ||
| 8 | echo "No keyname given" | ||
| 9 | exit 1 | ||
| 10 | end | ||
| 11 | |||
| 12 | wg genkey | tee "$keyname" | wg pubkey > "$keyname.pub" | ||
