summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
authorPavel Egorov <[email protected]>2026-01-09 22:13:03 +0300
committerPavel Egorov <[email protected]>2026-01-09 22:13:03 +0300
commit068b3c5770898387b574f888eac64749e9851fca (patch)
tree7f25abfde7e2c8f8f48ee34fb1a62047fc997b53 /.local/bin
parentcf61cfc560adbc195e534bff84b55b1828f8fe2f (diff)
downloaddotfiles-068b3c5770898387b574f888eac64749e9851fca.tar.gz
dotfiles-068b3c5770898387b574f888eac64749e9851fca.zip
[script] scripts are moved into separate repo
Diffstat (limited to '')
-rwxr-xr-x.local/bin/compress96
-rwxr-xr-x.local/bin/decompress114
-rwxr-xr-x.local/bin/reclaim13
-rwxr-xr-x.local/bin/wgkey12
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
3set archiver_formats tar
4set compressor_formats bz2 gz lz4 xz zstd
5set arch_and_comp_formats 7z rar zip
6set formats $archiver_formats $compressor_formats $arch_and_comp_formats
7
8set options 'h/help' 'n/name=' 't/timestamp' 'f/format=!validate_format'
9
10function validate_format
11 if not contains $_flag_value $formats
12 echo "$_flag_value archive is not supported" >&2
13 return 1
14 end
15end
16
17function 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
33end
34
35function create_tarball
36 tar --force-local -cvf $tarball $files
37end
38
39# Script main code
40
41argparse $options -- $argv
42or return 1
43
44if set -q _flag_help; or test (count $argv) -eq 0
45 print_help
46 return
47end
48
49if not set -q _flag_name
50 set _flag_name archive
51end
52
53if set -q _flag_timestamp
54 set _flag_name "$_flag_name@$(date -Iseconds)"
55end
56
57if not set -q _flag_format
58 echo "No format specified, using zip" >&2
59 set _flag_format zip
60end
61
62set tarball "$_flag_name.tar"
63
64set files $argv
65
66if 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
74end
75
76switch $_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
95end
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
3set options 'h/help'
4set archiver_formats tar
5set bzip2 bz2 tar.bz2 tbz
6set gzip gz tar.gz tgz
7set lz4 lz4 tar.lz4
8set xz xz tar.xz txz
9set zstd zst tar.zst tzst
10set compressor_formats $bzip2 $gzip $lz4 $xz $zstd
11set arch_and_comp_formats 7z rar zip
12set formats $archiver_formats $compressor_formats $arch_and_comp_formats
13
14function 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"
23end
24
25function get_extension -a file
26 set bname (basename $file)
27 set extension (string join '.' (string split '.' $bname)[2..])
28 echo $extension
29end
30
31function 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
67end
68
69function 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
79end
80
81# Script main code
82
83argparse $options -- $argv
84or return 1
85
86if set -q _flag_help; or test (count $argv) -eq 0
87 print_help
88 return
89end
90
91set final_status 0
92
93for 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
112end
113
114return $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
3switch (rg "^ID" /etc/os-release)
4 case arch
5 paccache -rk 1
6end
7
8journalctl --vacuum-size=500M
9
10docker volume prune
11docker image prune -a
12docker buildx prune
13docker 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
3umask 077
4
5set keyname "$argv[1]"
6
7if test -z "$keyname"
8 echo "No keyname given"
9 exit 1
10end
11
12wg genkey | tee "$keyname" | wg pubkey > "$keyname.pub"