diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/80 | 1 | ||||
-rwxr-xr-x | bin/assert-arg | 1 | ||||
-rwxr-xr-x | bin/aux | 2 | ||||
-rwxr-xr-x | bin/backup | 1 | ||||
-rwxr-xr-x | bin/bins | 1 | ||||
-rwxr-xr-x | bin/boop | 2 | ||||
-rwxr-xr-x | bin/clamp | 7 | ||||
-rwxr-xr-x | bin/color | 10 | ||||
-rwxr-xr-x | bin/copy | 14 | ||||
-rwxr-xr-x | bin/dice | 2 | ||||
-rwxr-xr-x | bin/e | 15 | ||||
-rwxr-xr-x | bin/email | 1 | ||||
-rwxr-xr-x | bin/forever | 5 | ||||
-rwxr-xr-x | bin/gc | 1 | ||||
-rwxr-xr-x | bin/gen-password | 1 | ||||
-rwxr-xr-x | bin/git-cleanup | 1 | ||||
-rwxr-xr-x | bin/grun | 11 | ||||
-rwxr-xr-x | bin/htmlesc | 1 | ||||
-rwxr-xr-x | bin/httpno | 1 | ||||
-rwxr-xr-x | bin/ifnew | 7 | ||||
-rwxr-xr-x | bin/lc | 1 | ||||
-rwxr-xr-x | bin/lines | 1 | ||||
-rwxr-xr-x | bin/max | 7 | ||||
-rwxr-xr-x | bin/menu | 1 | ||||
-rwxr-xr-x | bin/min | 6 | ||||
-rwxr-xr-x | bin/mkdtemp | 1 | ||||
-rwxr-xr-x | bin/mkstemp | 1 | ||||
-rwxr-xr-x | bin/msg | 6 | ||||
-rwxr-xr-x | bin/n-times | 6 | ||||
-rwxr-xr-x | bin/nato | 1 | ||||
-rwxr-xr-x | bin/ootb | 10 | ||||
-rwxr-xr-x | bin/open | 11 | ||||
-rwxr-xr-x | bin/player | 1 | ||||
-rwxr-xr-x | bin/playlist | 1 | ||||
-rwxr-xr-x | bin/pre | 4 | ||||
-rwxr-xr-x | bin/print | 14 | ||||
-rwxr-xr-x | bin/prompt | 3 | ||||
-rwxr-xr-x | bin/qr | 1 | ||||
-rwxr-xr-x | bin/reconfigure | 1 | ||||
-rwxr-xr-x | bin/rfc | 5 | ||||
-rwxr-xr-x | bin/serve | 1 | ||||
-rwxr-xr-x | bin/shesc | 1 | ||||
-rwxr-xr-x | bin/slugify | 1 | ||||
-rwxr-xr-x | bin/stopwatch | 1 | ||||
-rwxr-xr-x | bin/tmp | 3 | ||||
-rwxr-xr-x | bin/tmpname | 1 | ||||
-rwxr-xr-x | bin/tuivid | 1 | ||||
-rwxr-xr-x | bin/uc | 1 | ||||
-rwxr-xr-x | bin/untill | 5 | ||||
-rwxr-xr-x | bin/update | 1 | ||||
-rwxr-xr-x | bin/uuid | 1 | ||||
-rwxr-xr-x | bin/vcs | 16 | ||||
-rwxr-xr-x | bin/volume | 1 | ||||
-rwxr-xr-x | bin/without-env | 17 | ||||
-rwxr-xr-x | bin/wms | 1 | ||||
-rwxr-xr-x | bin/xmpp | 1 | ||||
-rwxr-xr-x | bin/yt | 2 | ||||
-rwxr-xr-x | bin/z | 4 |
58 files changed, 200 insertions, 26 deletions
@@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/assert-arg b/bin/assert-arg index 3c8990a..477a571 100755 --- a/bin/assert-arg +++ b/bin/assert-arg @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -17,6 +17,8 @@ help() { Options: -h, --help show this message + FILE specific path to be written + Hydrate software project with auxiliary files. If FILE is given, restrict effect to those paths. @@ -43,6 +43,7 @@ help() { $ backup + Create backup with comment, and verbose mode active: $ backup -qC 'The backup has a comment' my-backup @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -F force remove the cache file -h, --help show this message @@ -11,6 +11,7 @@ usage() { help() { cat <<-'EOF' + Options: -m MESSAGE text message of the desktop notification (default: COMMAND) @@ -26,6 +27,7 @@ help() { $ boop echo 123 + Fail with the underlying 127 return code with the message "ERROR": @@ -12,9 +12,14 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + NUMBER the number to be clamped + MIN lower bound + MAX upper bound + Clamp the NUMBER between MIN and MAX. @@ -26,11 +31,13 @@ help() { $ clamp 5 3 9 5 + When a number is below MIN it gets clamped: $ clamp 1 3 9 3 + When a number is above MAX it gets clamped: $ clamp 15 3 9 @@ -13,19 +13,24 @@ usage() { help() { cat <<-'EOF' + Options: - -c COLOR + -c COLOR color name -h, --help show this message + TEXT literal string to be coloured + - Print the given text with a color. + Print TEXT using COLOR. The available colors are: EOF + list_colors | sed 's/^/ /' cat <<-'EOF' + Examples: Print "banana" in yellow: @@ -33,6 +38,7 @@ help() { $ color -c yellow 'banana' banana + Print "grass" in green, with a newline: $ color -c green 'grass\n' @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - copy [-n] < STDIN + copy [-n] copy -h EOF } @@ -12,17 +12,25 @@ usage() { help() { cat <<-'EOF' + Options: -n remove newlines -h, --help show this message + + Copy data from STDIN to the X11 clipboard. + + Examples: Copy numbers to clipboard: - seq 10 | copy + + $ seq 10 | copy + Copy string without newline: - echo 'with automatic newline' | copy -n + + $ echo 'with automatic newline' | copy -n EOF } @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -29,6 +30,7 @@ help() { $ dice 3 + Roll a D20: $ dice 20 @@ -12,11 +12,18 @@ usage() { help() { cat <<-'EOF' + Options: - -h, --help + -h, --help show this message + + FILE path to the file + + Flexibly run a text editor, either directly or in a pipe. + + The editor used is either $VISUAL or $EDITOR, with a fallback to + vi in case any of those variables aren't defined. - Flexibly run a text editor, either directly on in a pipe. Examples: @@ -24,12 +31,10 @@ help() { $ e file.txt + Manipulate the content of a pipe midway: $ seq 10 | e | grep 5 - - The editor used is either $VISUAL or $EDITOR, with a fallback to - vi in case any of those variables aren't defined. EOF } @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -s SUBJECT the email subject (default: "CLI email: No subject") -f FROM the addr to send from (default: "eu@euandre.org") diff --git a/bin/forever b/bin/forever index a865fa3..aad2a29 100755 --- a/bin/forever +++ b/bin/forever @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - forever [-q] -- COMMAND... + forever [-q] COMMAND... forever -h EOF } @@ -12,10 +12,13 @@ usage() { help() { cat <<-'EOF' + Options: -q quiet mode, don't print exit code messages -h, --help show this message + COMMAND shell command to be wrapped + Run COMMAND forever. @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/gen-password b/bin/gen-password index 327858f..07ed9ab 100755 --- a/bin/gen-password +++ b/bin/gen-password @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/git-cleanup b/bin/git-cleanup index 4196cff..f09fe9f 100755 --- a/bin/git-cleanup +++ b/bin/git-cleanup @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -r RECIPIENT the recipient to encrypt to. Can be provided multiple times for multiple recipients. @@ -23,18 +24,22 @@ help() { FILENAME The GPG-encrypted file to be processed. If it doesn't exist yet, it will be created. + + Edit the encripted FILENAME in a pipeline, using COMMAND to + modify the content. If COMMAND emits a non-zero return code, + the file is left unmodified. + + Examples: Edit "secrets.txt.gpg" using `vipe` and the default recipient: $ grun secrets.txt.gpg -- vipe + Delete lines containing "TODO" in todos.gpg for specific keys: $ grun -r ABC123DEF321 todos.gpg -- sed '/TODO/d' - - If COMMAND emits a non-zero return code, the file is left - unmodified. EOF } diff --git a/bin/htmlesc b/bin/htmlesc index 0e4c75a..436ed54 100755 --- a/bin/htmlesc +++ b/bin/htmlesc @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -e escape the string (the default action) -d unescape (de-escape?) the string @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -39,6 +39,13 @@ help() { $ echo bbb | ifnew new-file $ stat --print='%y' new-file # timestamp 2 + + + Only change file when content changes in a Makefile: + + i18.cfg: ALWAYS + gen-cfg | ifnew $@ + po4a $@ EOF } @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,9 +12,13 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + NUMBER the list of numbers to get the max from + + Get the maximum number from the given values. @@ -25,16 +29,19 @@ help() { $ min 5 3 9 9 4 9 + Get the maximum number when negative numbers are given $ max -- -3 -5 -3 + Get the maximum number given a single number $ max 8 8 + The maximum default number: $ max @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,9 +12,12 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + NUMBER the list of numbers to get the min from + Get the minimun number from the given values. @@ -26,16 +29,19 @@ help() { $ min 5 3 9 9 4 3 + Get the minimum number when negative numbers are given $ min -- -3 -5 -5 + Get the minimum number given a single number $ min 8 8 + The minimum default number: $ min diff --git a/bin/mkdtemp b/bin/mkdtemp index 3729dd4..9c5f8c8 100755 --- a/bin/mkdtemp +++ b/bin/mkdtemp @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/mkstemp b/bin/mkstemp index 4097e59..ded9837 100755 --- a/bin/mkstemp +++ b/bin/mkstemp @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -X send MESSAGE using the `xmpp` command -s play $XDG_DATA_HOME/msg/{good,bad}.ogg sound @@ -25,12 +26,17 @@ help() { MESSAGE the text to be sent by the relevant channel + + Send MESSAGE via all the selected channels. + + Examples: Ring a terminal bell and play a sound, representing an error: $ msg -1sb + Send an email and an XMPP message: $ msg -mX 'The message goes here' diff --git a/bin/n-times b/bin/n-times index c8d10d8..660b734 100755 --- a/bin/n-times +++ b/bin/n-times @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - n-times COUNT -- COMMAND... + n-times COUNT COMMAND... n-times -h EOF } @@ -12,12 +12,16 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message COUNT the number of times for COMMAND to be executed + Run COMMAND, COUNT times. + + Examples: Print 123 5 times: @@ -17,6 +17,7 @@ sub usage($fh) { sub help($fh) { print $fh <<~'EOF'; + Options: -h, --help show this message @@ -39,11 +39,11 @@ help() { 'build-1/' directory with: build-1/ - Makefile -> /absolute/path/to/Makefile - README.md -> /absolute/path/to/README.md + Makefile -> ../Makefile + README.md -> ../README.md src/ - file1.ext -> /absolute/path/to/file1.ext - file2.ext -> /absolute/path/to/file2.ext + file1.ext -> ../../src/file1.ext + file2.ext -> ../../src/file2.ext With that one can `cd build-1/` and run builds there, without the build artifacts littering the source tree. Also, one could @@ -99,5 +99,5 @@ mkdir -p "$BUILD_DIRECTORY" while read -r f; do mkdir -p "$BUILD_DIRECTORY"/"$(dirname "$f")" - ln -fs "$PWD"/"$f" "$BUILD_DIRECTORY"/"$f" + ln -rfs "$PWD"/"$f" "$BUILD_DIRECTORY"/"$f" done @@ -12,19 +12,30 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + FILE path to file to be opened + + + Wrapper for xdg-open(1). + + Examples: Open an HTML file on the current $BROWSER: + $ open index.html + Open multiple PDF files (with zathura): + $ open *.pdf EOF } + for flag in "$@"; do case "$flag" in --) @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/playlist b/bin/playlist index 8b9271f..ebe0902 100755 --- a/bin/playlist +++ b/bin/playlist @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,10 +12,14 @@ usage() { help() { cat <<-'EOF' + Options: -c COLOR ANSI color to be used on the prefix text -h, --help show this message + PREFIX the string to insert at the beginning + + Prefix STDIN with PREFIX. @@ -12,24 +12,38 @@ usage() { help() { cat <<-'EOF' + Options: -d print duplex/double-sided -q QUALITY choose the print quality, either: low, medium (default) or high. -h, --help show this message + FILE path to file to be printed + + + Print FILE using CUPS using lp(1). + + Examples: Print the given PostScript file with default quality: + $ print f1.ps + Print multiple PDF files with high quality: + $ print -dq high *.pdf + Print the file from STDIN, double-sided: + $ print -d < f2.ps + Print multiple source code files: + $ print src/*.{c,h} EOF } @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -24,7 +25,7 @@ help() { Examples: - Conditionally run download command + Conditionally run download command: if prompt 'Download files?'; then run_download; @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -s PIXEL_SIZE size of the pixel (default 10) -h, --help show this help message diff --git a/bin/reconfigure b/bin/reconfigure index d166819..ca38cb1 100755 --- a/bin/reconfigure +++ b/bin/reconfigure @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -U run update(1) before acting -h, --help show this message @@ -23,12 +23,16 @@ usage() { help() { cat <<-'EOF' + Options: -w show the path to the RFC file instead of displaying its contents -u update the local RFC database -h, --help show this message + RFC_NUMBER the RFC id number + + Lookup the given RFC in $XDG_DATA_HOME/doc/rfc/ (defaults to ~/.local/share), and feed it into the $PAGER, akin to doing: @@ -42,7 +46,6 @@ help() { Examples: - Show RFC 1234 in $PAGER: $ rfc 1234 @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -d DIRECTORY the directory to serve (default: ".") -p PORT the port to listen on (default: find one) @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/slugify b/bin/slugify index 955a849..834e4bc 100755 --- a/bin/slugify +++ b/bin/slugify @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/stopwatch b/bin/stopwatch index 3d5cd07..14182d2 100755 --- a/bin/stopwatch +++ b/bin/stopwatch @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -13,10 +13,13 @@ usage() { help() { cat <<-'EOF' + Options: -d delete the remote "tmp/" folder -h, --help show this message + FILE path to files to be copied + Copies a file to the public server. diff --git a/bin/tmpname b/bin/tmpname index 89d7e4d..ea3f0aa 100755 --- a/bin/tmpname +++ b/bin/tmpname @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -13,6 +13,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - until [-m MAX] [-n SECONDS] -- COMMAND... + until [-m MAX] [-n SECONDS] COMMAND... until -h EOF } @@ -12,12 +12,15 @@ usage() { help() { cat <<-'EOF' + Options: -n SECONDS the amount of seconds to sleep between attempts (default: 5) -m MAX the maximum number of attempts (default: unlimited) -h, --help show this message + COMMAND the shell command to be executed + Runs COMMAND until it eventually succeeds, trying atmost MAX times. Sleep SECONDS between attempts. @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -191,6 +191,22 @@ help() { - status - gc - ls + + + Wrapper command for normalizing options of differenct version + control software. + + + Examples: + + Say the type of repo in "project/": + + $ vcs -C project/ -t + + + Fetch updates for VCS in current directory: + + $ vcs fetch EOF } @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message diff --git a/bin/without-env b/bin/without-env index 57c2d2e..4e7ed15 100755 --- a/bin/without-env +++ b/bin/without-env @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - without-env ENVVAR PATH -- COMMAND... + without-env ENVVAR PATH COMMAND... without-env -h EOF } @@ -12,17 +12,30 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + ENVVAR the name of the environment variable to be modifed + PATH section to be excluded from ENVVAR + COMMAND command to be wrapped + + + Execute COMMAND, but changing the variable ENVVAR by excluding + PATH from it. + + Examples: Execute "command -V" filtering ~/bin, to get where "w3m" is in $PATH, other than ~/bin: + $ without-env PATH ~/bin -- command -v w3m + Compile foo.c, excluding ~/.local/include from $C_INCLUDE_PATH: + $ without-env C_INCLUDE_PATH ~/.local/include -- cc -co foo.o foo.c EOF } @@ -60,7 +73,7 @@ shift $((OPTIND - 1)) eval "$(assert-arg -- "${1:-}" 'ENVVAR')" eval "$(assert-arg -- "${2:-}" 'PATH')" -eval "export $1=\"\$(echo \"\$$1\" | sed \"s|\$2:||g\")\"" +eval "export $1=\"\$(echo \"\$$1\" | sed \"s|\$2||g\")\"" shift # drop $1 shift # drop $2 if [ "${1:-}" = '--' ]; then @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message @@ -12,6 +12,7 @@ Usage: xmpp -h""" HELP = """ + Options: -d run in DEBUG mode -m MESSAGE the text of the message to be sent @@ -12,6 +12,7 @@ usage() { help() { cat <<-'EOF' + Options: -n PLAYLIST_COUNT the number of videos to grab from a playlist (default: 15) @@ -23,6 +24,7 @@ help() { FILE a file with 'https://...' addresses, one per line + Download videos and store them locally. @@ -13,7 +13,7 @@ use List::Util qw(any); sub usage($fh) { print $fh <<~'EOF'; Usage: - z COMMANDS... + z COMMAND... z -h EOF } @@ -25,6 +25,8 @@ sub help($fh) { Options: -h, --help show this message + COMMAND shell command to be wrapped + Wrapper that uncompresses file arguments to commands. This enables having commands that operate on plain files to not |