~dricottone/my-utils

ref: 618b5e7801dd9bdc6100b6ed88f04d9dcd75a3ab my-utils/README.md -rw-r--r-- 5.8 KiB
618b5e78Dominic Ricottone Slight refactor of a usage message 3 years ago
                                                                                
052c7cc6 dricottone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# my-utils

A set of scripts that I use frequently. Written in a mix of shell (some POSIX sh, some bash), sed, awk, and so on. Any dependencies *beyond* the POSIX standard and inter-dependency are noted.



## General-Use Scripts

Executable|Description                                                   |Extra Dependencies
:---------|:-------------------------------------------------------------|:------------------------------------------
check-x   |Check if an X11 server is running
ctdir     |Count entries in a target directory(ies)
debom     |Remove BOM from a target file                                 |`bash`
enumerate |Rename files in current directory into sequential numbers     |`bash`
epub      |Dumps HTML from an 'epub' e-book archive                      |`bash`, `zipinfo`, `unzip`, `w3m`
fw-status |Print current firewall status                                 |`ufw`
mkbak     |Create a backup of a target file                              |`bash`
mktar     |Wrapper around `tar` for easier compression                   |`bash` *
pingable  |Check if an address/name is ping-able                         |`ping`
rand      |Get a random number within an inclusive range                 |`bash`, `shuf`
rebom     |Add BOM to a target file
resetx    |Reset X server monitor configuration                          |`xrandr`
rmold     |Delete old files
rmtar     |Delete 'tar' archive files
rmzip     |Delete 'zip' archive files
start-at  |After a pattern is matched, re-print                          |GNU or New (AT&T) `awk`
stop-at   |Re-print until a pattern is matched                           |GNU or New (AT&T) `awk`
tarcat    |Print contents of `tar` archive file(s)                       |*
tarls     |List files within `tar` archive file(s)                       |*
unittest  |Wrapper around Python's `unittest` module                     |`python3`, GNU or New (AT&T) `awk`
untar     |Wrapper around `tar` for easier decompression                 |*
vimsplit  |Open two files in split windows                               |`nvim`
whichcat  |Print all lines from a program
whiched   |Open a program with your editor
whichhead |Print the first 10 lines from a program                       |`bash`
whichvi   |Open a program with your visual editor
whisper   |Wrapper around `espeak` to mirror `say` in macOS              |`espeak`
wttr      |Wrapper around `wttr` to fix double-wide runes for some fonts |`wego`
zipls     |List files within `zip` archive file(s)                       |`zipinfo`


## Emulator Scripts

Executable       |Description                                            |Extra Dependencies
:----------------|:------------------------------------------------------|:-----------------
android-emulator |Start an Android emulator session                      |`adb`, `emulator`
qemu-test        |Check if hardware and OS are capable of virtualization |


## Docker Scripts

The following all depend on `docker`.

Executable        |Description                                                 |Extra Dependencies
:-----------------|:-----------------------------------------------------------|:-----------------
docker-clean      |Stop all containers, remove all images, and clear the cache |
docker-get-all    |List all Docker containers' IDs                             |
docker-get-exited |List all exited Docker containers' IDs                      |
docker-restart    |Restart all exited Docker containers                        |
docker-up         |Start a Docker container using `./docker-compose.yml`       |`docker-compose`


## Pulseaudio Scripts

The following all depend on `pactl`.

Executable            |Description                                          |Extra Dependencies
:---------------------|:----------------------------------------------------|:-----------------
pactl-get-running-sink|Get the currently running Pulseaudio sink ID         |
pactl-mute            |Toggle mute on the currently running Pulseaudio sink |
pactl-volume-down     |Reduce volume (default: 10%)                         |
pactl-volume-printf   |Print the currently running Pulseaudio sink volume   |
pactl-volume-up       |Increase volume (default: 10%)                       |


## VPN Scripts

Executable|Description                                               |Extra Dependencies
:---------|:---------------------------------------------------------|:-----------------
vpn-off   |Stop all OpenVPN connections                              |`killall`
vpn-on    |Start an OpenVPN connection using `$MYUTILS_OPENVPN_CONF` |`openvpn`
wg-off    |Stop the `wg0` Wireguard connection                       |`wg`, `wg-quick`
wg-on     |Start the `wg0` Wireguard connection                      |`wg`, `wg-quick`
wg-status |Print current Wireguard connection status                 |`wg`
wg-test   |Check if Wireguard connection is on and working           |`wg`


## Notes

\* *While you **technically** won't run into an error, these scripts **do** expect `tar` to support Zstandard, which isn't necessarily POSIX standard.*

*All* scripts support `-h` and `--help` for printing built-in documentation.

*Almost all* scripts do nothing if no input arguments are given. (The exceptions are `whisper` and `wttr`.)



## Development

These being re-used scripts, there's been a great deal of feature creep, bikeshedding, and over-engineering. That is to say, there's a lot of uncertainty as to how *reliable* these scripts are. To mitigate these concerns, `shellcheck` is a development dependency. A test suite is in the making, and hopefully new entrants to this repository will come with tests.



## License

If you really want to use anything in this repository-and I need to stress *if you really want to*-just go right ahead. I'm licensing everything under GPL because I'd appreciate you letting me know I messed something up. But you *really* shouldn't try using anything here in production...