diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-26 10:59:50 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-26 10:59:50 +1300 |
commit | 8088b97f99ce2f0f2424ca231147f814eaa4c0cb (patch) | |
tree | b22ee2dcc737b47a6dfca1b30f20eff78113ec21 | |
parent | Merge branch 'master' into port/sunos/illumos/openindiana (diff) | |
parent | Correct misnamed variable (diff) | |
download | dotfiles-8088b97f99ce2f0f2424ca231147f814eaa4c0cb.tar.gz dotfiles-8088b97f99ce2f0f2424ca231147f814eaa4c0cb.zip |
Merge branch 'master' into port/sunos/illumos/openindiana
-rw-r--r-- | IDEAS.markdown | 4 | ||||
-rw-r--r-- | bin/chc.sh | 7 | ||||
-rw-r--r-- | bin/fnl.sh | 4 | ||||
-rw-r--r-- | bin/mktd.sh | 3 | ||||
-rw-r--r-- | bin/mw.awk | 2 | ||||
-rw-r--r-- | bin/onl.awk | 5 | ||||
-rw-r--r-- | bin/plmu.sh | 2 | ||||
-rw-r--r-- | bin/rfct.awk | 10 | ||||
-rw-r--r-- | games/aaf.sh | 2 | ||||
-rw-r--r-- | games/chkl.sed | 1 | ||||
-rw-r--r-- | games/dr.sh | 4 | ||||
-rw-r--r-- | games/kvlt.sed | 4 | ||||
-rw-r--r-- | games/philsay.sh | 1 | ||||
-rw-r--r-- | games/rndn.sh | 1 | ||||
-rw-r--r-- | games/strik.sed | 64 | ||||
-rw-r--r-- | games/xyzzy.sh | 2 | ||||
-rw-r--r-- | keychain/profile.d/keychain.sh | 2 | ||||
-rw-r--r-- | man/man6/strik.6df | 10 | ||||
-rw-r--r-- | perlcritic/perlcriticrc | 22 | ||||
-rw-r--r-- | sh/profile.d/downloads.sh | 5 | ||||
-rw-r--r-- | sh/shrc.d/grep.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/ls.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/tree.sh | 2 | ||||
m--------- | vim/bundle/commentary | 0 | ||||
m--------- | vim/bundle/html5 | 0 | ||||
m--------- | vim/bundle/lion | 0 | ||||
m--------- | vim/bundle/pathogen | 0 | ||||
m--------- | vim/bundle/targets | 0 | ||||
m--------- | vim/bundle/unimpaired | 0 |
29 files changed, 68 insertions, 93 deletions
diff --git a/IDEAS.markdown b/IDEAS.markdown index f267be12..544530e3 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -1,6 +1,10 @@ Ideas ===== +* A wrapper ksw(1df) (kill-switch) that caches SIGINT traps to kill a called + program or loop immediately rather than aborting a loop (is this possible?) +* A wrapper sil(1df) or nec(1df) to turn stty -echo off for the duration of a + paste? * I can probably share my psql() completions/shortcuts after sanitizing them a bit * Wouldn't be too hard to add some HTTP BASIC auth to ix(1df) to make pastes @@ -1,5 +1,12 @@ # Cache the output of a command and emit it straight from the cache if not # expired on each run +self=chc + +# Check arguments for sanity +if [ "$#" -lt 3 ] ; then + printf >&2 '%s: Need a cache path, a duration, and a command\n' "$self" + exit 2 +fi # First argument is the cache path, second is the duration in seconds cac=$1 dur=$2 @@ -9,7 +9,9 @@ fi # Create a temporary directory; note that we *don't* clean it up on exit dir=$(mktd fnl) || exit -# Run the command; keep its exit status +# Run the command; keep its exit status; wrap the command in braces so that the +# out files are always opened even if the command is not found or otherwise +# can't be run; some BSD shells require this, I forget which ones { "$@" ; } >"$dir"/stdout 2>"$dir"/stderr ret=$? diff --git a/bin/mktd.sh b/bin/mktd.sh index 89cdc7c3..72375873 100644 --- a/bin/mktd.sh +++ b/bin/mktd.sh @@ -2,7 +2,8 @@ # Build the intended directory name, with the last element a random integer # from 1..2^31 -dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648) +lim=$((2 << 31)) +dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 "$lim") # Create the directory and print its name if successful mkdir -m 700 -- "$dn" && printf '%s\n' "$dn" @@ -1,7 +1,7 @@ # Crude approach to get alphabetic words one per line from input, not sorted or # deduplicated BEGIN { - FS = "(--|['_-]*[^[:alnum:]'_-]+['_-]*)" + FS = "(--|['_-]*[^a-zA-Z0-9_'_-]+['_-]*)" } { for (i = 1; i <= NF; i++) diff --git a/bin/onl.awk b/bin/onl.awk index 15e4f46d..89469f3c 100644 --- a/bin/onl.awk +++ b/bin/onl.awk @@ -2,8 +2,9 @@ # For each line of input ... { - # Strip out whitespace characters and rebuild the fields - gsub(/[\n\t\r ]+/, "") + # Replace groups of spaces and control characters with one space, + # implicitly re-splitting the fields + gsub(/[\a\b\f\n\r\t\v ]+/, " ") # Print each field, without a newline; add a leading space if it's not the # very first one diff --git a/bin/plmu.sh b/bin/plmu.sh index b6a500ac..78778920 100644 --- a/bin/plmu.sh +++ b/bin/plmu.sh @@ -14,7 +14,7 @@ fi # the existing sorting plenv list-modules | sort | -# Exclude any modules in ~.plenv/non-cpanm-modules if it exists +# Exclude any modules in ~/.plenv/non-cpanm-modules if it exists comm -23 -- - "$ef" | # Read that list of modules to upgrade and upgrade them one by one diff --git a/bin/rfct.awk b/bin/rfct.awk index 4467f206..3d942b58 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -6,8 +6,12 @@ BEGIN { ORS = "\n\n" } -# Strip out control characters, except tab and newline -{ gsub(/[^[:print:]\n\t]/, "") } +# Skip paragraphs with ^L chars in them, as they likely contain headers and +# footers +/\f/ { next } -# If there's anything left, print it +# Strip out other control characters, but allow newline and tab +{ gsub(/[\a\b\r\v]/, "") } + +# If there's anything left after that, print it length($0) diff --git a/games/aaf.sh b/games/aaf.sh index 4f1825c6..24094a73 100644 --- a/games/aaf.sh +++ b/games/aaf.sh @@ -1,3 +1,3 @@ -#!/bin/sh +# Print a random ASCII Art Fart curl http://www.asciiartfarts.com/random.cgi | pup -p 'table[cellpadding]' pre text{} diff --git a/games/chkl.sed b/games/chkl.sed index 40c35cee..6e4b1c77 100644 --- a/games/chkl.sed +++ b/games/chkl.sed @@ -1,4 +1,3 @@ -#!/bin/sed -f # Change an ASCII checklist with [/], [x], and [ ] boxes to a Unicode one /^#/d s_^\[ \]_☐_ diff --git a/games/dr.sh b/games/dr.sh index 9f08164d..df21d7a5 100644 --- a/games/dr.sh +++ b/games/dr.sh @@ -1,4 +1,3 @@ -#!/bin/sh # Roll D&D-style dice in a ndn+n formula, e.g. 10d6+2 # Need exactly one argument @@ -23,8 +22,7 @@ esac # Roll the dice the appropriate number of times using rndi(1df) i=0 t=0 while [ "$i" -lt "$n" ] ; do - seed=$(rnds) - r=$(rndi 1 "$d" "$seed") + r=$(rndi 1 "$d") t=$((t + r)) i=$((i + 1)) done diff --git a/games/kvlt.sed b/games/kvlt.sed index e2905a35..461fc04f 100644 --- a/games/kvlt.sed +++ b/games/kvlt.sed @@ -53,10 +53,10 @@ s,C\([^H]\),K\1,g # -S[^H] -> Z (so "sharp" doesn't become "ZHARP") s,S\([^H]\),Z\1,g -# consant-I-consonant -> -Y- +# consonant-I-consonant -> -Y- s,\([B-DF-HJ-NP-TV-XZ]\)I\([B-DF-HJ-NP-TV-XZ]\),\1Y\2,g -# consant-U-consonant -> -V- +# consonant-U-consonant -> -V- s,\([B-DF-HJ-NP-TV-XZ]\)U\([B-DF-HJ-NP-TV-XZ]\),\1V\2,g # THE -> DER diff --git a/games/philsay.sh b/games/philsay.sh index 9270c52e..1c02bf57 100644 --- a/games/philsay.sh +++ b/games/philsay.sh @@ -1,3 +1,4 @@ +# Ha, ha, ha! ASCII! speech=$(pks "$@") || exit printf '\n%066s\n' '( '"$speech"' )' cat <<'EOF' diff --git a/games/rndn.sh b/games/rndn.sh index 18c34218..bcde9c3c 100644 --- a/games/rndn.sh +++ b/games/rndn.sh @@ -1,4 +1,3 @@ -#!/bin/sh # Esoteric random number generator # Single optional argument is a random seed, otherwise use rnds(1df) diff --git a/games/strik.sed b/games/strik.sed index bc1cbdc5..cda6b797 100644 --- a/games/strik.sed +++ b/games/strik.sed @@ -1,64 +1,2 @@ # Strike out text -s/a/a̶/g -s/b/b̶/g -s/c/c̶/g -s/d/d̶/g -s/e/e̶/g -s/f/f̶/g -s/g/g̶/g -s/h/h̶/g -s/i/i̶/g -s/j/j̶/g -s/k/k̶/g -s/l/l̶/g -s/m/m̶/g -s/n/n̶/g -s/o/o̶/g -s/p/p̶/g -s/q/q̶/g -s/r/r̶/g -s/s/s̶/g -s/t/t̶/g -s/u/u̶/g -s/v/v̶/g -s/w/w̶/g -s/x/x̶/g -s/y/y̶/g -s/z/z̶/g -s/A/A̶/g -s/B/B̶/g -s/C/C̶/g -s/D/D̶/g -s/E/E̶/g -s/F/F̶/g -s/G/G̶/g -s/H/H̶/g -s/I/I̶/g -s/J/J̶/g -s/K/K̶/g -s/L/L̶/g -s/M/M̶/g -s/N/N̶/g -s/O/O̶/g -s/P/P̶/g -s/Q/Q̶/g -s/R/R̶/g -s/S/S̶/g -s/T/T̶/g -s/U/U̶/g -s/V/V̶/g -s/W/W̶/g -s/X/X̶/g -s/Y/Y̶/g -s/Z/Z̶/g -s/0/0̶/g -s/1/1̶/g -s/2/2̶/g -s/3/3̶/g -s/4/4̶/g -s/5/5̶/g -s/6/6̶/g -s/7/7̶/g -s/8/8̶/g -s/9/9̶/g -s/ / ̶/g +s/./&̶/g diff --git a/games/xyzzy.sh b/games/xyzzy.sh index d262c0e6..5cc03278 100644 --- a/games/xyzzy.sh +++ b/games/xyzzy.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# ADVENTURE if [ -e "$HOME"/.xyzzy ] ; then printf >&2 '%s\n' 'Nothing happens.' exit 1 diff --git a/keychain/profile.d/keychain.sh b/keychain/profile.d/keychain.sh index c0319d49..63eb613a 100644 --- a/keychain/profile.d/keychain.sh +++ b/keychain/profile.d/keychain.sh @@ -2,4 +2,4 @@ command -v keychain >/dev/null 2>&1 || return eval "$(TERM=${TERM:-ansi} keychain \ --eval --ignore-missing --quick --quiet \ - id_dsa id_rsa id_ecsda id_ed25519)" + id_dsa id_rsa id_ecdsa id_ed25519)" diff --git a/man/man6/strik.6df b/man/man6/strik.6df index 3d5840a7..92b92074 100644 --- a/man/man6/strik.6df +++ b/man/man6/strik.6df @@ -10,10 +10,10 @@ lynx -dump https://sanctum.geek.nz/ | .B strik .SH DESCRIPTION .B strik -converts the 26 letters of the English alphabet, both upper and lower case, the -Arabic numerals, and the space character to their equivalents with a Unicode -strikethrough. -.P -The results are printed in UTF-8; they're hard-coded within the script. +adds a Unicode combining strikethrough character COMBINING LONG STROKE OVERLAY +(U+0036) after each character of input, giving the appearance of struck-out +text with appropriate glyph support. +.SH SEE ALSO +<http://www.fileformat.info/info/unicode/char/0036/index.htm> .SH AUTHOR Tom Ryder <tom@sanctum.geek.nz> diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index ed1d9064..bc8453f8 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -1,5 +1,23 @@ +# No mercy! severity = brutal -exclude = Bangs::ProhibitBitwiseOperators +# I flatly disagree with this policy; sometimes bitwise operators are in fact +# what I want, and I don't have the problem of using | instead of || as the +# policy documentation suggests +[-Bangs::ProhibitBitwiseOperators] + +# Add some networking terms to the list of legal numbered names [Bangs::ProhibitNumberedNames] -exceptions = inet4 inet6 ipv4 ipv6 md5 sha1 sha256 sha512 x11 utf8 +add_exceptions = inet4 inet6 ipv4 ipv6 + +# I'll keep code running for old Perls, but users are on their own with +# documentation, so allow e.g. L<http://...> on Perl 5.6 +[-Compatibility::PodMinimumVersion] + +# This one causes more trouble than it's worth, too +[-Documentation::RequirePODUseEncodingUTF8] + +# Soften this policy a bit; tolerate all the single-digit integers as literals, +# and also three powers of 10 (for percentages, milliseconds etc) +[ValuesAndExpressions::ProhibitMagicNumbers] +allowed_values = 0..9 10 100 1000 diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh index fb8dd64a..865cb859 100644 --- a/sh/profile.d/downloads.sh +++ b/sh/profile.d/downloads.sh @@ -15,6 +15,7 @@ esac # Count files in each directory, report if greater than zero ( + lc=0 while IFS= read -r dir ; do case $dir in '#'*) continue ;; @@ -23,6 +24,8 @@ esac set -- "$dir"/* [ -e "$1" ] || shift [ "$#" -gt 0 ] || continue - printf '\nYou have %u unsorted files in %s.\n\n' "$#" "$dir" + printf 'You have %u unsorted files in %s.\n' "$#" "$dir" + lc=$((lc+1)) done < "$HOME"/.downloads + [ "$((lc > 0))" -eq 1 ] && printf '\n' ) diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index dd85a198..3df1ee9a 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -14,7 +14,7 @@ grep() { # Add --color=auto if the terminal has at least 8 colors [ -e "$HOME"/.cache/sh/opt/grep/color ] && - [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && + [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" # Add --devices=skip to gracefully skip devices diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index b5acfcf9..d58c64f9 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -25,7 +25,7 @@ ls() { # Add --color if the terminal has at least 8 colors [ -e "$HOME"/.cache/sh/opt/ls/color ] && - [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && + [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" # Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred diff --git a/sh/shrc.d/tree.sh b/sh/shrc.d/tree.sh index b4f91df8..ca134fe2 100644 --- a/sh/shrc.d/tree.sh +++ b/sh/shrc.d/tree.sh @@ -21,7 +21,7 @@ tree() { [ -t 1 ] || exit # Not if output terminal doesn't have at least 8 colors - [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] || exit + [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] ) ; then set -- -C "$@" diff --git a/vim/bundle/commentary b/vim/bundle/commentary -Subproject be79030b3e8c0ee3c5f45b4333919e4830531e8 +Subproject 89f43af18692d22ed999c3097e449f12fdd8b29 diff --git a/vim/bundle/html5 b/vim/bundle/html5 -Subproject 9aa4a1c79c61c581ace5caa5b09b0e283d5c72a +Subproject 916085df16ad6bd10ecbd37bc5d44b62f062572 diff --git a/vim/bundle/lion b/vim/bundle/lion -Subproject 08d5e714e87305c4b42f17db373af8244293e42 +Subproject 80de27aa2849b42d8f9cec6ac362858651677d9 diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen -Subproject ddfb1f14d7597e6aedc749be06b559a673c437a +Subproject e7857bed4e0705f91f781dbe99706f07d08d104 diff --git a/vim/bundle/targets b/vim/bundle/targets -Subproject 050335f848d57cb1c59bffe6f32f901307b7e50 +Subproject dec6409fb80ec1554bad582652f7511aa28c4ed diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired -Subproject e1e0cc3859323f354b8d905ca177e172c7d69f0 +Subproject 3a7759075cca5b0dc29ce81f2747489b6c8e36a |