1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 10:53:23 -07:00

flesh out the compatibility table

This commit is contained in:
Connor Olding 2021-09-23 06:48:05 -07:00
parent 9dc69caebd
commit 112a7a6d63
56 changed files with 110 additions and 23 deletions

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# though technically compatible with other shells,
# extra functionality is through zsh's extended arithmetic functions.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
whoa=(
-Wall

View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
# TODO: portable way of dodging aliases to allow other shell support?

3
sh/bak
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
bak() { ### @-
### backup files by creating copies and appending ".bak" to their names.
@ -20,7 +21,7 @@ bak() { ### @-
### ```
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
local ret=0
local f
local f=
for f; do
if [ -e "$f.bak" ]; then
bak "$f.bak" || { ret=1; continue; }

View File

@ -3,6 +3,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
baks() { ### @-
### backup files by copying each and appending *the current* date-time,

1
sh/bin
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# though technically compatible with other shells,
# extra functionality is through zsh's extended arithmetic functions.

View File

@ -1,5 +1,8 @@
#!/usr/bin/env zsh
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
cdbusiest() { ### @-
### cd to the directory with the most files in it, counted recursively.
@ -17,4 +20,6 @@ cdbusiest() { ### @-
cd $d
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} dbusiest
[ -n "${preload+-}" ] || cdbusiest "$@"

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
colors() { ### @-
### display all combinations of foreground and background terminal colors.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
setup_clang_ubuntu() { ### @-
### print (but don't execute) the commands necessary to install

View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
cutv() { ### @-
### (WIP) create a short clip of a long video file.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
days() { ### @-
### compute the number of days since a given date.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
dbusiest() { ### @-
### list directories ordered descending by the number of files in them,

3
sh/dfu
View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox awk.
dfu() { ### @-
### pretty-print `df` in GiB.

View File

@ -2,9 +2,8 @@
# disassembles a function given its symbolic name.
# YES_ZSH
# YES_BASH
# YES_DASH
# TODO: actually test that this works with dash.
# does not work with busybox sed (yet?)
disf() { ### @-
### disassemble a single function from an unstripped executable, unreliably.

1
sh/e
View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
e() { ### @-
### wrap around `$EDITOR` to run it as root if necessary.

1
sh/ea
View File

@ -3,6 +3,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
ea() { ### @- **TODO:** document.
local cmd="${1:?missing subcommand}"; shift

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
echo2() { ### @-
### print arguments joined by spaces to stderr without parsing anything.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
explore() { ### @- open a single directory in `explorer.exe`, defaulting to `$PWD`.
[ -n "$MSYSTEM" ] || { printf "%s\n" "$0: only for MSYS2" >&2; return 1; }

View File

@ -5,6 +5,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
ghmd() { ### @-
### convert a markdown file to HTML in the style of GitHub.

1
sh/has
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
has() { ### @-
### print the result of `which` if the program is found, else simply return 1.

1
sh/hex
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# though technically compatible with other shells,
# extra functionality is through zsh's extended arithmetic functions.

1
sh/ify
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
ify() { ### @-
### pipe one command through another, so you can still pass arguments to the former.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
is_empty() { ### @-
### return 0 if the directory given by argument is empty.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
isup() { ### @-
### return 0 if a given website returns a 2xx HTTP code.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
maybesudo_() { ### @-
### mimic certain features of `sudo` for systems without it installed.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
minutemaid() { ### @-
### return 0 and/or execute a command if the current minute

View File

@ -1,5 +1,8 @@
#!/usr/bin/env zsh
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
monitor() { ### @-
### this is [watch(1)](https://www.man7.org/linux/man-pages/man1/watch.1.html)

View File

@ -1,14 +1,15 @@
#!/usr/bin/env sh
# the first expression is taken from this FAQ:
# https://perldoc.perl.org/perlfaq6.html#How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file%3f
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# TODO: what's the minimum version of perl required for this?
noccom() { ### @-
### strip C-like comments; both multi-line and single-line.
# the first expression is taken from this FAQ:
# https://perldoc.perl.org/perlfaq6.html#How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file%3f
[ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <<EOF
#!/usr/bin/env perl

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
note() { ### @-
### act like [`echo2`,](#echo2) but use a bright color to stand out more.

15
sh/now
View File

@ -2,8 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# dash compatibility is not fully tested, but it's probably okay.
# YES_ASH
now() { ### @-
### print a date-time (UTC) in a sortable format.
@ -18,8 +17,8 @@ now() { ### @-
### 2009-02-13_84690000
### ```
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
local dt
local fmt='+%F_%T_%N'
local dt= fmt='+%F_%T_%N'
if [ -z "$1" ]; then
dt="$(date -u "$fmt")"
elif [ -e "$1" ]; then
@ -28,12 +27,12 @@ now() { ### @-
dt="$(date -u -d "$1" "$fmt")"
fi
local F T N
local F= T= N=
F=${dt%%_*}
T=${dt#*_}
T=${T%_*}
N=${dt##*_}
local H M S
local H= M= S=
H=${T%%:*}
M=${T#*:}
M=${M%:*}
@ -47,8 +46,8 @@ now() { ### @-
M=${M#0*}
S=${S#0*}
local ms
ms=$(((H*60*60+M*60+S)*1000+N/1000000))
local ms=
ms=$(( (H*60*60+M*60+S)*1000+N/1000000 ))
ms=$(printf '%08i' $ms)
echo "${F}_${ms}"
}

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# TODO: does this work with busybox awk?
pacbm() { ### @-
### display and order installed pacman packages by their filesize ascending,

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
pause() { ### @-
### pause — the companion script of [`confirm`.](#confirm)

View File

@ -2,8 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# TODO: source pippy here? this may affect dash compatibility.
# YES_ASH
pegg() { ### @-
### download and (pip) install a Python "egg" from a project on GitHub,
@ -19,4 +18,6 @@ pegg() { ### @-
pippy "https://github.com/$1/$2/tarball/${3:-master}#egg=$2"
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} pippy
[ -n "${preload+-}" ] || pegg "$@"

View File

@ -1,15 +1,17 @@
#!/usr/bin/env sh
# YES_ZSH
#. ~/sh/maybesudo
#. ~/sh/has
# YES_BASH
# YES_DASH
# YES_ASH
pippy() { ### @-
### install Python packages using pip,
### but only update their dependencies as required.
### this uses [`maybesudo`](#maybesudo_-shmaybesudo) internally.
local sudo="$(has sudo || echo maybesudo_)"
"$sudo" py -m pip install --upgrade --upgrade-strategy only-if-needed "$@"
"$sudo" python3 -m pip install --upgrade --upgrade-strategy only-if-needed "$@"
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} has maybesudo
[ -n "${preload+-}" ] || pippy "$@"

1
sh/pre
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
pre() { ### @-
### dump all the `#define`s that `$CC $CPPFLAGS $CFLAGS $LDFLAGS` would result in.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
psbm() { ### @-
### display and order processes by their memory usage ascending, and their sum.

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox.
randir() { ### @-
### display a random directory in the current working directory.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
refresh() { ### @- invoke `hash -r`.
hash -r

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox tr.
rot13() { ### @-
### rot13 with numbers rotated as well.

3
sh/rs
View File

@ -1,5 +1,8 @@
#!/usr/bin/env zsh
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
rs() { ### @-
### record screen. does not record audio.

8
sh/sc
View File

@ -1,4 +1,8 @@
#!/usr/bin/env bash
# NO_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
sc_shorten() {
REPLY="${1:2:2}${1:5:2}${1:8:2}${1:11:12}"
@ -16,7 +20,7 @@ copy_scr() {
local r='20\d\d-\d\d-\d\d_\d\d\d\d\d\d\d\d.(png|jpg)'
grep -Pq "$r" <<<"$short" || return 1
eaput "$fn" "$short"
ea put "$fn" "$short"
sc_shorten "$short"
uri_encode "$REPLY"
REPLY="$_REMOTE_DOMAIN/s/$REPLY"
@ -27,7 +31,7 @@ copy_tmp() {
local fn="$1"
local short="$(basename "$fn")"
eaput "$fn" "$short"
ea put "$fn" "$short"
uri_encode "$short"
REPLY="$_REMOTE_DOMAIN/t/$REPLY"
return 0

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# does not work with busybox sed (yet?)
scramble() { ### @-
### scrambles text in a predictable way using regex.

View File

@ -1,5 +1,8 @@
#!/usr/bin/env zsh
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
screeny() { ### @-
### handle GNU screens.

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# does not work with busybox awk (yet?)
similar() { ### @-
### highlight adjacent lines up to the first inequivalent character.

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox ash.
slit() { ### @-
### view specific columns of text.

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox ash.
slitt() { ### @-
### view specific columns of text.

View File

@ -2,6 +2,8 @@
# awful things
# YES_ZSH
# YES_BASH
# NO_DASH
# NO_ASH
mpvs() { ### @- invoke mpv with some extra flags suited for streamed sources.
mpv --quiet \

1
sh/sum
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
sum() { ### @-
### compute the summation of its arguments without forking processes.

3
sh/sv
View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# works with busybox awk.
sv() { ### @-
### collect the lastmost value of every key.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
tpad() { ### @-
### add a 1px transparent border around an image to prevent twitter from mangling it into a jpg.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
trash() { ### @-
### output a given number of bytes from `/dev/random`.

View File

@ -2,6 +2,9 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# does not work with busybox awk (yet?)
trunc() { ### @-
### truncate text to fit within your terminal using the unicode character `…`.

View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
unscreen() { ### @-
### handle closing of screens — this works alongside [`screeny`](#screeny).

1
sh/wat
View File

@ -2,6 +2,7 @@
# YES_ZSH
# NO_BASH
# NO_DASH
# NO_ASH
# wat - a better and recursive which/whence
# via: https://leahneukirchen.org/dotfiles/tools.html

View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
wipe() { ### @-
### clear the screen and its scrollback, then print a high-contrast horizontal line.
@ -12,13 +13,13 @@ wipe() { ### @-
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
clear
clear # twice because mintty is weird
echo $'\033[30m\033[107m' | tr -d '$'
printf '\033[30m\033[107m\n'
if [ -n "${ZSH_VERSION:-}" ]; then
printf '*%.0s' {1..$COLUMNS}
else
tput cols | awk '{for(i=0;i<$0;i++)printf "*"}'
fi
echo $'\033[0m\n' | tr -d '$'
printf '\033[0m\n\n'
}
[ -n "${preload+-}" ] || wipe "$@"

1
sh/xxp
View File

@ -2,6 +2,7 @@
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
xxp() { ### @-
### act like `xxd -p`, but nicely formatted.