From 74e2f9f15cd205dc0c04f5e30fe7f1216c752db1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jan 2017 00:36:43 +1300 Subject: Tolerate C-M-l for clear window in ksh Already works in ksh93 and mksh. Trapping C-l in ksh93 interferes with the builtin SIGWINCH handling, clearing the screen every time the window resizes, and I can't find a good way to work around it. Probably best not to fight this. --- ksh/kshrc.d/bind.ksh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/ksh/kshrc.d/bind.ksh b/ksh/kshrc.d/bind.ksh index 34cb5f5a..a1999731 100644 --- a/ksh/kshrc.d/bind.ksh +++ b/ksh/kshrc.d/bind.ksh @@ -1,28 +1,17 @@ -# Try to bind ^I to complete words and ^L to clear the screen +# Try to bind tab to complete words and Ctrl-Alt-L to clear the screen +# Already done in ksh93 case $KSH_VERSION in - # ksh93 is lovely, but complex; rebind ^L so it does the same as Alt-^L - *'93'*) - keybd_trap() { - # shellcheck disable=SC2154 - case ${.sh.edchar} in - $'\f') .sh.edchar=$'\e\f' ;; - esac - } - trap keybd_trap KEYBD - ;; - # More straightforward with mksh; bind keys to the appropriate emacs mode # editing commands *'MIRBSD KSH'*) bind '^I'='complete' - bind '^L'='clear-screen' ;; # Similar with pdksh; there's a "complete" command, but not a "clear" one, # so we fake it with clear(1) and some yanking *'PD KSH'*) bind '^I'='complete' - bind -m '^L'='^Uclear^J^Y' + bind -m '^[^L'='^Uclear^J^Y' ;; esac -- cgit v1.2.3 From 79644d5772fb4cfc2c8529c1ac886f14d1573998 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jan 2017 01:09:38 +1300 Subject: Update rfcf(1df) and rfcr(1df) idioms --- bin/rfcf | 9 +++++---- bin/rfcr | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/rfcf b/bin/rfcf index 633eaace..6f257415 100755 --- a/bin/rfcf +++ b/bin/rfcf @@ -1,11 +1,12 @@ #!/bin/sh -# Figure out RFC number -self=rfcf -if ! [ "$1" ] ; then - printf >&2 '%s: Need an RFC number\n' "$self" +# Check arguments +if [ "$#" -ne 1 ] ; then + printf >&2 'rfcf: Need one RFC number\n' exit 2 fi + +# Argument is RFC number rn=$1 # Retrieve the RFC with curl(1) diff --git a/bin/rfcr b/bin/rfcr index 03de898d..75d9abb0 100755 --- a/bin/rfcr +++ b/bin/rfcr @@ -1,11 +1,12 @@ #!/bin/sh -# Figure out RFC number -self=rfcr -if ! [ "$1" ] ; then - printf >&2 '%s: Need an RFC number\n' "$self" +# Check arguments +if [ "$#" -ne 1 ] ; then + printf >&2 'rfcf: Need one RFC number\n' exit 2 fi + +# Argument is RFC number rn=$1 # Retrieve the RFC with rfcf(1df) -- cgit v1.2.3 From 6628da72677bb836821b7572b1d319feecd0420a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jan 2017 14:09:06 +1300 Subject: Add two ideas --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 7f94b027..5fd4939f 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -8,3 +8,5 @@ Ideas manageable * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? +* Have path() default to appending/inserting/removing $PWD +* Add "pop" and "shift" methods to path() -- cgit v1.2.3 From 0976603694f0fb1bf078260317d78c6c8194b4ae Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jan 2017 20:47:37 +1300 Subject: Improvements to path() * Move common directory argument checking into helper function * Tolerate only one directory argument * Show subcommand in error output * Don't show help on failed commands, just suggest it * (Technicality) Fix trailing-newline lossage in subshell function --- sh/shrc.d/path.sh | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 3caabbc9..23eec75b 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -24,10 +24,28 @@ path() { done ) ;; + # Helper function checks directory argument makes sense + _argcheck) + shift + if [ "$#" -gt 2 ] ; then + printf >&2 'path(): %s: too many arguments\n' "$1" + return 2 + fi + case $2 in + *:*) + printf >&2 'path(): %s: %s contains colon\n' "$@" + return 2 + ;; + esac + return 0 + ;; + # Add a directory at the start of $PATH insert) + [ "$#" -eq 2 ] || set -- "$1" "$PWD" + path _argcheck "$@" || return if path check "$2" ; then - printf >&2 'path(): %s already in PATH\n' "$2" + printf >&2 'path(): %s: %s already in PATH\n' "$@" return 1 fi PATH=${2}${PATH:+:"$PATH"} @@ -35,8 +53,10 @@ path() { # Add a directory to the end of $PATH append) + [ "$#" -eq 2 ] || set -- "$1" "$PWD" + path _argcheck "$@" || return if path check "$2" ; then - printf >&2 'path(): %s already in PATH\n' "$2" + printf >&2 'path(): %s: %s already in PATH\n' "$@" return 1 fi PATH=${PATH:+"$PATH":}${2} @@ -44,21 +64,25 @@ path() { # Remove a directory from $PATH remove) + [ "$#" -eq 2 ] || set -- "$1" "$PWD" + path _argcheck "$@" || return if ! path check "$2" ; then - printf >&2 'path(): %s not in PATH\n' "$2" + printf >&2 'path(): %s: %s not in PATH\n' "$@" return 1 fi PATH=$( path=:$PATH: path=${path%%:"$2":*}:${path#*:"$2":} path=${path#:} - path=${path%:} - printf '%s\n' "$path" + printf '%s:' "$path" ) + PATH=${PATH%%:} ;; # Check whether a directory is in PATH check) + path _argcheck "$@" || return + [ "$#" -eq 2 ] || set -- "$1" "$PWD" case :$PATH: in *:"$2":*) return 0 ;; esac @@ -73,23 +97,22 @@ path(): Manage contents of PATH variable USAGE: path [list] Print the current directories in PATH, one per line (default command) - path insert DIR - Add a directory to the front of PATH - path append DIR - Add a directory to the end of PATH - path remove DIR - Remove directory from PATH - path check DIR - Return whether DIR is a component of PATH + path insert [DIR] + Add directory DIR (default $PWD) to the front of PATH + path append [DIR] + Add directory DIR (default $PWD) to the end of PATH + path remove [DIR] + Remove directory DIR (default $PWD) from PATH + path check [DIR] + Return whether directory DIR (default $PWD) is a component of PATH path help - Print this help message (also done if command not found) + Print this help message EOF ;; # Command not found *) - printf >&2 'path(): Unknown command\n' - path help >&2 + printf >&2 'path(): %s: Unknown command (try "help")\n' "$1" return 2 ;; esac -- cgit v1.2.3 From 6d478a815ab3575345c93992b3f734d628a2af60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jan 2017 21:35:44 +1300 Subject: Remove misplaced \0 in completion func --- bash/bash_completion.d/path.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/path.bash b/bash/bash_completion.d/path.bash index e0e7732d..a65e10ce 100644 --- a/bash/bash_completion.d/path.bash +++ b/bash/bash_completion.d/path.bash @@ -49,7 +49,7 @@ _path() { local part for part in "${promptarr[@]}" ; do [[ $part == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue - COMPREPLY[${#COMPREPLY[@]}]=$(printf '%q\0' "$part") + COMPREPLY[${#COMPREPLY[@]}]=$(printf '%q' "$part") done ;; -- cgit v1.2.3 From 8e20116f74753fa07d2f15b915aa5a700fd1f53c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 02:05:16 +1300 Subject: Adjust subshell logic in md() --- sh/shrc.d/md.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sh/shrc.d/md.sh b/sh/shrc.d/md.sh index 6fd3d7ca..a7134931 100644 --- a/sh/shrc.d/md.sh +++ b/sh/shrc.d/md.sh @@ -7,11 +7,14 @@ md() { return 2 fi - # If first arg unset or empty, assume the user means the current dir - [ -n "$1" ] || set -- "$PWD" - - # Jump to the dir and emit PWD from a subshell to get an absolute path - set -- "$(cd -- "$1" && printf %s "$PWD")" + # If argument given, change to it in subshell to get absolute path. + # If not, use current working directory. + if [ -n "$1" ] ; then + set -- "$(cd -- "$1" && printf '%s/' "$PWD")" + set -- "${1%%/}" + else + set -- "$PWD" + fi # If that turned up empty, we have failed; the cd call probably threw an # error for us too -- cgit v1.2.3 From cd1f4c6d2a45f143db953e00b7415d259e6cd3ff Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 10:41:27 +1300 Subject: Bind Ctrl-Alt-L to clear screen in Bash Two of the three ksh variants and zsh already do this. So, if you can't beat 'em... --- readline/inputrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readline/inputrc b/readline/inputrc index 5254656e..af82a65d 100644 --- a/readline/inputrc +++ b/readline/inputrc @@ -62,6 +62,9 @@ $if Bash # Alt+A cycles through completion options "\ea": menu-complete + # Ctrl-Alt-L to clear screen; more ksh-like + "\e\C-l": clear-screen + # Alt-E (for exec) to prepend "exec " to a command and return to the end of # the line "\ee": "\C-aexec \C-e" -- cgit v1.2.3 From 95300500b834544843cc60286ce0d10a889b9a44 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 13:16:07 +1300 Subject: Add keys to fire up a ksh/zsh window --- X/xbindkeysrc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/X/xbindkeysrc b/X/xbindkeysrc index 00855b09..ac9394c3 100644 --- a/X/xbindkeysrc +++ b/X/xbindkeysrc @@ -1,6 +1,12 @@ "exec urxvtcd" Mod4 + Return +"exec urxvtcd -e ksh" + Mod4 + Shift + Return + +"exec urxvtcd -e zsh" + Mod4 + Control + Return + "exec br" Mod4 + b -- cgit v1.2.3 From b1f48a6bf11c24672edafdd05eedac5e87c9e925 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 13:34:14 +1300 Subject: Reset working dir and SHLVL for xbindkeys Otherwise it starts terminals with SHLVL incremented or in whatever dir I ran x() in --- X/xinitrc.d/xbindkeys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X/xinitrc.d/xbindkeys.sh b/X/xinitrc.d/xbindkeys.sh index a21bd995..b50f5c60 100644 --- a/X/xinitrc.d/xbindkeys.sh +++ b/X/xinitrc.d/xbindkeys.sh @@ -1,3 +1,3 @@ # Start xbindkeys(1) command -v xbindkeys >/dev/null 2>&1 || return -xbindkeys -n & +(cd -- "$HOME" && SHLVL= xbindkeys -n) & -- cgit v1.2.3 From 1756afffbc121598441bc966fb59950ae0fcaf42 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 14:24:52 +1300 Subject: Add a plain sh keybinding --- X/xbindkeysrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/X/xbindkeysrc b/X/xbindkeysrc index ac9394c3..ff404691 100644 --- a/X/xbindkeysrc +++ b/X/xbindkeysrc @@ -1,11 +1,14 @@ "exec urxvtcd" Mod4 + Return +"exec urxvtcd -e sh" + Mod4 + Control + Return + "exec urxvtcd -e ksh" Mod4 + Shift + Return "exec urxvtcd -e zsh" - Mod4 + Control + Return + Mod4 + Alt + Return "exec br" Mod4 + b -- cgit v1.2.3 From d7c0417f0ac25fefd2b02ad68deb584f684dd935 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jan 2017 23:39:36 +1300 Subject: Remove resolved issue --- IDEAS.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 5fd4939f..f7e3341b 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -8,5 +8,4 @@ Ideas manageable * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? -* Have path() default to appending/inserting/removing $PWD * Add "pop" and "shift" methods to path() -- cgit v1.2.3 From 523fc2d8d7f8fd518f95762b116a150d351af7e3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jan 2017 00:15:53 +1300 Subject: Force LC_COLLATE to a sane value It always really annoys me when e.g. the leading dot or leading slash in pathnames or filenames gets ignored for the purposes of sorting. I may refine this later on but it seems like a good start for an approach. --- sh/profile.d/lang.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sh/profile.d/lang.sh diff --git a/sh/profile.d/lang.sh b/sh/profile.d/lang.sh new file mode 100644 index 00000000..44d1cefa --- /dev/null +++ b/sh/profile.d/lang.sh @@ -0,0 +1,15 @@ +# Use the system's locale and language, but if it's not C or C.UTF-8, then +# force LC_COLLATE to an appropriate C locale so that the order of sort and +# glob expansion stays sane without making e.g. dates insane. Don't interfere +# at all if LANG isn't even set. +case $LANG in + C|C.UTF-8) ;; + *) + if locale -a | grep -q C.UTF-8 ; then + LC_COLLATE=C.UTF-8 + else + LC_COLLATE=C + fi + export LC_COLLATE + ;; +esac -- cgit v1.2.3 From 4dca4a2620fed992a0c71834f6ac6d7a72192741 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jan 2017 00:50:17 +1300 Subject: Much simpler LC_COLLATE approach --- sh/profile.d/lang.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/sh/profile.d/lang.sh b/sh/profile.d/lang.sh index 44d1cefa..21f67d5b 100644 --- a/sh/profile.d/lang.sh +++ b/sh/profile.d/lang.sh @@ -1,15 +1,4 @@ -# Use the system's locale and language, but if it's not C or C.UTF-8, then -# force LC_COLLATE to an appropriate C locale so that the order of sort and -# glob expansion stays sane without making e.g. dates insane. Don't interfere -# at all if LANG isn't even set. -case $LANG in - C|C.UTF-8) ;; - *) - if locale -a | grep -q C.UTF-8 ; then - LC_COLLATE=C.UTF-8 - else - LC_COLLATE=C - fi - export LC_COLLATE - ;; -esac +# Always use bytewise sorting if not already set +[ -z "$LC_COLLATE" ] || return +LC_COLLATE=C +export LC_COLLATE -- cgit v1.2.3 From 13a24b5dd4c9d97600eeee6b2b21b73af731b5b0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jan 2017 18:31:01 +1300 Subject: Add syntax detection for xresources subfiles --- vim/after/ftdetect/xdefaults.vim | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 vim/after/ftdetect/xdefaults.vim diff --git a/vim/after/ftdetect/xdefaults.vim b/vim/after/ftdetect/xdefaults.vim new file mode 100644 index 00000000..f0ee7b81 --- /dev/null +++ b/vim/after/ftdetect/xdefaults.vim @@ -0,0 +1,6 @@ +" Add automatic commands to find Xresources subfiles +augroup dfxdefaults + autocmd BufNewFile,BufRead + \ **/.Xresources.d/* + \ setlocal filetype=xdefaults +augroup END -- cgit v1.2.3 From 7fa00e4e844712df0ddb82675e5931fcf9f2167a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jan 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 93144aea..21ce415b 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 93144aea5adee78e008be4d3c8a40a84bc221385 +Subproject commit 21ce415bd93225c3b10010b650652f07dd229129 -- cgit v1.2.3 From 395b455020887e494b66eac820cac3f7195a564e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jan 2017 08:38:13 +1300 Subject: Add stock Debian Zsh completion --- zsh/zshrc.d/completion.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 zsh/zshrc.d/completion.zsh diff --git a/zsh/zshrc.d/completion.zsh b/zsh/zshrc.d/completion.zsh new file mode 100644 index 00000000..233a1b91 --- /dev/null +++ b/zsh/zshrc.d/completion.zsh @@ -0,0 +1,19 @@ +# Use modern completion system +autoload -Uz compinit +compinit + +# Taken from Debian's stock .zshrc as a start +zstyle ':completion:*' auto-description 'specify: %d' +zstyle ':completion:*' completer _expand _complete _correct _approximate +zstyle ':completion:*' format 'Completing %d' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' menu select=2 +zstyle ':completion:*' list-colors '' +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s +zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' +zstyle ':completion:*' menu select=long +zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s +zstyle ':completion:*' use-compctl false +zstyle ':completion:*' verbose true +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' -- cgit v1.2.3 From 3425b39cda52638ffa4940622d311b4a77e543ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jan 2017 11:22:26 +1300 Subject: Add safety left paren for subshell case --- bin/xgo | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/xgo b/bin/xgo index 46d90f2e..652d5a14 100755 --- a/bin/xgo +++ b/bin/xgo @@ -13,12 +13,12 @@ for url ; do ( case $url in # If this is a GitHub or GitLab link, swap "blob" for "raw" to get the actual file - *://github.com/*/blob/*|*://gitlab.com/*/blob/*) + (*://github.com/*/blob/*|*://gitlab.com/*/blob/*) url=$(printf '%s\n' "$url" | sed 's_/blob/_/raw/_') ;; # Dig out the plain text for pastebin.com links - *://pastebin.com/*) + (*://pastebin.com/*) # shellcheck disable=SC2016 url=$(printf '%s\n' "$url" | sed 's_/[A-Za-z0-9][A-Za-z0-9]*$_/raw&_') ;; @@ -26,14 +26,14 @@ for url ; do ( # If this is a not-direct imgur link and not to an album, swap URL # elements to get to the actual file (it may not actually be a JPEG; # the MIME type will tell us) - *://imgur.com/a/*) ;; - *://imgur.com/*) + (*://imgur.com/a/*) ;; + (*://imgur.com/*) url=$(printf '%s\n' "$url" | sed 's_imgur\.com_i.imgur.com_;s/$/.jpg/') ;; # If this is a YouTube video without a given start time, load it in mpv(1) - *[/.]youtube.com/watch*[?\&]t=) ;; - *[/.]youtube.com/watch*) + (*[/.]youtube.com/watch*[?\&]t=) ;; + (*[/.]youtube.com/watch*) mpv -- "$url" && exit ;; esac @@ -46,7 +46,7 @@ for url ; do ( # Open PDFs in xpdf(1); download them first as xpdf(1) does not seem to # have a way to handle stdin files - application/pdf) + (application/pdf) ( cd -- "$HOME"/Downloads || exit curl -O -- "$url" || exit @@ -56,18 +56,18 @@ for url ; do ( # Open audio and video in mpv(1); force a window even for audio so I # can control it - audio/*|video/*) + (audio/*|video/*) mpv --force-window -- "$url" && exit ;; # If the MIME type is an image that is not a GIF, load it in feh(1) - image/gif) ;; - image/*) + (image/gif) ;; + (image/*) curl -- "$url" | feh - && exit ;; # Open plain text in a terminal view(1) - text/plain) + (text/plain) # shellcheck disable=SC2016 urxvt -e sh -c 'curl -- "$1" | view -' _ "$url" && exit ;; -- cgit v1.2.3 From b5b8f9b71e7cb067aef507d31aef280c798b2082 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jan 2017 17:01:13 +1300 Subject: Move tmux() function to tm(1df) No real reason for it to be a shell function --- README.markdown | 4 ++-- bin/tm | 18 ++++++++++++++++++ man/man1/tm.1df | 12 ++++++++++++ readline/inputrc | 4 ++-- sh/shrc.d/tmux.sh | 19 ------------------- 5 files changed, 34 insertions(+), 23 deletions(-) create mode 100755 bin/tm create mode 100644 man/man1/tm.1df delete mode 100644 sh/shrc.d/tmux.sh diff --git a/README.markdown b/README.markdown index 97823267..b906c3f0 100644 --- a/README.markdown +++ b/README.markdown @@ -204,8 +204,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: * `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. * `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never preserved; I hate having `root`-owned files in my home directory. -* `tmux()` changes the default command for `tmux(1)` to `attach-session -d` - if a session exists, or creates a new session if one doesn't. * `tree()` colorizes GNU `tree(1)` output if possible (without having `LS_COLORS` set). * `vim()` defines three functions to always use `vim(1)` as my `ex(1)`, @@ -501,6 +499,8 @@ Installed by the `install-bin` target: `scp(1)`'s HOST:PATH format. * `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used to use Taskwarrior, but found it too complex and buggy. +* `tm()` runs `tmux(1)` with `attach-session -d` if a session exists, and + `new-session` if it doesn't. * `try(1df)` repeats a command up to a given number of times until it succeeds, only printing error output if all three attempts failed. Good for tolerating blips or temporary failures in `cron(8)` scripts. diff --git a/bin/tm b/bin/tm new file mode 100755 index 00000000..f2b51c63 --- /dev/null +++ b/bin/tm @@ -0,0 +1,18 @@ +#!/bin/sh +# Attach to existing tmux session rather than create a new one if possible + +# If given any arguments, just use them as they are +if [ "$#" -gt 0 ] ; then + : + +# If a session exists, just attach to it +elif command tmux has-session 2>/dev/null ; then + set -- attach-session -d + +# Create a new session with an appropriate name +else + set -- new-session -s "${TMUX_SESSION:-default}" +fi + +# Execute with concluded arguments +tmux "$@" diff --git a/man/man1/tm.1df b/man/man1/tm.1df new file mode 100644 index 00000000..125d69c1 --- /dev/null +++ b/man/man1/tm.1df @@ -0,0 +1,12 @@ +.TH TM 1df "January 2017" "Manual page for tm" +.SH NAME +.B tm +\- tmux shortcut +.SH SYNOPSIS +.B tm +.SH DESCRIPTION +If arguments are given, pass them to tmux(1) unchanged. If not, check if a tmux +session exists; if it does, attach to it. If not, create a new session with +name given in environment variable $TMUX_SESSION, default "default". +.SH AUTHOR +Tom Ryder diff --git a/readline/inputrc b/readline/inputrc index af82a65d..7e4b500d 100644 --- a/readline/inputrc +++ b/readline/inputrc @@ -74,8 +74,8 @@ $if Bash # Alt-S (for set) to wrap current command in (set -x ; ...) "\es": "\C-a(set -x ; \C-e)\C-b" - # Alt-M (for muxer) to run tmux - "\em": "\C-utmux\C-j\C-y" + # Alt-M (for muxer) to run tm(1df) + "\em": "\C-utm\C-j\C-y" # Ctrl-Alt-B to move backward a shell-quoted word "\e\C-b": shell-backward-word diff --git a/sh/shrc.d/tmux.sh b/sh/shrc.d/tmux.sh deleted file mode 100644 index bd954be8..00000000 --- a/sh/shrc.d/tmux.sh +++ /dev/null @@ -1,19 +0,0 @@ -# Attach to existing tmux session rather than create a new one if possible -tmux() { - - # If given any arguments, just use them as they are - if [ "$#" -gt 0 ] ; then - : - - # If a session exists, just attach to it - elif command tmux has-session 2>/dev/null ; then - set -- attach-session -d - - # Create a new session with an appropriate name - else - set -- new-session -s "${TMUX_SESSION:-default}" - fi - - # Execute with concluded arguments - command tmux "$@" -} -- cgit v1.2.3 From fc3b8c17f0756e3a397928529349d11601d79aed Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Jan 2017 17:06:07 +1300 Subject: Change some return codes for dir marking funcs The mark not being set isn't really a usage error for the function given. --- sh/shrc.d/gd.sh | 2 +- sh/shrc.d/pmd.sh | 2 +- sh/shrc.d/xd.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh index 5a3f54b0..fa5776f2 100644 --- a/sh/shrc.d/gd.sh +++ b/sh/shrc.d/gd.sh @@ -10,7 +10,7 @@ gd() { # Complain if mark not actually set yet if ! [ -n "$PMD" ] ; then printf >&2 'gd(): Mark not set\n' - return 2 + return 1 fi # Go to the marked directory diff --git a/sh/shrc.d/pmd.sh b/sh/shrc.d/pmd.sh index 03f18b7b..c96a50bd 100644 --- a/sh/shrc.d/pmd.sh +++ b/sh/shrc.d/pmd.sh @@ -2,7 +2,7 @@ pmd() { if ! [ -n "$PMD" ] ; then printf >&2 'pmd(): Mark not set\n' - return 2 + return 1 fi printf '%s\n' "$PMD" } diff --git a/sh/shrc.d/xd.sh b/sh/shrc.d/xd.sh index 01b8fd3a..40319cf2 100644 --- a/sh/shrc.d/xd.sh +++ b/sh/shrc.d/xd.sh @@ -10,7 +10,7 @@ xd() { # Complain if mark not actually set yet if ! [ -n "$PMD" ] ; then printf >&2 'gd(): Mark not set\n' - return 2 + return 1 fi # Put the current and marked directories into positional params -- cgit v1.2.3 From dd4392ef10ccd7f0722a7e865a52f1fb5ae06798 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 13:11:47 +1300 Subject: Add xrq(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/xrq.awk | 28 ++++++++++++++++++++++++++++ man/man1/xrq.1df | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100755 bin/xrq.awk create mode 100644 man/man1/xrq.1df diff --git a/.gitignore b/.gitignore index a9f181be..8250c055 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ bin/su2d bin/tot bin/unf bin/uts +bin/xrq games/acq games/aesth games/chkl diff --git a/Makefile b/Makefile index 06d5adf3..e48ab590 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ BINS = bin/brnl \ bin/tot \ bin/unf \ bin/uts \ + bin/xrq GAMES = games/acq \ games/aesth \ diff --git a/README.markdown b/README.markdown index b906c3f0..bb317a30 100644 --- a/README.markdown +++ b/README.markdown @@ -511,6 +511,8 @@ Installed by the `install-bin` target: * `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. * `vex(1df)` runs a command and prints `true` or `false` explicitly to `stdout` based on the exit value. +* `xrq(1df)` gets the values of specific resources out of `xrdb -query` + output. There's some silly stuff in `install-games`: diff --git a/bin/xrq.awk b/bin/xrq.awk new file mode 100755 index 00000000..c29bfb9d --- /dev/null +++ b/bin/xrq.awk @@ -0,0 +1,28 @@ +# Run xrdb(1) to query specific resources from it +# I thought xrdb -query would do this, but it doesn't seem to, maybe I'm doing +# it wrong +BEGIN { + + # Separator is a colon followed by a tab + FS = ":\t" + + # Check we have at least one resource name + if (ARGC < 2) { + print "xrq: Need at least one resource name" | "cat 1>&2" + exit(2) + } + + # Run `xrdb -query` and search for instances of the requested resource + while ("xrdb -query" | getline) { + for (i in ARGV) { + if ($1 == ARGV[i]) { + found = 1 + print $2 + continue + } + } + } + + # Exit successfully if we found at least one result + exit(!found) +} diff --git a/man/man1/xrq.1df b/man/man1/xrq.1df new file mode 100644 index 00000000..245ac66f --- /dev/null +++ b/man/man1/xrq.1df @@ -0,0 +1,16 @@ +.TH XRQ 1df "August 2016" "Manual page for xrq" +.SH NAME +.B xrq +\- view the given URL in an appropriate program, falling back on $BROWSER +.SH SYNOPSIS +.B xrq +Xft.hintstyle +.br +.B xrq +URxvt.color0 URxvt.color9 +.SH DESCRIPTION +.B xrq +runs xrdb(1) with the -query option and filters for the values of the named +keys. It exits successfully if at least one of the named keys was found. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 0b39beeca2621bf66bd004b05d74ee0df3319602 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 16:12:23 +1300 Subject: Add an idea --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index f7e3341b..145efb28 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,3 +9,5 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * Add "pop" and "shift" methods to path() +* `ls()` function flags can probably be made more generic by looking for + their short POSIX equivalents if any -- cgit v1.2.3 From d3f446c9508be8fc0fde70981918b1d000e37ae0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 16:29:04 +1300 Subject: Use POSIX-compatible versions of ls(1) opts --- IDEAS.markdown | 2 -- sh/profile.d/options.sh | 11 ++++------- sh/shrc.d/ls.sh | 25 ++++++++++--------------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 145efb28..f7e3341b 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,5 +9,3 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * Add "pop" and "shift" methods to path() -* `ls()` function flags can probably be made more generic by looking for - their short POSIX equivalents if any diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index aa7e9ace..345888d0 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -46,12 +46,9 @@ options grep \ # Cache options for ls(1) options ls \ - almost-all \ - block-size \ - classify \ - color \ - format \ - hide-control-chars \ - human-readable \ + almost-all \ + block-size \ + color \ + human-readable \ time-style ) diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 7e916239..40da567a 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -5,31 +5,26 @@ # Define function proper ls() { + # Add -F to show trailing indicators of the filetype + set -- -F "$@" + + # Add -q to replace control chars with '?' + set -- -q "$@" + + # Format with entries sorted across, not down, in columns + set -- -x "$@" + # Add --block-size=K to always show the filesize in kibibytes [ -e "$HOME"/.cache/ls/block-size ] && set -- --block-size=1024 "$@" - # Add --classify to show trailing indicators of the filetype - [ -e "$HOME"/.cache/ls/classify ] && - set -- --classify "$@" - # Add --color if the terminal has at least 8 colors [ -e "$HOME"/.cache/ls/color ] && [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" - # Add --format=horizontal to print entries in a saner way - [ -e "$HOME"/.cache/ls/format ] && - set -- --format=horizontal "$@" - - # Add --hide-control-chars if present; we always want this interactively, - # even if the output is to a pager; we shouldn't be trying to script ls(1) - # output anyway - [ -e "$HOME"/.cache/ls/hide-control-chars ] && - set -- --hide-control-chars "$@" - # Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred - # format + # (fixed) format [ -e "$HOME"/.cache/ls/time-style ] && set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" -- cgit v1.2.3 From c259de7eeca82a881ecb0f878d31e73863049267 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 16:32:05 +1300 Subject: Group single-letter ls(1) opts --- sh/shrc.d/ls.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 40da567a..11ab15b4 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -5,14 +5,10 @@ # Define function proper ls() { - # Add -F to show trailing indicators of the filetype - set -- -F "$@" - - # Add -q to replace control chars with '?' - set -- -q "$@" - - # Format with entries sorted across, not down, in columns - set -- -x "$@" + # -F to show trailing indicators of the filetype + # -q to replace control chars with '?' + # -x to format entries across, not down + set -- -Fqx "$@" # Add --block-size=K to always show the filesize in kibibytes [ -e "$HOME"/.cache/ls/block-size ] && -- cgit v1.2.3 From a3dde617762b69232d5ee0a5ee19905d068e7221 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 16:43:54 +1300 Subject: Don't let OpenBSD alias `ls` in ksh --- ksh/kshrc.d/unalias.ksh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ksh/kshrc.d/unalias.ksh diff --git a/ksh/kshrc.d/unalias.ksh b/ksh/kshrc.d/unalias.ksh new file mode 100644 index 00000000..44905209 --- /dev/null +++ b/ksh/kshrc.d/unalias.ksh @@ -0,0 +1,2 @@ +# OpenBSD likes to define ls as an alias, but I don't +unalias ls -- cgit v1.2.3 From 2b3dccc9e8c7e921f546c61d1a1a8fc052b30515 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 22:57:13 +1300 Subject: Have ls() func undo aliases in its way --- ksh/kshrc.d/unalias.ksh | 2 -- sh/shrc.d/ls.sh | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 ksh/kshrc.d/unalias.ksh diff --git a/ksh/kshrc.d/unalias.ksh b/ksh/kshrc.d/unalias.ksh deleted file mode 100644 index 44905209..00000000 --- a/ksh/kshrc.d/unalias.ksh +++ /dev/null @@ -1,2 +0,0 @@ -# OpenBSD likes to define ls as an alias, but I don't -unalias ls diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 11ab15b4..1aca767e 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -2,6 +2,10 @@ # options for us; if not, we won't be wrapping ls(1) with a function at all [ -d "$HOME"/.cache/ls ] || return +# If the system has already aliased ls(1) for us, like Slackware or OpenBSD +# does, just get rid of it +unalias ls >/dev/null 2>&1 + # Define function proper ls() { -- cgit v1.2.3 From 3cd623e6f016aa13d387cb87058a768dbc8ba108 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:16:02 +1300 Subject: Work around systems that export PS1 So far I don't like SlackWare's shell setup very much at all --- sh/shrc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sh/shrc b/sh/shrc index 879c8947..c3e300ea 100644 --- a/sh/shrc +++ b/sh/shrc @@ -13,6 +13,12 @@ HISTSIZE=$((1 << 12)) # Don't warn me about new mail unset -v MAILCHECK +# Some systems' /etc/profile setups export PS1, which really fouls things up +# when switching between non-login shells; let's put things right by unsetting +# it to break the export and then just setting them as simple variables +unset PS1 PS2 PS3 PS4 +PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' + # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions for sh in "$HOME"/.shrc.d/*.sh ; do -- cgit v1.2.3 From 817a82e3f7da5c4f41c6e7b63ca42da84573fb06 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:24:48 +1300 Subject: Unset stupid GNU options to grep(1)/ls(1) --- sh/shrc.d/grep.sh | 3 +++ sh/shrc.d/ls.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index a52b6f90..7b3aea57 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -2,6 +2,9 @@ # options for us; if not, we won't be wrapping grep(1) with a function at all [ -d "$HOME"/.cache/grep ] || return +# Discard GREP_OPTIONS +unset -v GREP_OPTIONS + # Define function proper grep() { diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 1aca767e..d1391d40 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -6,6 +6,9 @@ # does, just get rid of it unalias ls >/dev/null 2>&1 +# Discard LS_OPTIONS +unset -v LS_OPTIONS + # Define function proper ls() { -- cgit v1.2.3 From 3495ca7ba6e6f9a4f66fecaf6c836d840b592a94 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:28:52 +1300 Subject: More cleaning crap --- sh/shrc.d/less.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sh/shrc.d/less.sh diff --git a/sh/shrc.d/less.sh b/sh/shrc.d/less.sh new file mode 100644 index 00000000..08361ba2 --- /dev/null +++ b/sh/shrc.d/less.sh @@ -0,0 +1,3 @@ +# Unset stupid options to avoid interfering with my less(1) setup +unset -v LESS +unset -v LESSOPEN -- cgit v1.2.3 From 862400319d86df7c83ee02894b5b82dc13d96eab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:29:40 +1300 Subject: Unset some more stupid variables --- sh/shrc.d/less.sh | 5 ++--- sh/shrc.d/ls.sh | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sh/shrc.d/less.sh b/sh/shrc.d/less.sh index 08361ba2..2778ce65 100644 --- a/sh/shrc.d/less.sh +++ b/sh/shrc.d/less.sh @@ -1,3 +1,2 @@ -# Unset stupid options to avoid interfering with my less(1) setup -unset -v LESS -unset -v LESSOPEN +# Unset stupid env vars to avoid interfering with my less(1) setup +unset -v LESS LESSOPEN diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index d1391d40..e29002fe 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -6,8 +6,8 @@ # does, just get rid of it unalias ls >/dev/null 2>&1 -# Discard LS_OPTIONS -unset -v LS_OPTIONS +# Discard LS_OPTIONS and LS_COLORS +unset -v LS_OPTIONS LS_COLORS # Define function proper ls() { -- cgit v1.2.3 From c522da742ae1349e3970cf18fdbb275ce91dc2f7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:32:47 +1300 Subject: Move prompt resetting into its own file --- sh/shrc | 6 ------ sh/shrc.d/prompt.sh | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 sh/shrc.d/prompt.sh diff --git a/sh/shrc b/sh/shrc index c3e300ea..879c8947 100644 --- a/sh/shrc +++ b/sh/shrc @@ -13,12 +13,6 @@ HISTSIZE=$((1 << 12)) # Don't warn me about new mail unset -v MAILCHECK -# Some systems' /etc/profile setups export PS1, which really fouls things up -# when switching between non-login shells; let's put things right by unsetting -# it to break the export and then just setting them as simple variables -unset PS1 PS2 PS3 PS4 -PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' - # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions for sh in "$HOME"/.shrc.d/*.sh ; do diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh new file mode 100644 index 00000000..a481b5bb --- /dev/null +++ b/sh/shrc.d/prompt.sh @@ -0,0 +1,5 @@ +# Some systems' /etc/profile setups export PS1, which really fouls things up +# when switching between non-login shells; let's put things right by unsetting +# it to break the export and then just setting them as simple variables +unset PS1 PS2 PS3 PS4 +PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' -- cgit v1.2.3 From c7b9bcce58d3b59a110e98453a2394b71b7668e0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Jan 2017 23:34:51 +1300 Subject: Make some comments less useless --- sh/shrc.d/grep.sh | 2 +- sh/shrc.d/ls.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index 7b3aea57..fc8f62c0 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -2,7 +2,7 @@ # options for us; if not, we won't be wrapping grep(1) with a function at all [ -d "$HOME"/.cache/grep ] || return -# Discard GREP_OPTIONS +# Discard GNU grep(1) environment variables if the environment set them unset -v GREP_OPTIONS # Define function proper diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index e29002fe..58263e96 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -6,7 +6,7 @@ # does, just get rid of it unalias ls >/dev/null 2>&1 -# Discard LS_OPTIONS and LS_COLORS +# Discard GNU ls(1) environment variables if the environment set them unset -v LS_OPTIONS LS_COLORS # Define function proper -- cgit v1.2.3 From 1b0385f53ee3d75afa9dfa2a270ef29cdd676ccf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 12 Jan 2017 00:02:09 +1300 Subject: Remove redundant `continue` --- bin/xrq.awk | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/xrq.awk b/bin/xrq.awk index c29bfb9d..5c9f7e96 100755 --- a/bin/xrq.awk +++ b/bin/xrq.awk @@ -18,7 +18,6 @@ BEGIN { if ($1 == ARGV[i]) { found = 1 print $2 - continue } } } -- cgit v1.2.3 From 441005d55e38c718e601046ca3361a5218a4b84d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Jan 2017 13:13:25 +1300 Subject: Finish xrq(1df) man page --- man/man1/xrq.1df | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/man1/xrq.1df b/man/man1/xrq.1df index 245ac66f..d0bdeeb3 100644 --- a/man/man1/xrq.1df +++ b/man/man1/xrq.1df @@ -1,7 +1,7 @@ -.TH XRQ 1df "August 2016" "Manual page for xrq" +.TH XRQ 1df "January 2017" "Manual page for xrq" .SH NAME .B xrq -\- view the given URL in an appropriate program, falling back on $BROWSER +\- query X resource values .SH SYNOPSIS .B xrq Xft.hintstyle -- cgit v1.2.3 From c8370aafa5a7227330d49deeb96d0e2d060d51b5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jan 2017 14:30:07 +1300 Subject: Add hook to load xrandr(1) file first Here's mine on my home desktop: # Size monitors xrandr --output DVI-0 --auto xrandr --output DisplayPort-1 --auto xrandr --output DVI-1 --auto # Place monitors xrandr --output DVI-0 --pos 0x360 xrandr --output DisplayPort-1 --pos 1920x0 xrandr --output DVI-1 --pos 4480x360 --- X/xinitrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/X/xinitrc b/X/xinitrc index e0b3d661..6f2ad45f 100644 --- a/X/xinitrc +++ b/X/xinitrc @@ -1,3 +1,6 @@ +# If a file ~/.xrandrrc exists for monitor setup, source that first +[ -e "$HOME"/.xrandrrc ] && . "$HOME"/.xrandrrc + # Read X resources xrdb "$HOME"/.Xresources -- cgit v1.2.3 From 2e1c4cbcf6e491b972c0b71f12ad4a1ace641d66 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jan 2017 17:11:56 +1300 Subject: Remove Wyrd config files I never use it --- Makefile | 4 -- README.markdown | 2 - wyrd/wyrdrc | 167 -------------------------------------------------------- 3 files changed, 173 deletions(-) delete mode 100644 wyrd/wyrdrc diff --git a/Makefile b/Makefile index e48ab590..218b79f9 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,6 @@ install-gvim-config \ install-vim-plugins \ install-vim-pathogen \ - install-wyrd \ install-x \ install-yash \ install-zsh \ @@ -361,9 +360,6 @@ install-vim-pathogen : install-vim-plugins ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ "$(HOME)"/.vim/autoload/pathogen.vim -install-wyrd : - install -pm 0644 -- wyrd/wyrdrc "$(HOME)"/.wyrdrc - install-x : install -m 0755 -d -- \ "$(HOME)"/.config \ diff --git a/README.markdown b/README.markdown index bb317a30..5c70a17d 100644 --- a/README.markdown +++ b/README.markdown @@ -77,8 +77,6 @@ Configuration is included for: * [tmux](https://tmux.github.io/) -- Terminal multiplexer similar to GNU Screen * [Vim](http://www.vim.org/) -- Vi IMproved, a text editor -* [Wyrd](https://packages.debian.org/sid/wyrd) -- a `curses` calendar - frontend for [Remind](https://www.roaringpenguin.com/products/remind) * [X11](https://www.x.org/wiki/) -- Windowing system with network transparency for Unix diff --git a/wyrd/wyrdrc b/wyrd/wyrdrc deleted file mode 100644 index 86eae455..00000000 --- a/wyrd/wyrdrc +++ /dev/null @@ -1,167 +0,0 @@ -# Wyrd run-configuration file - -# command for the Remind executable -set remind_command="remind" -# the default reminder file to display -set reminders_file="$HOME/.reminders" -# command for editing an old appointment, given a line number %line% and filename %file% -set edit_old_command="${VISUAL:-$EDITOR} +%line% %file%" -# command for editing a new appointment, given a filename %file% -set edit_new_command="${VISUAL:-$EDITOR} +999999 %file%" -# command for free editing of the reminders file, given a filename %file% -set edit_any_command="${VISUAL:-$EDITOR} %file%" - - -# templates for creating new appointments -# %monname% -> month name, %mon% -> month number, %mday% -> day of the month, -# %year% -> year, %hour% -> hour, %min% -> minute, %wdayname% -> weekday name -# %wday% -> weekday number -set timed_template="REM %monname% %mday% %year% AT %hour%:%min% DURATION 1:00 MSG " -set untimed_template="REM %monname% %mday% %year% MSG " - -# weekly recurrence -set template0="REM %wdayname% AT %hour%:%min% DURATION 1:00 MSG " -set template1="REM %wdayname% MSG " - -# monthly recurrence -set template2="REM %mday% AT %hour%:%min% DURATION 1:00 MSG " -set template3="REM %mday% MSG " - - -# algorithm to use for determining busy level -# "1" -> count the number of reminders in each day -# "2" -> count the number of hours of reminders in each day -set busy_algorithm="1" -# for busy_algorithm="2", assume that untimed reminders occupy this many minutes -set untimed_duration="60" - -# if busy_algorithm="1", number of reminders per day allowed for each calendar -# colorization level; if busy_algorithm="2", use number of hours of reminders -# per day -set busy_level1="1" # level1 color -set busy_level2="3" # level2 color -set busy_level3="5" # level2 color, bold -set busy_level4="7" # level3 color - # (everything else is level3 color, bold) - - -# first day of the week is Monday -set week_starts_monday="true" - -# 12/24 hour time settings -set schedule_12_hour="false" -set selection_12_hour="true" -set status_12_hour="true" -set description_12_hour="true" - -# whether or not to keep the cursor centered when scrolling through timed -# reminders -set center_cursor="false" - -# date syntax for the 'go to date' command can be big or little endian -set goto_big_endian="true" -# date syntax for the "quick reminder" command can be US style -# (6/1 -> June 1) or non-US style (6/1 -> January 6) -set quick_date_US="false" - -# whether or not to number weeks within the month calendar -set number_weeks="false" - -# whether or not the cursor should follow the current time -# after pressing the "home" key -set home_sticky="true" - -# whether or not to display advance warnings -set advance_warning="false" - -# width of the untimed reminders window -set untimed_window_width="40" - -# whether or not to render untimed reminders in boldface -set untimed_bold="true" - - -# key bindings -bind "j" scroll_down -bind "" scroll_down -bind "k" scroll_up -bind "" scroll_up -bind "h" switch_window -bind "l" switch_window -bind "" switch_window -bind "" switch_window -bind "" previous_day -bind "4" previous_day -bind "<" previous_day -bind "H" previous_day -bind "" next_day -bind "6" next_day -bind ">" next_day -bind "L" next_day -bind "8" previous_week -bind "[" previous_week -bind "K" previous_week -bind "2" next_week -bind "]" next_week -bind "J" next_week -bind "{" previous_month -bind "}" next_month -bind "" home -bind "g" goto -bind "z" zoom -bind "" edit -bind "" edit -bind "e" edit_any -bind "y" copy -bind "X" cut -bind "p" paste -bind "P" paste_dialog -bind "d" scroll_description_up -bind "D" scroll_description_down -#bind "q" quick_add -bind "t" new_timed -bind "T" new_timed_dialog -bind "u" new_untimed -bind "U" new_untimed_dialog -bind "w" new_template0 -bind "W" new_template1 -bind "m" new_template2 -bind "M" new_template3 -bind "n" search_next -bind "/" begin_search -bind "" next_reminder -bind "r" view_remind -bind "R" view_remind_all -bind "c" view_week -bind "C" view_month -bind "?" help -bind "\\Cl" refresh -#bind "Q" quit -bind "q" quit - -bind "" entry_complete -bind "" entry_complete -bind "" entry_backspace -bind "" entry_cancel - - -# set up the colors -color help white magenta -color timed_default white black -color timed_current white magenta -color timed_reminder1 white blue -color timed_reminder2 white red -color timed_reminder3 white green -color timed_reminder4 yellow magenta -color untimed_reminder white black -color timed_date magenta black -color selection_info white magenta -color description white black -color status white magenta -color calendar_labels white black -color calendar_level1 white black -color calendar_level2 magenta black -color calendar_level3 red black -color calendar_today magenta white -color left_divider magenta magenta -color right_divider magenta magenta -- cgit v1.2.3 From f237438019a70644b1a90efc7ce8d84431627dfb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jan 2017 17:12:07 +1300 Subject: Bind Mod4+m to pull up tmux instance --- X/xbindkeysrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/X/xbindkeysrc b/X/xbindkeysrc index ff404691..16ae5b14 100644 --- a/X/xbindkeysrc +++ b/X/xbindkeysrc @@ -22,6 +22,9 @@ "exec gimp" Mod4 + i +"exec urxvtcd -e tm" + Mod4 + m + "exec dmp" Mod4 + p -- cgit v1.2.3 From e0fa08ffae400947de5df95991059b328ccef0f7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jan 2017 23:53:40 +1300 Subject: Add tab settings to shrc --- sh/shrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sh/shrc b/sh/shrc index 879c8947..e4015dbc 100644 --- a/sh/shrc +++ b/sh/shrc @@ -13,6 +13,11 @@ HISTSIZE=$((1 << 12)) # Don't warn me about new mail unset -v MAILCHECK +# Set terminal tab size to 4 rather than 8 +# (Bash and Vim do their own thing) +stty tab0 +tabs 4 + # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions for sh in "$HOME"/.shrc.d/*.sh ; do -- cgit v1.2.3 From bacd9bc82bfd0b12752dddcf43c6def31a570bab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 15 Jan 2017 14:16:01 +1300 Subject: Restore xrbg(1df) I switched to an xrandr(1)-based layout and feh(1)'s --randomize option applies a random background to each screen. I can't see a way of applying the same background to each screen, but xrbg(1df) does it, so I've restored it here. This reverts commit 1a0ac5be601f00e828dba181a7c90c2b29735b77. --- README.markdown | 1 + X/xinitrc.d/xbackground.sh | 3 --- X/xinitrc.d/xrbg.sh | 2 ++ bin/xrbg | 4 ++++ man/man1/xrbg.1df | 19 +++++++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) delete mode 100644 X/xinitrc.d/xbackground.sh create mode 100644 X/xinitrc.d/xrbg.sh create mode 100755 bin/xrbg create mode 100644 man/man1/xrbg.1df diff --git a/README.markdown b/README.markdown index 5c70a17d..b0982a7d 100644 --- a/README.markdown +++ b/README.markdown @@ -509,6 +509,7 @@ Installed by the `install-bin` target: * `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. * `vex(1df)` runs a command and prints `true` or `false` explicitly to `stdout` based on the exit value. +* `xrbg(1df)` applies the same randomly-selected background to each X screen. * `xrq(1df)` gets the values of specific resources out of `xrdb -query` output. diff --git a/X/xinitrc.d/xbackground.sh b/X/xinitrc.d/xbackground.sh deleted file mode 100644 index 7f2bc8c3..00000000 --- a/X/xinitrc.d/xbackground.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Apply a random background image -command -v feh >/dev/null 2>&1 || return -feh --bg-scale --no-fehbg --randomize -- "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}" diff --git a/X/xinitrc.d/xrbg.sh b/X/xinitrc.d/xrbg.sh new file mode 100644 index 00000000..0e4ec278 --- /dev/null +++ b/X/xinitrc.d/xrbg.sh @@ -0,0 +1,2 @@ +# Apply a random background image +xrbg diff --git a/bin/xrbg b/bin/xrbg new file mode 100755 index 00000000..801bf078 --- /dev/null +++ b/bin/xrbg @@ -0,0 +1,4 @@ +#!/bin/sh +# Apply a random background image. Requires rndf(1df) and feh(1). +bg=$(rndf "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}") || exit +feh --bg-scale --no-fehbg -- "$bg" diff --git a/man/man1/xrbg.1df b/man/man1/xrbg.1df new file mode 100644 index 00000000..481c9185 --- /dev/null +++ b/man/man1/xrbg.1df @@ -0,0 +1,19 @@ +.TH XRBG 1df "March 2016" "Manual page for xrbg" +.SH NAME +.B xrbg +\- apply a random X background image with feh(1) +.SH SYNOPSIS +.B xrbg +.br +XBACKGROUNDS=/path/to/images +.B xrbg +.SH DESCRIPTION +.B xrbg +searches for images in the directory named in the XBACKGROUNDS environment +variable (defaults to ~/.xbackgrounds), chooses a random one with rndf(1df), +and applies it with feh(1). It's designed for use in ~/.xinitrc, but it seems +to work when called manually from within an X session too. +.SH SEE ALSO +feh(1), rndf(1df) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From b977d027aa8a0909ccccb977abe954825ff84aad Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 15 Jan 2017 17:14:06 +1300 Subject: Block output from tabs(1) --- sh/shrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc b/sh/shrc index e4015dbc..c71ba900 100644 --- a/sh/shrc +++ b/sh/shrc @@ -16,7 +16,7 @@ unset -v MAILCHECK # Set terminal tab size to 4 rather than 8 # (Bash and Vim do their own thing) stty tab0 -tabs 4 +tabs 4 >/dev/null # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions -- cgit v1.2.3 From 7672e264871e6cb796c0e00df7514793f71ce263 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 15 Jan 2017 21:08:40 +1300 Subject: Block stderr from tabs call Also prefix with `command -p` --- sh/shrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/shrc b/sh/shrc index c71ba900..11202cd4 100644 --- a/sh/shrc +++ b/sh/shrc @@ -15,8 +15,8 @@ unset -v MAILCHECK # Set terminal tab size to 4 rather than 8 # (Bash and Vim do their own thing) -stty tab0 -tabs 4 >/dev/null +command -p stty tab0 +command -p tabs 4 >/dev/null 2>&1 # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions -- cgit v1.2.3 From f8aecb0cb50e3b52c9ff33449a766c54602fd7a9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 16 Jan 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/lion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/lion b/vim/bundle/lion index 9b1a923d..08d5e714 160000 --- a/vim/bundle/lion +++ b/vim/bundle/lion @@ -1 +1 @@ -Subproject commit 9b1a923d51a7d0a8efdbb2289ce1e763038f9653 +Subproject commit 08d5e714e87305c4b42f17db373af8244293e423 -- cgit v1.2.3 From b90c7fd8f283eeb0fc7e11a48e4f56febbc8bda3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 16 Jan 2017 10:32:12 +1300 Subject: Add an idea --- IDEAS.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index f7e3341b..39d9511e 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,3 +9,4 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * Add "pop" and "shift" methods to path() +* edio(1df), like vipe(1) -- cgit v1.2.3 From 43dd90dca8b5375d0eed2422ac328870a1800eb7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 16 Jan 2017 10:33:21 +1300 Subject: Add an issue --- ISSUES.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 383d7906..2fb2d46e 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,3 +18,7 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file +* The stty tab0/tabs settings in .shrc work on my home machine but not at + work for some reason; pressing Tab in a cat(1) process still indents by + eight spaces; if I run "tabs 4" again it indents by 3 spaces then 4 spaces + (!) -- cgit v1.2.3 From 0ac0571f46d432241c1c9caa1eaf2438052a5763 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 16 Jan 2017 14:03:35 +1300 Subject: Remove tabs settings `stty tab0` is not even in OpenBSD; these are way more trouble than they're worth. --- sh/shrc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sh/shrc b/sh/shrc index 11202cd4..879c8947 100644 --- a/sh/shrc +++ b/sh/shrc @@ -13,11 +13,6 @@ HISTSIZE=$((1 << 12)) # Don't warn me about new mail unset -v MAILCHECK -# Set terminal tab size to 4 rather than 8 -# (Bash and Vim do their own thing) -command -p stty tab0 -command -p tabs 4 >/dev/null 2>&1 - # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions for sh in "$HOME"/.shrc.d/*.sh ; do -- cgit v1.2.3 From 3735c23a4f1ac937811c9ecd8e92f0ff4b3ecfcb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 16 Jan 2017 14:08:47 +1300 Subject: Remove executable bit from source script --- bin/xrq.awk | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bin/xrq.awk diff --git a/bin/xrq.awk b/bin/xrq.awk old mode 100755 new mode 100644 -- cgit v1.2.3 From ffd9d95b6adf5982448e1685a8c79c74b148cb00 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jan 2017 17:17:33 +1300 Subject: Color ed(1) prompt if possible --- sh/shrc.d/ed.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index d7d3fa2f..3e544c74 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -11,8 +11,20 @@ ed() { [ -e "$HOME"/.cache/ed/verbose ] && set -- --verbose "$@" - # Add an asterisk prompt (POSIX feature) - set -- -p\* "$@" + # Add an asterisk prompt (POSIX feature); color it dark green if we can + set -- -p "$( + if [ "$(tput colors || tput Co)" -gt 8 ] ; then + ec=${ED_PROMPT_COLOR:-2} + tput setaf "$ec" || + tput setaf "$ec" 0 0 || + tput AF "$ec" || + tput AF "$ec" 0 0 + printf %s "${ED_PROMPT:-'*'}" + tput sgr0 || tput me + else + printf %s "${ED_PROMPT:-'*'}" + fi 2>/dev/null + )" "$@" # Run in rlwrap(1) if available set -- ed "$@" -- cgit v1.2.3 From f825245902048e324a3567e0967f21cc1fae5bd3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jan 2017 17:19:00 +1300 Subject: Remove some quotes that confused OpenBSD --- sh/shrc.d/ed.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index 3e544c74..2333cc0f 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -19,10 +19,10 @@ ed() { tput setaf "$ec" 0 0 || tput AF "$ec" || tput AF "$ec" 0 0 - printf %s "${ED_PROMPT:-'*'}" + printf %s "${ED_PROMPT:-*}" tput sgr0 || tput me else - printf %s "${ED_PROMPT:-'*'}" + printf %s "${ED_PROMPT:-*}" fi 2>/dev/null )" "$@" -- cgit v1.2.3 From 58acb5c5f157bf2bc4f30badd54874458fd55cc7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jan 2017 20:45:59 +1300 Subject: Revert "Remove some quotes that confused OpenBSD" This reverts commit f825245902048e324a3567e0967f21cc1fae5bd3. --- sh/shrc.d/ed.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index 2333cc0f..3e544c74 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -19,10 +19,10 @@ ed() { tput setaf "$ec" 0 0 || tput AF "$ec" || tput AF "$ec" 0 0 - printf %s "${ED_PROMPT:-*}" + printf %s "${ED_PROMPT:-'*'}" tput sgr0 || tput me else - printf %s "${ED_PROMPT:-*}" + printf %s "${ED_PROMPT:-'*'}" fi 2>/dev/null )" "$@" -- cgit v1.2.3 From 8bf807ab49a9de27a8a01157ebc7d7a770dfb229 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Jan 2017 20:46:01 +1300 Subject: Revert "Color ed(1) prompt if possible" This reverts commit ffd9d95b6adf5982448e1685a8c79c74b148cb00. --- sh/shrc.d/ed.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index 3e544c74..d7d3fa2f 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -11,20 +11,8 @@ ed() { [ -e "$HOME"/.cache/ed/verbose ] && set -- --verbose "$@" - # Add an asterisk prompt (POSIX feature); color it dark green if we can - set -- -p "$( - if [ "$(tput colors || tput Co)" -gt 8 ] ; then - ec=${ED_PROMPT_COLOR:-2} - tput setaf "$ec" || - tput setaf "$ec" 0 0 || - tput AF "$ec" || - tput AF "$ec" 0 0 - printf %s "${ED_PROMPT:-'*'}" - tput sgr0 || tput me - else - printf %s "${ED_PROMPT:-'*'}" - fi 2>/dev/null - )" "$@" + # Add an asterisk prompt (POSIX feature) + set -- -p\* "$@" # Run in rlwrap(1) if available set -- ed "$@" -- cgit v1.2.3 From 725caed4088358a7ebea4a9e855665ee8e1c84db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 21 Jan 2017 15:13:25 +1300 Subject: Add htref(1df) --- README.markdown | 3 ++- bin/htref | 3 +++ man/man1/htref.1df | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 bin/htref create mode 100644 man/man1/htref.1df diff --git a/README.markdown b/README.markdown index b0982a7d..3ee71195 100644 --- a/README.markdown +++ b/README.markdown @@ -405,9 +405,10 @@ Installed by the `install-bin` target: * `min(1df)` prints the minimum. * `mode(1df)` prints the first encountered mode. * `tot(1df)` totals the set. -* Two quick-and-dirty HTML text node content encoding tools: +* Three quick-and-dirty HTML tools: * `htenc(1df)` encodes. * `htdec(1df)` decodes. + * `htrec(1df)` wraps `a` tags around URLs. * `ap(1df)` reads arguments for a given command from the standard input, prompting if appropriate * `apf(1df)` prepends arguments to a command with ones read from a file, diff --git a/bin/htref b/bin/htref new file mode 100755 index 00000000..da089edc --- /dev/null +++ b/bin/htref @@ -0,0 +1,3 @@ +#!/bin/sed -f +# Quick-and-dirty HTML linkifier +s_https*://[^ \t<>]*_&_ diff --git a/man/man1/htref.1df b/man/man1/htref.1df new file mode 100644 index 00000000..922188dc --- /dev/null +++ b/man/man1/htref.1df @@ -0,0 +1,20 @@ +.TH HTREF 1df "January 2017" "Manual page for htref" +.SH NAME +.B htref +\- turn URLs into HTML links +.SH SYNOPSIS +htenc urls | +.B htref +| nlbr > urls.html +.SH DESCRIPTION +.B htref +looks for http:// and https:// URLs, and wraps tags around them +pointing to the same URL. HTML encoding of the URL should be done before this +step. +.P +All characters that are not spaces, tabs, or angle brackets are included in the +URL. +.SH SEE ALSO +htenc(1df) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 5bf128b692589b0056eea5a5112f968e0cf31348 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 21 Jan 2017 17:20:50 +1300 Subject: Remove an irrelevant issue These settings were removed in 0ac0571. --- ISSUES.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index 2fb2d46e..383d7906 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,7 +18,3 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file -* The stty tab0/tabs settings in .shrc work on my home machine but not at - work for some reason; pressing Tab in a cat(1) process still indents by - eight spaces; if I run "tabs 4" again it indents by 3 spaces then 4 spaces - (!) -- cgit v1.2.3 From b7a2ef8e9112302ee8b30becb45df51d5f46f085 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 21 Jan 2017 20:58:50 +1300 Subject: No title bar for i3 windows --- i3/config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/i3/config b/i3/config index b7c5dd5b..3c063c94 100644 --- a/i3/config +++ b/i3/config @@ -7,6 +7,9 @@ font pango:Verdana 7 # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod +# No title bar +new_window 1pixel + # Mod+Shift+r restarts i3wm bindsym $mod+Shift+r restart -- cgit v1.2.3 From 9643f292bb93557bff249d5b975d3c8a047aa7b6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Jan 2017 01:11:36 +1300 Subject: Change htref(1df) into proper source format --- .gitignore | 1 + Makefile | 1 + bin/htref | 3 --- bin/htref.sed | 2 ++ 4 files changed, 4 insertions(+), 3 deletions(-) delete mode 100755 bin/htref create mode 100644 bin/htref.sed diff --git a/.gitignore b/.gitignore index 8250c055..91f646d3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ bin/jfp bin/han bin/htdec bin/htenc +bin/htref bin/max bin/mean bin/med diff --git a/Makefile b/Makefile index 218b79f9..34be0053 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ BINS = bin/brnl \ bin/han \ bin/htdec \ bin/htenc \ + bin/htref \ bin/jfp \ bin/max \ bin/mean \ diff --git a/bin/htref b/bin/htref deleted file mode 100755 index da089edc..00000000 --- a/bin/htref +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sed -f -# Quick-and-dirty HTML linkifier -s_https*://[^ \t<>]*_&_ diff --git a/bin/htref.sed b/bin/htref.sed new file mode 100644 index 00000000..f2e943ca --- /dev/null +++ b/bin/htref.sed @@ -0,0 +1,2 @@ +# Quick-and-dirty HTML linkifier +s_https*://[^ \t<>]*_&_ -- cgit v1.2.3 From 060c814e1e263edb0d7f4c614460697391ad2911 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Jan 2017 01:16:57 +1300 Subject: Swap pph(1df) sed(1) subst for awk(1) concat Technically safer; regex metacharacters in the hostname (!) would break the sed. --- bin/pph | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pph b/bin/pph index 684aaafd..7987382f 100755 --- a/bin/pph +++ b/bin/pph @@ -1,5 +1,5 @@ #!/bin/sh # Run pp(1df) on args, prefix with machine hostname -hostname=$(hostname -s) || exit +hn=$(hostname -s) || exit pp "$@" | -sed 's_^_'"$hostname":'_' +awk -v hn="$hn" '{ print hn ":" $0 }' -- cgit v1.2.3 From 0fcdc79429fee582335dbd3b07f38f80db9689eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Jan 2017 12:55:44 +1300 Subject: Use explicit { print } rather than implicit 1 --- bin/sd2u.awk | 2 +- bin/su2d.awk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sd2u.awk b/bin/sd2u.awk index 87f710b2..02584952 100644 --- a/bin/sd2u.awk +++ b/bin/sd2u.awk @@ -1,3 +1,3 @@ # Convert DOS line endings to UNIX ones { sub(/\r$/, "") } -1 +{ print } diff --git a/bin/su2d.awk b/bin/su2d.awk index f9160ab0..34a8c5ae 100644 --- a/bin/su2d.awk +++ b/bin/su2d.awk @@ -1,3 +1,3 @@ # Convert UNIX line endings to DOS ones !/\r$/ { $0 = $0 "\r" } -1 +{ print } -- cgit v1.2.3 From 9def341b77dc076bd5c704fedb5f96e6c34168b3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Jan 2017 12:56:47 +1300 Subject: Fix a comment typo --- bin/vest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/vest b/bin/vest index d80c24d1..f857d8c1 100755 --- a/bin/vest +++ b/bin/vest @@ -1,5 +1,5 @@ #!/bin/sh -# Run a test(1) command a print a string to stdout showing pass/fail +# Run a test(1) command and print a string to stdout showing pass/fail if [ "$#" -eq 0 ] ; then printf >&2 'vest: Need test(1) arguments\n' exit 2 -- cgit v1.2.3 From 5981cb248e399b5594f9227b7de8f1c2b31e2c3f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Jan 2017 14:04:51 +1300 Subject: Work around trailing newlines in vr() This is ugly, but a better fix isn't evident to me just now. --- sh/shrc.d/vr.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sh/shrc.d/vr.sh b/sh/shrc.d/vr.sh index 1902e3ba..8b35357c 100644 --- a/sh/shrc.d/vr.sh +++ b/sh/shrc.d/vr.sh @@ -19,10 +19,16 @@ vr() { cd -- "$path" || exit # Ask Git the top level (good) - git rev-parse --show-toplevel 2>/dev/null && exit + if git rev-parse --show-toplevel 2>/dev/null ; then + printf / + exit + fi # Ask Mercurial the top level (great) - hg root 2>/dev/null && exit + if hg root 2>/dev/null ; then + printf / + exit + fi # If we can get SVN info, iterate upwards until we cannot; hopefully # that is the root (bad) @@ -32,7 +38,7 @@ vr() { cd .. || exit done if [ -n "$root" ] ; then - printf '%s\n' "$root" + printf '%s\n/' "$root" exit fi @@ -41,6 +47,9 @@ vr() { exit 1 )" + # Chop the trailing newline and slash + set -- "${1%?/}" + # Check we figured out a target, or bail [ -n "$1" ] || return -- cgit v1.2.3 From a9c7669e1d9e1e16bde23a0f51ccd1c573d037de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 24 Jan 2017 17:25:24 +1300 Subject: Remove SHLVL nested shell feature for now Causes a bit too much curliness in configuration; may need a more comprehensive approach. --- README.markdown | 16 ++++++---------- X/xinitrc.d/shlvl.sh | 2 -- X/xinitrc.d/xbindkeys.sh | 2 +- bash/bashrc.d/prompt.bash | 6 ------ ksh/kshrc.d/prompt.ksh | 8 -------- tmux/tmux.conf.m4 | 6 +----- zsh/zshrc.d/prompt.zsh | 6 ------ 7 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 X/xinitrc.d/shlvl.sh diff --git a/README.markdown b/README.markdown index 3ee71195..0057415f 100644 --- a/README.markdown +++ b/README.markdown @@ -122,20 +122,17 @@ after testing `BASH_VERSINFO` appropriately. A terminal session with my prompt looks something like this: ~$ ssh remote - tom@remote:~$ bash - >tom@remote:~$ cd .dotfiles - >tom@remote:~/.dotfiles(master+!)$ git status + tom@remote:~$ cd .dotfiles + tom@remote:~/.dotfiles(master+!)$ git status M README.markdown M bash/bashrc.d/prompt.bash A init - >tom@remote:~/.dotfiles(master+!)$ foobar + tom@remote:~/.dotfiles(master+!)$ foobar foobar: command not found - >tom@remote:~/.dotfiles(master+!)<127>$ sleep 5 & + tom@remote:~/.dotfiles(master+!)<127>$ sleep 5 & [1] 28937 - >tom@remote:~/.dotfiles(master+!){1}$ + tom@remote:~/.dotfiles(master+!){1}$ -If `SHLVL` is greater than one, right angle brackets are added to show how many -`bash` instances deep into the process tree we are, taking into account `tmux`. The username and hostname are elided if not connected via SSH. The working directory is always shown. The rest of the prompt expands based on context to include these elements in this order: @@ -148,8 +145,7 @@ include these elements in this order: * The exit status of the last command, if non-zero You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all -do about what you'd expect. `PROMPT_PREFIX` will appear after the `SHLVL` angle -brackets. +do about what you'd expect. This is all managed within the `prompt` function. There's some mildly hacky logic on `tput` codes included such that it should work correctly for most diff --git a/X/xinitrc.d/shlvl.sh b/X/xinitrc.d/shlvl.sh deleted file mode 100644 index 0e3bad04..00000000 --- a/X/xinitrc.d/shlvl.sh +++ /dev/null @@ -1,2 +0,0 @@ -# Reset SHLVL -unset SHLVL diff --git a/X/xinitrc.d/xbindkeys.sh b/X/xinitrc.d/xbindkeys.sh index b50f5c60..b76aebdd 100644 --- a/X/xinitrc.d/xbindkeys.sh +++ b/X/xinitrc.d/xbindkeys.sh @@ -1,3 +1,3 @@ # Start xbindkeys(1) command -v xbindkeys >/dev/null 2>&1 || return -(cd -- "$HOME" && SHLVL= xbindkeys -n) & +(cd -- "$HOME" && xbindkeys -n) & diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 123c4146..c954ef97 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -28,12 +28,6 @@ prompt() { # Add terminating "$" or "#" sign PS1=$PS1'\$' - # Add > symbols to show nested shells - local shlvl - for ((shlvl = 1; shlvl < SHLVL; shlvl++)) ; do - PS1='>'$PS1 - done - # Declare variables to contain terminal control strings local format reset diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 84129efc..925db0cf 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -28,14 +28,6 @@ function prompt { # Add terminating "$" or "#" sign PS1=$PS1'\$' - # Add > symbols to show nested shells - typeset shlvl - shlvl=1 - while ((shlvl < SHLVL)); do - PS1='>'$PS1 - ((shlvl++)) - done - # Declare variables to contain terminal control strings typeset format reset diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 index 9f1aa80f..a4af9f8e 100644 --- a/tmux/tmux.conf.m4 +++ b/tmux/tmux.conf.m4 @@ -8,16 +8,12 @@ set-environment -gru SSH_CONNECTION set-environment -gru SSH_TTY set-environment -gru WINDOWID -# Reset SHLVL -set-environment -gru SHLVL - # Otherwise, use the environment we had when we started; don't touch it during # a session unless I specifically ask set-option -g update-environment '' # Setting this makes each new pane a non-login shell, which suits me better -# Clear away SHLVL again first to stop it getting incremented twice -set-option -g default-command "unset SHLVL ; exec $SHELL" +set-option -g default-command "$SHELL" # Expect a 256-color terminal set-option -g default-terminal 'screen-256color' diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index 898031ea..a22739d3 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -24,12 +24,6 @@ prompt() { # Add terminating "$" or "#" sign PS1=$PS1'%#' - # Add > symbols to show nested shells - local shlvl - for ((shlvl = 1; shlvl < SHLVL; shlvl++)) ; do - PS1='>'$PS1 - done - # Bold and color the prompt if it looks like we can if (( $({ tput colors || tput Co ; } 2>/dev/null) >= 8 )) ; then PS1='%B%F{cyan}'$PS1'%f%b' -- cgit v1.2.3 From 62705a6a34f9023f859681e1a6640d961092d4be Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 24 Jan 2017 17:37:05 +1300 Subject: Add an issue --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 39d9511e..b47977a4 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -10,3 +10,5 @@ Ideas * Convert all the manual pages to mandoc maybe? * Add "pop" and "shift" methods to path() * edio(1df), like vipe(1) +* Allow specifying foreground and background colours for tmux configuration + files; would be useful for work -- cgit v1.2.3 From 38c96c44e908d456b503722b8850bf303a273cfa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 10:20:53 +1300 Subject: Revise custom tmux colouring --- IDEAS.markdown | 2 -- Makefile | 5 +++-- tmux/tmux.conf.m4 | 13 ++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index b47977a4..39d9511e 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -10,5 +10,3 @@ Ideas * Convert all the manual pages to mandoc maybe? * Add "pop" and "shift" methods to path() * edio(1df), like vipe(1) -* Allow specifying foreground and background colours for tmux configuration - files; would be useful for work diff --git a/Makefile b/Makefile index 34be0053..e16dc944 100644 --- a/Makefile +++ b/Makefile @@ -137,10 +137,11 @@ mutt/muttrc : mutt/muttrc.m4 -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ mutt/muttrc.m4 > mutt/muttrc -TMUX_COLOR := colour237 +TMUX_BG := colour237 +TMUX_FG := colour248 tmux/tmux.conf : tmux/tmux.conf.m4 - m4 -D TMUX_COLOR="$(TMUX_COLOR)" \ + m4 -D TMUX_BG="$(TMUX_BG)" -D TMUX_FG="$(TMUX_FG)" \ tmux/tmux.conf.m4 > tmux/tmux.conf .awk : diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 index a4af9f8e..4e3cce4d 100644 --- a/tmux/tmux.conf.m4 +++ b/tmux/tmux.conf.m4 @@ -112,17 +112,16 @@ set-option -g message-style "bg=colour18,fg=colour231" # Window choosers are white on blue set-window-option -g mode-style "bg=colour18,fg=colour231" -# Pane borders are always in dark gray -set-option -g pane-border-style "fg=TMUX_COLOR" -set-option -g pane-active-border-style "fg=TMUX_COLOR" +# Pane borders are always in the background color +set-option -g pane-border-style "fg=TMUX_BG" +set-option -g pane-active-border-style "fg=TMUX_BG" -# Inactive windows have a slightly grayed-out background and default text +# Inactive windows have slightly washed-out system colours set-option -g window-style "bg=colour232,fg=colour248" set-option -g window-active-style "bg=colour0,fg=colour15" -# The status bar defaults to light gray on dark gray, which applies to the left -# and right status bar sections described in status-left and status-right above -set-option -g status-style "bg=TMUX_COLOR,fg=colour248" +# The status bar has the defined background and foreground colours +set-option -g status-style "bg=TMUX_BG,fg=TMUX_FG" # Titles of windows default to black text with no embellishment set-window-option -g window-status-style "fg=colour16" -- cgit v1.2.3 From ea63b63d8149802373fc406387faa29420de36e9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 11:33:32 +1300 Subject: Add some missing periods --- README.markdown | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.markdown b/README.markdown index 0057415f..9c956d51 100644 --- a/README.markdown +++ b/README.markdown @@ -140,9 +140,9 @@ include these elements in this order: * Whether in a Git repository if applicable, and punctuation to show repository status including reference to upstreams at a glance. Subversion support can also be enabled (I need it at work), in which case a `git:` or - `svn:` prefix is added appropriately -* The number of running background jobs, if non-zero -* The exit status of the last command, if non-zero + `svn:` prefix is added appropriately. +* The number of running background jobs, if non-zero. +* The exit status of the last command, if non-zero. You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all do about what you'd expect. @@ -406,7 +406,7 @@ Installed by the `install-bin` target: * `htdec(1df)` decodes. * `htrec(1df)` wraps `a` tags around URLs. * `ap(1df)` reads arguments for a given command from the standard input, - prompting if appropriate + prompting if appropriate. * `apf(1df)` prepends arguments to a command with ones read from a file, intended as a framework for shell wrappers or functions. * `ax(1df)` evaluates an awk expression given on the command line; this is @@ -414,7 +414,7 @@ Installed by the `install-bin` target: * `bcq(1df)` runs `bc(1)`, quieting it down if need be. * `bel(1df)` prints a terminal bell character. * `bl(1df)` generates a given number of blank lines. -* `bp(1df)` runs `br(1df)` after prompting for an URL +* `bp(1df)` runs `br(1df)` after prompting for an URL. * `br(1df)` launches `$BROWSER`, or a more suitable application for an URL if it knows of one. * `ca(1df)` prints a count of its given arguments. @@ -425,9 +425,9 @@ Installed by the `install-bin` target: * `clog(1df)` is a tiny timestamped log system. * `clrd(1df)` sets up a per-line file read, clearing the screen first. * `clwr(1df)` sets up a per-line file write, clearing the screen before each - line + line. * `csmw(1df)` prints an English list of monospace-quoted words read from the - input + input. * `ddup(1df)` removes duplicate lines from unsorted input. * `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X CLIPBOARD. @@ -441,7 +441,7 @@ Installed by the `install-bin` target: * `finc(1df)` counts the number of results returned from a set of given `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary - files, printing their paths and line counts + files, printing their paths and line counts. * `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the script `getmails` in the `getmail` suite, but runs the requests in parallel and does up to three silent retries using `try(1df)`. -- cgit v1.2.3 From c6b5580e25a941ef88e3d16a2059dfbd99f77431 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 12:00:25 +1300 Subject: Add an issue --- ISSUES.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 383d7906..c2b7f350 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -15,6 +15,7 @@ Known issues jobspecs around that flee after a jobs builtin run; only saw this manifest after 90dcadf; either I understand job specs really poorly or this may be a bug in bash + * Need to figure out whether this is still needed * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file -- cgit v1.2.3 From dc0ba282b6e41c1c4b2dfba2ea362cf88a7f8c29 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 12:04:24 +1300 Subject: Be more specific in ref name trimming e.g. for a namespaced branch "foo/bar/bar", don't strip the leading part off --- bash/bashrc.d/prompt.bash | 2 +- ksh/kshrc.d/prompt.ksh | 2 +- zsh/zshrc.d/prompt.zsh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index c954ef97..b22f118f 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -104,7 +104,7 @@ prompt() { git describe --tags --exact-match HEAD || git rev-parse --short HEAD ) || return - name=${name##*/} + name=${name#refs/*/} [[ -n $name ]] || return # Check various files in .git to flag processes diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 925db0cf..bf77f626 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -100,7 +100,7 @@ function prompt { git describe --tags --exact-match HEAD || git rev-parse --short HEAD ) || return - name=${name##*/} + name=${name#refs/*/} [[ -n $name ]] || return # Check various files in .git to flag processes diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index a22739d3..cfac7ffd 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -67,7 +67,7 @@ prompt() { git describe --tags --exact-match HEAD || git rev-parse --short HEAD ) || return - name=${name##*/} + name=${name#refs/*/} [[ -n $name ]] || return # Check various files in .git to flag processes -- cgit v1.2.3 From 023afa3d93036e7eca9774f7e68690d397c5e44d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 12:39:47 +1300 Subject: Add FreeBSD -G to ls() wrapper Not sure this is the correct approach yet. I'm not sure I like the CLICOLOR environment variable. --- sh/shrc.d/ls.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 58263e96..c7703663 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -31,6 +31,12 @@ ls() { [ -e "$HOME"/.cache/ls/time-style ] && set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" + # Add -G for colorized output if the operating system is FreeBSD + # We have to check because -G means something else to e.g. GNU ls(1) + case $OS in + FreeBSD) set -- -G "$@" ;; + esac + # Run ls(1) with the concluded arguments command ls "$@" } -- cgit v1.2.3 From f5b0b481c3b5c6a1dfd089ec99582c0d5cc0e1b9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 13:32:34 +1300 Subject: Add -D option for FreeBSD ls() --- sh/shrc.d/ls.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index c7703663..0fc6923a 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -31,10 +31,14 @@ ls() { [ -e "$HOME"/.cache/ls/time-style ] && set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" - # Add -G for colorized output if the operating system is FreeBSD - # We have to check because -G means something else to e.g. GNU ls(1) + # If the operating system is FreeBSD, there are some specific options we + # can add that might mean different things to e.g. GNU ls(1) case $OS in - FreeBSD) set -- -G "$@" ;; + FreeBSD) + # -D: Timestamp format + # -G: Use color + set -- -D '%Y-%m-%d %H:%M:%S' -G "$@" + ;; esac # Run ls(1) with the concluded arguments -- cgit v1.2.3 From 43c88db1a7b402f28567e2659a40943b2a1a54ac Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:00:17 +1300 Subject: Clear away all aliases for interactive shells Some systems like OpenBSD or Slackware set up well-meaning aliases that I don't want. We do this for Bash, Yash, and Zsh, but not for Ksh, because it looks like its implementations all variously use aliases to implement some POSIX builtins like fc(1) or type(1) in terms of their own builtins. --- bash/bashrc | 5 +++++ yash/yashrc | 5 +++++ zsh/zshrc | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/bash/bashrc b/bash/bashrc index 3070c00c..ca13c4bf 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -9,6 +9,11 @@ esac # shellcheck disable=SC2128 [ -n "$BASH_VERSINFO" ] && shopt -q restricted_shell && return +# Clear away all aliases; we do this here rather than in $ENV because the ksh +# family of shells relies on aliases to implement certain POSIX utilities like +# fc(1) and type(1) +unalias -a + # If ENV is set, source it to get all the POSIX-compatible interactive stuff; # we should be able to do this even if we're running a truly ancient Bash [ -n "$ENV" ] && . "$ENV" diff --git a/yash/yashrc b/yash/yashrc index a731c80b..c2b2df26 100644 --- a/yash/yashrc +++ b/yash/yashrc @@ -1,3 +1,8 @@ +# Clear away all aliases; we do this here rather than in $ENV because the ksh +# family of shells relies on aliases to implement certain POSIX utilities like +# fc(1) and type(1) +unalias -a + # Load POSIX interactive shell startup files, because Yash won't do it if not # invoked as sh(1) [ -e "$ENV" ] && . "$ENV" diff --git a/zsh/zshrc b/zsh/zshrc index a97c0a73..68f8ffc7 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,6 +1,11 @@ # Emacs keybindings even if EDITOR is vi(1) bindkey -e +# Clear away all aliases; we do this here rather than in $ENV because the ksh +# family of shells relies on aliases to implement certain POSIX utilities like +# fc(1) and type(1) +unalias -a + # If ENV is set, source it to get all the POSIX-compatible interactive stuff [[ -n $ENV ]] && source "$ENV" -- cgit v1.2.3 From a03e567632b1104433c7f53768fc28566b42d438 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:08:24 +1300 Subject: Move Zsh keybinding setup to after ENV sourcing --- zsh/zshrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zsh/zshrc b/zsh/zshrc index 68f8ffc7..796e8680 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,6 +1,3 @@ -# Emacs keybindings even if EDITOR is vi(1) -bindkey -e - # Clear away all aliases; we do this here rather than in $ENV because the ksh # family of shells relies on aliases to implement certain POSIX utilities like # fc(1) and type(1) @@ -9,6 +6,9 @@ unalias -a # If ENV is set, source it to get all the POSIX-compatible interactive stuff [[ -n $ENV ]] && source "$ENV" +# Emacs keybindings even if EDITOR is vi(1) +bindkey -e + # History settings setopt histignorealldups sharehistory HISTFILE=$HOME/.zsh_history -- cgit v1.2.3 From e3f97d6c12e6e311b155ce24ce586717b1abc18b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:31:32 +1300 Subject: Show prompt prefix if a shell is exotic That is, include e.g. "ksh:" as a prefix to the prompt if the user appears to have Bash or Zsh (or anything else) as their login shell. This is probably imperfect, but it's a start. --- README.markdown | 3 +++ bash/bashrc.d/prompt.bash | 6 ++++++ ksh/kshrc.d/prompt.ksh | 14 ++++++++++++++ zsh/zshrc.d/prompt.zsh | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/README.markdown b/README.markdown index 9c956d51..70234ed8 100644 --- a/README.markdown +++ b/README.markdown @@ -147,6 +147,9 @@ include these elements in this order: You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all do about what you'd expect. +If you start up Bash, Ksh, or Zsh and it detects that it's not normally your +`$SHELL`, the prompt will display an appropriate prefix. + This is all managed within the `prompt` function. There's some mildly hacky logic on `tput` codes included such that it should work correctly for most common terminals using both `termcap(5)` and `terminfo(5)`, including \*BSD diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index b22f118f..2bd70c2f 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -22,6 +22,12 @@ prompt() { # Add sub-commands; VCS, job, and return status checks PS1=$PS1'$(ret=$?;prompt vcs;prompt job;prompt ret)' + # Add a helpful prefix if this shell appears to be exotic + case ${SHELL##*/} in + (bash) ;; + (*) PS1=bash:$PS1 ;; + esac + # Add prefix and suffix PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}' diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index bf77f626..09c7de6e 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -22,6 +22,20 @@ function prompt { # count, and previous command return value PS1=$PS1'$(ret=$?;jobc=$(jobs -p|sed -n '\''$='\'');prompt pwd;prompt vcs;prompt job;prompt ret;:)' + # Add a helpful prefix if this shell appears to be exotic + typeset ksh + case $KSH_VERSION in + (*'93'*) ksh=ksh93 ;; + (*'PD KSH'*) ksh=pdksh ;; + (*'MIRBSD KSH'*) ksh=mksh ;; + esac + case ${SHELL##*/} in + ('') ;; + (ksh) ;; + ("$ksh") ;; + (*) PS1=$ksh:$PS1 ;; + esac + # Add prefix and suffix PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}' diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index cfac7ffd..f374dbec 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -18,6 +18,12 @@ prompt() { # Add sub-commands; VCS, job, and return status checks PS1=$PS1'$(ret=$?;prompt vcs;prompt job;prompt ret)' + # Add a helpful prefix if this shell appears to be exotic + case ${SHELL##*/} in + (zsh) ;; + (*) PS1=zsh:$PS1 ;; + esac + # Add prefix and suffix PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}' -- cgit v1.2.3 From b485b356ca4890eef7df132ee4b12642af254ab5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:35:50 +1300 Subject: Ignore `unalias` failed call output in zsh zsh 5.0.7 doesn't appear to implement -a for zsh, but 5.2 does --- zsh/zshrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zsh/zshrc b/zsh/zshrc index 796e8680..b4c60747 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,7 +1,8 @@ # Clear away all aliases; we do this here rather than in $ENV because the ksh # family of shells relies on aliases to implement certain POSIX utilities like -# fc(1) and type(1) -unalias -a +# fc(1) and type(1). Ignore output, as older Zsh seems not to implement this +# (quelle surprise). +unalias -a >/dev/null 2>&1 # If ENV is set, source it to get all the POSIX-compatible interactive stuff [[ -n $ENV ]] && source "$ENV" -- cgit v1.2.3 From 1200846f20de92c3bf8f88f4230ccbb9ab047969 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:44:48 +1300 Subject: Add an issue --- ISSUES.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index c2b7f350..e4c4a161 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -19,3 +19,6 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file +* I'm still not sure that the special character escaping for the ksh prompt + actually works. The line-wrapping behaviour for ksh93 seems to be a bit + weird. This requires debugging. -- cgit v1.2.3 From ff0041f1416098cbd90d4374c72e8cb6ff9c22b3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 14:51:53 +1300 Subject: Avoid a fork in options detection --- sh/profile.d/options.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index 345888d0..a668a360 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -1,10 +1,13 @@ # Cache the options available to certain programs. Run all this in a subshell # (none of its state needs to endure in the session) ( -options() ( +options() { # Check or create the directory to cache the options + # Shift the program name off; remaining arguments are the options to check dir=$HOME/.cache/$1 + prog=$1 + shift # Directory already exists; bail out [ -d "$dir" ] && exit @@ -14,18 +17,16 @@ options() ( cd -- "$dir" || exit # Write the program's --help output to a file, even if it's empty - "$1" --help help 2>/dev/null || exit - - # Shift the program name off; remaining arguments are the options to check - shift + # This probably only works with GNU tools in general + "$prog" --help help 2>/dev/null || exit - # Iterate through some useful options and create files to show they're - # available if found in the help output + # Iterate through remaining arguments (desired options), creating files to + # show they're available if found in the help output for opt ; do command -p grep -q -- '[^[:alnum:]]--'"$opt"'[^[:alnum:]]' help && touch -- "$opt" done -) +} # Cache options for bc(1) options bc \ -- cgit v1.2.3 From ae16b1077311c228048f040f93977d3ae862340b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 25 Jan 2017 16:30:16 +1300 Subject: Add "pop" and "shift" methods to path() --- IDEAS.markdown | 1 - bash/bash_completion.d/path.bash | 2 +- sh/shrc.d/path.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 39d9511e..25b79516 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -8,5 +8,4 @@ Ideas manageable * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? -* Add "pop" and "shift" methods to path() * edio(1df), like vipe(1) diff --git a/bash/bash_completion.d/path.bash b/bash/bash_completion.d/path.bash index a65e10ce..ba2dcb79 100644 --- a/bash/bash_completion.d/path.bash +++ b/bash/bash_completion.d/path.bash @@ -6,7 +6,7 @@ _path() { # Complete operation as first word local cmd - for cmd in list insert append remove check help ; do + for cmd in list insert append remove shift pop check help ; do [[ $cmd == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue COMPREPLY[${#COMPREPLY[@]}]=$cmd done diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 23eec75b..2759e11f 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -79,6 +79,40 @@ path() { PATH=${PATH%%:} ;; + # Remove the first directory in $PATH + shift) + case $PATH in + '') + printf >&2 'path(): %s: PATH is empty!\n' "$@" + return 1 + ;; + *:*) + PATH=${PATH#*:} + ;; + *) + # shellcheck disable=SC2123 + PATH= + ;; + esac + ;; + + # Remove the last directory in $PATH + pop) + case $PATH in + '') + printf >&2 'path(): %s: PATH is empty!\n' "$@" + return 1 + ;; + *:*) + PATH=${PATH%:*} + ;; + *) + # shellcheck disable=SC2123 + PATH= + ;; + esac + ;; + # Check whether a directory is in PATH check) path _argcheck "$@" || return @@ -103,6 +137,10 @@ USAGE: Add directory DIR (default $PWD) to the end of PATH path remove [DIR] Remove directory DIR (default $PWD) from PATH + path shift + Remove the first directory from PATH + path pop + Remove the last directory from PATH path check [DIR] Return whether directory DIR (default $PWD) is a component of PATH path help -- cgit v1.2.3 From 0d6874e9bcc2ca628857bb1bfbed978fcee53a2b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 08:17:37 +1300 Subject: Allow specifying MAILDIR for make(1) --- Makefile | 15 +++++++++------ mutt/muttrc.m4 | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e16dc944..193a9bf4 100644 --- a/Makefile +++ b/Makefile @@ -132,9 +132,12 @@ man/man7/dotfiles.7df : README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o "$@" +MAILDIR := $(HOME)/Mail + mutt/muttrc : mutt/muttrc.m4 m4 \ -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ + -D DOTFILES_MAILDIR="$(MAILDIR)" \ mutt/muttrc.m4 > mutt/muttrc TMUX_BG := colour237 @@ -258,12 +261,12 @@ install-less : install-maildir : install -m 0755 -d -- \ - "$(HOME)"/Mail/inbox/cur \ - "$(HOME)"/Mail/inbox/new \ - "$(HOME)"/Mail/inbox/tmp \ - "$(HOME)"/Mail/sent/cur \ - "$(HOME)"/Mail/sent/new \ - "$(HOME)"/Mail/sent/tmp + "$(MAILDIR)"/inbox/cur \ + "$(MAILDIR)"/inbox/new \ + "$(MAILDIR)"/inbox/tmp \ + "$(MAILDIR)"/sent/cur \ + "$(MAILDIR)"/sent/new \ + "$(MAILDIR)"/sent/tmp install-mutt : mutt/muttrc install-maildir install -m 0755 -d -- \ diff --git a/mutt/muttrc.m4 b/mutt/muttrc.m4 index 587d879e..f84dc16e 100644 --- a/mutt/muttrc.m4 +++ b/mutt/muttrc.m4 @@ -12,7 +12,7 @@ set sendmail = 'DOTFILES_SENDMAIL' # Mailbox type and location set mbox_type = 'Maildir' -set folder = '~/Mail/' +set folder = 'DOTFILES_MAILDIR' # Submailboxes set spoolfile = '+inbox' -- cgit v1.2.3 From bd4868042575238538aac8367c4efb9cef9841a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 08:26:16 +1300 Subject: Create muttrc.local if it doesn't exist --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 193a9bf4..ae9eedff 100644 --- a/Makefile +++ b/Makefile @@ -274,6 +274,7 @@ install-mutt : mutt/muttrc install-maildir "$(HOME)"/.cache/mutt install -pm 0644 -- mutt/muttrc "$(HOME)"/.muttrc install -pm 0644 -- mutt/signature "$(HOME)"/.signature + [ -f "$(HOME)"/.mutt/muttrc.local ] || touch "$(HOME)"/.mutt/muttrc.local install-ncmcpp : install -m 0755 -d -- "$(HOME)"/.ncmpcpp -- cgit v1.2.3 From f5291ac899e0fbcb18ff7a41ab7b06f296ae1462 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 12:09:34 +1300 Subject: Add an idea --- IDEAS.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 25b79516..610e0914 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,3 +9,4 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * edio(1df), like vipe(1) +* Maybe add ~/.mailrc -- cgit v1.2.3 From 8d8b41a243caf9f9897482ffe549c771792878dd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 13:04:50 +1300 Subject: Add ~/.mailrc config --- .gitignore | 1 + IDEAS.markdown | 1 - Makefile | 11 ++++++++++- README.markdown | 1 + mail/mailrc.m4 | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 mail/mailrc.m4 diff --git a/.gitignore b/.gitignore index 91f646d3..b0ad92d7 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ games/strik games/zs git/gitconfig gnupg/gpg.conf +mail/mailrc man/man7/dotfiles.7df mutt/muttrc tmux/tmux.conf diff --git a/IDEAS.markdown b/IDEAS.markdown index 610e0914..25b79516 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,4 +9,3 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * edio(1df), like vipe(1) -* Maybe add ~/.mailrc diff --git a/Makefile b/Makefile index ae9eedff..1e8664af 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ install-gtk \ install-i3 \ install-less \ + install-mail \ install-maildir \ install-mutt \ install-ncmcpp \ @@ -111,6 +112,7 @@ clean distclean : $(GAMES) \ git/gitconfig \ gnupg/gpg.conf \ + mail/mailrc \ man/man7/dotfiles.7df \ mutt/muttrc \ tmux/tmux.conf \ @@ -128,6 +130,10 @@ gnupg/gpg.conf : gnupg/gpg.conf.m4 m4 -D DOTFILES_HOME="$(HOME)" \ gnupg/gpg.conf.m4 > gnupg/gpg.conf +mail/mailrc : mail/mailrc.m4 + m4 -D DOTFILES_SENDMAIL="$$(command -v "$(SENDMAIL)")" \ + mail/mailrc.m4 > "$@" + man/man7/dotfiles.7df : README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o "$@" @@ -259,6 +265,9 @@ install-less : install -pm 0644 -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey +install-mail : + install -pm 0644 -- mail/mailrc "$(HOME)"/.mailrc + install-maildir : install -m 0755 -d -- \ "$(MAILDIR)"/inbox/cur \ @@ -268,7 +277,7 @@ install-maildir : "$(MAILDIR)"/sent/new \ "$(MAILDIR)"/sent/tmp -install-mutt : mutt/muttrc install-maildir +install-mutt : mutt/muttrc install-mail install-maildir install -m 0755 -d -- \ "$(HOME)"/.mutt \ "$(HOME)"/.cache/mutt diff --git a/README.markdown b/README.markdown index 70234ed8..be0f6481 100644 --- a/README.markdown +++ b/README.markdown @@ -58,6 +58,7 @@ Configuration is included for: elements * [i3](https://i3wm.org/) -- Tiling window manager * [less](https://www.gnu.org/software/less/) -- Terminal pager +* `mail(1)` -- classic mail program * [Mutt](http://www.mutt.org/) -- Terminal mail user agent * [`mysql(1)`](http://linux.die.net/man/1/mysql) -- Command-line MySQL client * [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client diff --git a/mail/mailrc.m4 b/mail/mailrc.m4 new file mode 100644 index 00000000..873fe080 --- /dev/null +++ b/mail/mailrc.m4 @@ -0,0 +1,3 @@ +set sendmail=DOTFILES_SENDMAIL +unset askcc +set nosave skipempty -- cgit v1.2.3 From 3ba06ca19404c07587d86e83c10b5979c0e88e6f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 15:08:35 +1300 Subject: Allow specifying GnuPG keyserver --- Makefile | 6 +++++- gnupg/gpg.conf.m4 | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1e8664af..9a476a4b 100644 --- a/Makefile +++ b/Makefile @@ -126,8 +126,12 @@ git/gitconfig : git/gitconfig.m4 -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ git/gitconfig.m4 > git/gitconfig +KEYSERVER := hkps://hkps.pool.sks-keyservers.net + gnupg/gpg.conf : gnupg/gpg.conf.m4 - m4 -D DOTFILES_HOME="$(HOME)" \ + m4 \ + -D DOTFILES_HOME="$(HOME)" \ + -D DOTFILES_KEYSERVER="$(KEYSERVER)" \ gnupg/gpg.conf.m4 > gnupg/gpg.conf mail/mailrc : mail/mailrc.m4 diff --git a/gnupg/gpg.conf.m4 b/gnupg/gpg.conf.m4 index 8531a742..dbbed306 100644 --- a/gnupg/gpg.conf.m4 +++ b/gnupg/gpg.conf.m4 @@ -22,7 +22,7 @@ fixed-list-mode keyid-format 0xlong # Use a pool of servers which support HKPS (encrypted key retrieval) -keyserver hkps://hkps.pool.sks-keyservers.net +keyserver DOTFILES_KEYSERVER # Retrieve keys automatically; check the keyserver port cert; use whichever # server is proffered from the pool -- cgit v1.2.3 From 91ee5659e4d8144747ce7e4acdc2f4c7aeeed0c2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 15:16:20 +1300 Subject: Add missing dependency --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9a476a4b..52642bf5 100644 --- a/Makefile +++ b/Makefile @@ -269,7 +269,7 @@ install-less : install -pm 0644 -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey -install-mail : +install-mail : mail/mailrc install -pm 0644 -- mail/mailrc "$(HOME)"/.mailrc install-maildir : -- cgit v1.2.3 From dfba229d697dcac47a113fae8b6738db785efb21 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 15:23:17 +1300 Subject: Source local Mutt config at the end not the start --- mutt/muttrc.m4 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mutt/muttrc.m4 b/mutt/muttrc.m4 index f84dc16e..4709adef 100644 --- a/mutt/muttrc.m4 +++ b/mutt/muttrc.m4 @@ -1,7 +1,3 @@ -# Person-specific settings -# (Define 'from', 'realname', and specify alternate addresses in here) -source ~/.mutt/muttrc.local - # Names set use_domain = yes set use_from = yes @@ -152,3 +148,6 @@ macro generic,index,browser,pager gm '!gms --quiet &' 'Run gms' # Shortcut to add addresses to abook macro index,pager A 'abook --add-email' 'Add sender address to abook' + +# Machine or account specific settings +source ~/.mutt/muttrc.local -- cgit v1.2.3 From 5f2eb3a2b486943d73633934f634df96a536c61b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 15:29:37 +1300 Subject: Create drafts directory --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 52642bf5..145dbc92 100644 --- a/Makefile +++ b/Makefile @@ -274,6 +274,9 @@ install-mail : mail/mailrc install-maildir : install -m 0755 -d -- \ + "$(MAILDIR)"/drafts/cur \ + "$(MAILDIR)"/drafts/new \ + "$(MAILDIR)"/drafts/tmp \ "$(MAILDIR)"/inbox/cur \ "$(MAILDIR)"/inbox/new \ "$(MAILDIR)"/inbox/tmp \ -- cgit v1.2.3 From ddecb8816020199cf5962e4bab20368bdd7da712 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 18:23:20 +1300 Subject: Use nicer mailbox creation --- Makefile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 145dbc92..504e48e4 100644 --- a/Makefile +++ b/Makefile @@ -273,16 +273,12 @@ install-mail : mail/mailrc install -pm 0644 -- mail/mailrc "$(HOME)"/.mailrc install-maildir : - install -m 0755 -d -- \ - "$(MAILDIR)"/drafts/cur \ - "$(MAILDIR)"/drafts/new \ - "$(MAILDIR)"/drafts/tmp \ - "$(MAILDIR)"/inbox/cur \ - "$(MAILDIR)"/inbox/new \ - "$(MAILDIR)"/inbox/tmp \ - "$(MAILDIR)"/sent/cur \ - "$(MAILDIR)"/sent/new \ - "$(MAILDIR)"/sent/tmp + for box in drafts inbox sent ; do \ + for dir in cur new tmp ; do \ + install -m 0755 -d -- \ + "$(MAILDIR)"/"$$box"/"$$dir" ; \ + done ; \ + done install-mutt : mutt/muttrc install-mail install-maildir install -m 0755 -d -- \ -- cgit v1.2.3 From 63447d90aae253088100c62499aa6f8aeb3734c2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 18:33:09 +1300 Subject: Confirmed jobs weirdness still an issue ~$ bash --version GNU bash, version 4.4.5(1)-release (x86_64-pc-linux-gnu) --- ISSUES.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index e4c4a161..c29fc284 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -15,7 +15,6 @@ Known issues jobspecs around that flee after a jobs builtin run; only saw this manifest after 90dcadf; either I understand job specs really poorly or this may be a bug in bash - * Need to figure out whether this is still needed * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file -- cgit v1.2.3 From 7a44a93714d328a37c18c7afec98e6c1f7be060c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 19:07:02 +1300 Subject: Mention that csmw(1df) backticks words --- man/man1/csmw.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/csmw.1df b/man/man1/csmw.1df index e7ef7284..787c2da4 100644 --- a/man/man1/csmw.1df +++ b/man/man1/csmw.1df @@ -13,7 +13,8 @@ program | .B csmw .SH DESCRIPTION Reads a list of whitespace-separated words and prints an English -comma-and-"and" separated list: +comma-and-"and" separated list, with each word between backticks with the +expectation it'll be used in Markdown. .P $ csmw foo -- cgit v1.2.3 From 1e22f51087cf941311c553c7113ad2f35f7df5c9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Jan 2017 20:55:48 +1300 Subject: Fixed prompt alignment hack for ksh The manual page for mksh hints that the escaped initial character should in fact be a carriage return, not a newline. That seems to work really well. The newline variable was an empty string before this commit anyway because it was stripped by the subshell expansion. --- ksh/kshrc.d/prompt.ksh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 09c7de6e..1dcbd864 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -81,11 +81,11 @@ function prompt { # Play ball with ksh's way of escaping non-printing characters typeset es nl - es=$(printf '\00') - nl=$(printf '\n') + es=$(printf '\01') + cr=$(printf '\r') # String it all together - PS1="${es}${nl}${es}${format}${es}${PS1}${es}${reset}${es}"' ' + PS1="${es}${cr}${es}${format}${es}${PS1}${es}${reset}${es}"' ' PS2='> ' PS3='? ' PS4='+<$?> $LINENO:' -- cgit v1.2.3 From d5f521fb213c82fbd68fad8f5e36d61527bb0757 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Jan 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 21ce415b..6a5cc051 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 21ce415bd93225c3b10010b650652f07dd229129 +Subproject commit 6a5cc0511776b69994b5e3bb2cacccbb81fa8464 -- cgit v1.2.3 From 8cc85ff3ffe5ebd1260ed276fc2b35621ccfba55 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Jan 2017 13:03:09 +1300 Subject: Extend "fallback" prompt a bit Include username/hostname if no SSH variables --- bash/bashrc.d/prompt.bash | 5 ++++- ksh/kshrc.d/prompt.ksh | 5 ++++- sh/shrc.d/prompt.sh | 6 ++++++ zsh/zshrc.d/prompt.zsh | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 2bd70c2f..f64355f7 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -81,10 +81,13 @@ prompt() { # Revert to simple inexpensive prompts off) unset -v PROMPT_COMMAND PROMPT_DIRTRIM - PS1='\$ ' + PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' + if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + PS1=$(id -nu)'@'$(hostname -s)'$ ' + fi ;; # Git prompt function diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 1dcbd864..3f526526 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -188,10 +188,13 @@ function prompt { # Revert to simple inexpensive prompts off) - PS1='\$ ' + PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' + if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + PS1=$(id -nu)'@'$(hostname -s)'$ ' + fi ;; # Abbreviated working directory diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh index a481b5bb..f1b67fb4 100644 --- a/sh/shrc.d/prompt.sh +++ b/sh/shrc.d/prompt.sh @@ -3,3 +3,9 @@ # it to break the export and then just setting them as simple variables unset PS1 PS2 PS3 PS4 PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' + +# If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the +# username and hostname in PS1 too. +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then + PS1=$(id -nu)'@'$(hostname)'$ ' +fi diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index f374dbec..446e336e 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -44,10 +44,13 @@ prompt() { # Revert to simple inexpensive prompts off) - PS1='\$ ' + PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' + if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + PS1=$(id -nu)'@'$(hostname -s)'$ ' + fi ;; # Git prompt function -- cgit v1.2.3 From 853ac278289d0a92497a5189e2cb18a2b46482c5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Jan 2017 14:02:05 +1300 Subject: s/exit/return/ in ex-subshell func --- sh/profile.d/options.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index a668a360..1a511d75 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -10,15 +10,15 @@ options() { shift # Directory already exists; bail out - [ -d "$dir" ] && exit + [ -d "$dir" ] && return # Create the directory and step into it - command -p mkdir -p -- "$dir" || exit - cd -- "$dir" || exit + command -p mkdir -p -- "$dir" || return + cd -- "$dir" || return # Write the program's --help output to a file, even if it's empty # This probably only works with GNU tools in general - "$prog" --help help 2>/dev/null || exit + "$prog" --help help 2>/dev/null || return # Iterate through remaining arguments (desired options), creating files to # show they're available if found in the help output -- cgit v1.2.3 From e8e999266652d74c8c0fb5c856c16ec10a22facd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Jan 2017 16:34:39 +1300 Subject: Add quo(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + bin/quo.sed | 3 +++ man/man1/quo.1df | 22 ++++++++++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 bin/quo.sed create mode 100644 man/man1/quo.1df diff --git a/.gitignore b/.gitignore index b0ad92d7..6e82dcd6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ bin/min bin/mode bin/nlbr bin/onl +bin/quo bin/rfct bin/rndi bin/sd2u diff --git a/Makefile b/Makefile index 504e48e4..e35d5c40 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,7 @@ BINS = bin/brnl \ bin/mode \ bin/nlbr \ bin/onl \ + bin/quo \ bin/rfct \ bin/rndi \ bin/sd2u \ diff --git a/README.markdown b/README.markdown index be0f6481..df6e6e66 100644 --- a/README.markdown +++ b/README.markdown @@ -484,6 +484,7 @@ Installed by the `install-bin` target: [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in `~/.plenv/non-cpan-modules`, and updates them all. * `pwg(1df)` generates just one decent password with `pwgen(1)`. +* `quo(1df)` quotes its input with right angle brackets. * `rgl(1df)` is a very crude interactive `grep(1)` loop. * `shb(1df)` attempts to build shebang lines for scripts from the system paths. diff --git a/bin/quo.sed b/bin/quo.sed new file mode 100644 index 00000000..1100d5ce --- /dev/null +++ b/bin/quo.sed @@ -0,0 +1,3 @@ +#!/bin/sed -f +/^[^>]/s/^/ / +s/^/>/ diff --git a/man/man1/quo.1df b/man/man1/quo.1df new file mode 100644 index 00000000..643d8ff5 --- /dev/null +++ b/man/man1/quo.1df @@ -0,0 +1,22 @@ +.TH QUO 1df "January 2017" "Manual page for quo" +.SH NAME +.B quo +\- quote the input with right-angle brackets +.SH SYNOPSIS +.B quo +.br +Text on standard input. +.br +^D +.br +.B quo +FILE1 [FILE2...] +.br +.B quo < FILE +.SH DESCRIPTION +.B quo +quotes its input by insert a right-angle bracket followed by a space at the +start of every unquoted line. If the line was already quoted, it adds another +level of right-angle bracket. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From a94e37a8a6e30d38522e2dc601b0e7b321f42720 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Jan 2017 17:37:36 +1300 Subject: Add chn(1df) --- README.markdown | 1 + bin/chn | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man1/chn.1df | 47 ++++++++++++++++++++++++++++++++++++ man/man1/maybe.1df | 2 +- man/man1/try.1df | 2 +- 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100755 bin/chn create mode 100644 man/man1/chn.1df diff --git a/README.markdown b/README.markdown index df6e6e66..2ae64927 100644 --- a/README.markdown +++ b/README.markdown @@ -426,6 +426,7 @@ Installed by the `install-bin` target: * `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as well. * `chc(1df)` caches the output of a command. +* `chn(1df)` runs a filter over its input a given number of times. * `clog(1df)` is a tiny timestamped log system. * `clrd(1df)` sets up a per-line file read, clearing the screen first. * `clwr(1df)` sets up a per-line file write, clearing the screen before each diff --git a/bin/chn b/bin/chn new file mode 100755 index 00000000..46a8a27a --- /dev/null +++ b/bin/chn @@ -0,0 +1,70 @@ +#!/bin/sh +# Repeat a command to filter input several times +self=chn + +# Check arguments. +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need a count and a program name\n' "$self" + exit 2 +fi + +# Shift off the repetition count. +c=$1 +shift + +# Check the repetition count looks sane. Zero is fine! +if [ "$c" -lt 0 ] ; then + printf >&2 '%s: Nonsensical negative count\n' "$self" + exit 2 +fi + +# If the count is zero, just run the input straight through! +if [ "$c" -eq 0 ] ; then + cat + exit +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Define and create input and output files +if=$td/if of=$td/of +touch -- "$if" "$of" + +# Iterate through the count +while [ "${n=1}" -le "$c" ] ; do + + # Start a subshell so we can deal with FDs cleanly + ( + # If this isn't the first iteration, our input comes from $if + [ "$n" -eq 1 ] || + exec <"$if" + + # If this isn't the last iteration, our output goes to $of + [ "$n" -eq "$c" ] || + exec >"$of" + + # Run the command with the descriptors above; if the command fails, the + # subshell will exit, which will in turn exit the program + "$@" + ) || exit + + # Copy the output file over the input one + cp -- "$of" "$if" + + # Increment the counter for the next while loop run + n=$((n+1)) +done diff --git a/man/man1/chn.1df b/man/man1/chn.1df new file mode 100644 index 00000000..576e5425 --- /dev/null +++ b/man/man1/chn.1df @@ -0,0 +1,47 @@ +.TH CHN 1df "January 2017" "Manual page for chn" +.SH NAME +.B chn +\- filter standard input through multiple runs of a command +.SH USAGE +.B chn +COUNT +COMMAND [ARG1...] +.SH DESCRIPTION +Run the given command the specified number of times, passing the standard +output of each run into the standard input of the next. +.P +As an example, to quote some text with quo(1df) repeatedly: +.P + $ cat msg + Hello! + $ chn 2 quo < msg + >> Hello! + $ chn 5 quo < msg + >>>> Hello! +.P +Zero is a valid count; in this case the input is passed untouched to output: +.P + $ chn 0 quo < msg + Hello! +.P +Don't confuse this with simply repeating a command. This happens to work: +.P + $ chn 5 sync +.P +But this will not do what you expect: +.P + $ chn 5 echo foo +.SH CAVEATS +It's slow. +.P +It's not a real pipe. The commands are run successively, not in parallel. That +means you can't pass one line to it and have it return another line before +sending EOF, for unbuffered (e.g. linewise) tools. +.P +There's almost certainly a better way to do this, fixing one or both of the +above issues, and possibly even in shell; maybe with curlier file descriptor +logic to save unneeded open(2) syscalls. I smell `eval` usage on the horizon. +.SH SEE ALSO +maybe(1df), try(1df) +.SH AUTHOR +Tom Ryder diff --git a/man/man1/maybe.1df b/man/man1/maybe.1df index e313eb17..3b89b09d 100644 --- a/man/man1/maybe.1df +++ b/man/man1/maybe.1df @@ -22,6 +22,6 @@ of success or failure. rndi(1df) is used for the randomness. $ maybe 3 $ maybe 2 5 .SH SEE ALSO -true(1), false(1), try(1df), rndi(1df) +true(1), false(1), chn(1df), try(1df), rndi(1df) .SH AUTHOR Tom Ryder diff --git a/man/man1/try.1df b/man/man1/try.1df index d982c1d3..63db5209 100644 --- a/man/man1/try.1df +++ b/man/man1/try.1df @@ -17,6 +17,6 @@ run. $ try maybe $ try -n5 -s10 gms .SH SEE ALSO -maybe(1df) +maybe(1df), chn(1df) .SH AUTHOR Tom Ryder -- cgit v1.2.3 From a689fa37dd01d87a98e9c79f1581b27fd14d598e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 15:31:57 +1300 Subject: More generic Mutt configuration Remove some person and system specific stuff, including my signature; nothing complex about that, after all. --- .gitignore | 1 - Makefile | 34 ++-------- mail/mailrc.m4 | 3 - mutt/muttrc | 134 ++++++++++++++++++++++++++++++++++++ mutt/muttrc.d/src | 6 ++ mutt/muttrc.m4 | 153 ------------------------------------------ mutt/signature | 2 - vim/after/ftdetect/muttrc.vim | 12 ++++ 8 files changed, 156 insertions(+), 189 deletions(-) delete mode 100644 mail/mailrc.m4 create mode 100644 mutt/muttrc create mode 100755 mutt/muttrc.d/src delete mode 100644 mutt/muttrc.m4 delete mode 100644 mutt/signature create mode 100644 vim/after/ftdetect/muttrc.vim diff --git a/.gitignore b/.gitignore index 6e82dcd6..22e40356 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,5 @@ git/gitconfig gnupg/gpg.conf mail/mailrc man/man7/dotfiles.7df -mutt/muttrc tmux/tmux.conf urxvt/ext/select diff --git a/Makefile b/Makefile index e35d5c40..ae1655fa 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,6 @@ install-gtk \ install-i3 \ install-less \ - install-mail \ - install-maildir \ install-mutt \ install-ncmcpp \ install-newsbeuter \ @@ -113,9 +111,7 @@ clean distclean : $(GAMES) \ git/gitconfig \ gnupg/gpg.conf \ - mail/mailrc \ - man/man7/dotfiles.7df \ - mutt/muttrc \ + man/man8/dotfiles.7df \ tmux/tmux.conf \ urxvt/ext/select @@ -135,22 +131,12 @@ gnupg/gpg.conf : gnupg/gpg.conf.m4 -D DOTFILES_KEYSERVER="$(KEYSERVER)" \ gnupg/gpg.conf.m4 > gnupg/gpg.conf -mail/mailrc : mail/mailrc.m4 - m4 -D DOTFILES_SENDMAIL="$$(command -v "$(SENDMAIL)")" \ - mail/mailrc.m4 > "$@" - man/man7/dotfiles.7df : README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o "$@" MAILDIR := $(HOME)/Mail -mutt/muttrc : mutt/muttrc.m4 - m4 \ - -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ - -D DOTFILES_MAILDIR="$(MAILDIR)" \ - mutt/muttrc.m4 > mutt/muttrc - TMUX_BG := colour237 TMUX_FG := colour248 @@ -270,24 +256,12 @@ install-less : install -pm 0644 -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey -install-mail : mail/mailrc - install -pm 0644 -- mail/mailrc "$(HOME)"/.mailrc - -install-maildir : - for box in drafts inbox sent ; do \ - for dir in cur new tmp ; do \ - install -m 0755 -d -- \ - "$(MAILDIR)"/"$$box"/"$$dir" ; \ - done ; \ - done - -install-mutt : mutt/muttrc install-mail install-maildir +install-mutt : install -m 0755 -d -- \ - "$(HOME)"/.mutt \ + "$(HOME)"/.muttrc.d \ "$(HOME)"/.cache/mutt install -pm 0644 -- mutt/muttrc "$(HOME)"/.muttrc - install -pm 0644 -- mutt/signature "$(HOME)"/.signature - [ -f "$(HOME)"/.mutt/muttrc.local ] || touch "$(HOME)"/.mutt/muttrc.local + install -pm 0755 -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d install-ncmcpp : install -m 0755 -d -- "$(HOME)"/.ncmpcpp diff --git a/mail/mailrc.m4 b/mail/mailrc.m4 deleted file mode 100644 index 873fe080..00000000 --- a/mail/mailrc.m4 +++ /dev/null @@ -1,3 +0,0 @@ -set sendmail=DOTFILES_SENDMAIL -unset askcc -set nosave skipempty diff --git a/mutt/muttrc b/mutt/muttrc new file mode 100644 index 00000000..7f40e617 --- /dev/null +++ b/mutt/muttrc @@ -0,0 +1,134 @@ +# Addresses +set query_command = 'abook --mutt-query %s' +set reverse_name = yes +set use_domain = yes +set use_from = yes + +# Alerts +set beep_new = yes + +# Attachments +attachments +A */.* +attachments -A text/x-vcard application/pgp.* +attachments -A application/x-pkcs7-.* +attachments +I text/plain +attachments -A message/external-body +attachments -I message/external-body + +# Caching +set header_cache = '~/.cache/mutt/headers' + +# Colors +color attachment brightyellow default +color hdrdefault cyan default +color indicator black white +color markers brightred default +color normal default default +color quoted green default +color signature cyan default +color status default color22 +color tilde brightblack default +color tree default default + +# Completion +bind editor complete-query +bind editor ^T complete + +# Files +set delete = yes +set move = no + +# Flags +set mark_old = no + +# Headers +ignore * +unignore Date From: To Cc Subject +hdr_order Date From: To Cc Subject +set edit_headers = yes + +# Index +set index_format = '%4C %Z %{%b %d %Y} %-15.15L (%?l?%4l&%4c?) %s' + +# Interaction +set abort_unmodified = no +set confirmappend = no +set wait_key = no +set quit = ask-yes + +# Intervals +set mail_check = 5 +set sleep_time = 0 + +# Mailboxes +set confirmcreate = yes + +# Menus +set menu_context = 1 + +# MIME +mime_lookup application/octet-stream + +# Pager +set pager_context = 1 +set pager_format = '%4C %Z %[!%b %e at %I:%M %p] %.20n %s%* -- (%P)' +set pager_stop = yes + +# Presentation/formatting +set markers = no +set smart_wrap = yes +set text_flowed = yes +set tilde = yes +alternative_order text/plain text/html * +auto_view text/html + +# Quoting +set quote_regexp = '^(>[ \t]*)+' + +# Responses +set fast_reply = yes +set forward_format = 'Fw: %s' +set include = yes +set use_envelope_from = yes + +# Searching/sorting +set sort = 'threads' +set sort_aux = 'last-date-received' +set strict_threads = yes +set thorough_search = yes + +# SSH +set time_inc = 250 + +# Encryption settings +set crypt_replysign = yes +set crypt_replyencrypt = yes +set crypt_replysignencrypted = yes +set crypt_use_gpgme = yes +set crypt_use_pka = yes +set crypt_verify_sig = yes + +# Vim-ish bindings +bind index gg first-entry +bind index G last-entry +bind pager gg top +bind pager G bottom +bind index,pager \Cu half-up +bind index,pager \Cd half-down +bind generic,index,browser,pager \Cf next-page +bind generic,index,browser,pager \Cb previous-page + +# Turn off annoying mailbox lock feature +bind index '%' noop + +# Blindly save message to whatever box is suggested +macro index,pager S 's' 'Save message blindly' + +# Run gms to retrieve all mail +macro generic,index,browser,pager gm '!gms --quiet &' 'Run gms(1df)' + +# Shortcut to add addresses to abook +macro index,pager A 'abook --add-email' 'Add sender address to abook' + +# Machine or account specific settings +source ~/.muttrc.d/src| diff --git a/mutt/muttrc.d/src b/mutt/muttrc.d/src new file mode 100755 index 00000000..584a2785 --- /dev/null +++ b/mutt/muttrc.d/src @@ -0,0 +1,6 @@ +#!/bin/sh +# Helper script to emit the source all muttrc subfiles, in LC_COLLATE order +for rc in "$HOME"/.muttrc.d/*.rc ; do + [ -e "$rc" ] || continue + cat -- "$rc" +done diff --git a/mutt/muttrc.m4 b/mutt/muttrc.m4 deleted file mode 100644 index 4709adef..00000000 --- a/mutt/muttrc.m4 +++ /dev/null @@ -1,153 +0,0 @@ -# Names -set use_domain = yes -set use_from = yes -set reverse_name = yes - -# SMTP implementation -set sendmail = 'DOTFILES_SENDMAIL' - -# Mailbox type and location -set mbox_type = 'Maildir' -set folder = 'DOTFILES_MAILDIR' - -# Submailboxes -set spoolfile = '+inbox' -set postponed = '+drafts' -set record = '+sent' -mailboxes ! - -# Addresses -set query_command = 'abook --mutt-query %s' - -# Alerts -set beep_new = yes - -# Attachments -attachments +A */.* -attachments -A text/x-vcard application/pgp.* -attachments -A application/x-pkcs7-.* -attachments +I text/plain -attachments -A message/external-body -attachments -I message/external-body - -# Caching -set header_cache = '~/.cache/mutt/headers' - -# Colors -color attachment brightyellow default -color hdrdefault cyan default -color indicator black white -color markers brightred default -color normal default default -color quoted green default -color signature cyan default -color status default color22 -color tilde brightblack default -color tree default default - -# Completion -bind editor complete-query -bind editor ^T complete - -# Files -set delete = yes -set move = no - -# Flags -set mark_old = no - -# Headers -ignore * -unignore Date From: To Cc Subject -hdr_order Date From: To Cc Subject -set edit_headers = yes - -# Index -set index_format = '%4C %Z %{%b %d %Y} %-15.15L (%?l?%4l&%4c?) %s' - -# Interaction -set abort_unmodified = no -set confirmappend = no -set wait_key = no -set quit = ask-yes - -# Intervals -set mail_check = 5 -set sleep_time = 0 - -# Mailboxes -set confirmcreate = yes - -# Menus -set menu_context = 1 - -# MIME -mime_lookup application/octet-stream - -# Pager -set pager_context = 1 -set pager_format = '%4C %Z %[!%b %e at %I:%M %p] %.20n %s%* -- (%P)' -set pager_stop = yes - -# Presentation/formatting -set markers = no -set smart_wrap = yes -set text_flowed = yes -set tilde = yes -alternative_order text/plain text/html * -auto_view text/html - -# Quoting -set quote_regexp = '^(>[ \t]*)+' - -# Responses -set fast_reply = yes -set forward_format = 'Fw: %s' -set include = yes -set use_envelope_from = yes - -# Searching/sorting -set sort = 'threads' -set sort_aux = 'last-date-received' -set strict_threads = yes -set thorough_search = yes - -# SSH -set time_inc=250 - -# Encryption settings -set crypt_replysign = yes -set crypt_replyencrypt = yes -set crypt_replysignencrypted = yes -set crypt_use_gpgme = yes -set crypt_use_pka = yes -set crypt_verify_sig = yes - -# Vim-ish bindings -bind index gg first-entry -bind index G last-entry -bind pager gg top -bind pager G bottom -bind index,pager \Cu half-up -bind index,pager \Cd half-down -bind generic,index,browser,pager \Cf next-page -bind generic,index,browser,pager \Cb previous-page - -# Turn off annoying mailbox lock feature -bind index '%' noop - -# Jump to mailboxes -macro generic,index,browser,pager gi '=inbox' 'Change to inbox folder' -macro generic,index,browser,pager gs '=sent' 'Change to sent folder' - -# Blindly save message to whatever box is suggested -macro index,pager S 's' 'Save message blindly' - -# Run gms to retrieve all mail -macro generic,index,browser,pager gm '!gms --quiet &' 'Run gms' - -# Shortcut to add addresses to abook -macro index,pager A 'abook --add-email' 'Add sender address to abook' - -# Machine or account specific settings -source ~/.mutt/muttrc.local diff --git a/mutt/signature b/mutt/signature deleted file mode 100644 index a229b5f5..00000000 --- a/mutt/signature +++ /dev/null @@ -1,2 +0,0 @@ -Tom Ryder -The next 1<<10 years are ours. diff --git a/vim/after/ftdetect/muttrc.vim b/vim/after/ftdetect/muttrc.vim new file mode 100644 index 00000000..ff3776b5 --- /dev/null +++ b/vim/after/ftdetect/muttrc.vim @@ -0,0 +1,12 @@ +" Add automatic commands to detect .muttrc files +augroup dfmuttrc + + autocmd BufNewFile,BufRead + \ **/.dotfiles/mutt/muttrc.d/*.rc + \ setlocal filetype=muttrc + + autocmd BufNewFile,BufRead + \ **/.muttrc.d/*.rc + \ setlocal filetype=muttrc + +augroup END -- cgit v1.2.3 From 19fe50f521bae5d699604ec9d7f4ecdf17a41f4c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 17:18:01 +1300 Subject: Correct a typeset call --- ksh/kshrc.d/prompt.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 3f526526..1d4db926 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -80,7 +80,7 @@ function prompt { } >/dev/null 2>&1 # Play ball with ksh's way of escaping non-printing characters - typeset es nl + typeset es cr es=$(printf '\01') cr=$(printf '\r') -- cgit v1.2.3 From 891e547055c48523ab89e2297eb23636c1aed931 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 20:51:23 +1300 Subject: Start using Bash host completion But use ~/.hosts if it's there --- bash/bashrc | 4 ++-- bash/bashrc.d/completion.bash | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bash/bashrc b/bash/bashrc index ca13c4bf..16669adf 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -57,8 +57,8 @@ shopt -s histappend shopt -s histreedit # Repeat the expanded line on successful history expansion shopt -s histverify -# Don't use Bash's builtin host completion -shopt -u hostcomplete +# Use Bash's builtin host completion +shopt -s hostcomplete # Don't change newlines to semicolons in history shopt -s lithist # Don't warn me about new mail all the time diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index 0d8dbb13..c77f8844 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -6,6 +6,10 @@ # character: (E13) [[ -n $COMP_WORDBREAKS ]] && COMP_WORDBREAKS=${COMP_WORDBREAKS//:} +# If ~/.hosts exists, use that as the host completion file rather than +# /etc/hosts, so I can populate the list myself +[[ -f $HOME/.hosts ]] && HOSTFILE=$HOME/.hosts + # Aliases complete -A alias unalias -- cgit v1.2.3 From 62cf0d463e9171712ff3e4dcc18293adf50a1a94 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 20:56:52 +1300 Subject: Add host completion for some common tools --- bash/bash_completion.d/dig.bash | 2 ++ bash/bash_completion.d/host.bash | 2 ++ bash/bash_completion.d/netcat.bash | 2 ++ bash/bash_completion.d/ping.bash | 2 ++ bash/bash_completion.d/telnet.bash | 2 ++ 5 files changed, 10 insertions(+) create mode 100644 bash/bash_completion.d/dig.bash create mode 100644 bash/bash_completion.d/host.bash create mode 100644 bash/bash_completion.d/netcat.bash create mode 100644 bash/bash_completion.d/ping.bash create mode 100644 bash/bash_completion.d/telnet.bash diff --git a/bash/bash_completion.d/dig.bash b/bash/bash_completion.d/dig.bash new file mode 100644 index 00000000..bdbd1cd8 --- /dev/null +++ b/bash/bash_completion.d/dig.bash @@ -0,0 +1,2 @@ +# Complete dig(1) with hostnames +complete -A hostname dig diff --git a/bash/bash_completion.d/host.bash b/bash/bash_completion.d/host.bash new file mode 100644 index 00000000..e49e76c4 --- /dev/null +++ b/bash/bash_completion.d/host.bash @@ -0,0 +1,2 @@ +# Complete host(1) with hostnames +complete -A hostname host diff --git a/bash/bash_completion.d/netcat.bash b/bash/bash_completion.d/netcat.bash new file mode 100644 index 00000000..be4e885f --- /dev/null +++ b/bash/bash_completion.d/netcat.bash @@ -0,0 +1,2 @@ +# Complete nc(1) with hostnames +complete -A hostname netcat nc diff --git a/bash/bash_completion.d/ping.bash b/bash/bash_completion.d/ping.bash new file mode 100644 index 00000000..8dc27673 --- /dev/null +++ b/bash/bash_completion.d/ping.bash @@ -0,0 +1,2 @@ +# Complete ping(8) with hostnames +complete -A hostname ping diff --git a/bash/bash_completion.d/telnet.bash b/bash/bash_completion.d/telnet.bash new file mode 100644 index 00000000..eacf552d --- /dev/null +++ b/bash/bash_completion.d/telnet.bash @@ -0,0 +1,2 @@ +# Complete telnet(1) with hostnames +complete -A hostname telnet -- cgit v1.2.3 From 4c03a1886a55bcb75cc7700ffa665593ab3f766d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 21:34:45 +1300 Subject: Remove resolved issue This was fixed in 1e22f51 --- ISSUES.markdown | 3 --- 1 file changed, 3 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index c29fc284..383d7906 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,6 +18,3 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file -* I'm still not sure that the special character escaping for the ksh prompt - actually works. The line-wrapping behaviour for ksh93 seems to be a bit - weird. This requires debugging. -- cgit v1.2.3 From 66e73957af8561198dc6fc25ea739c1ce9128824 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 21:38:52 +1300 Subject: Fix nc(1) completions, add nmap(1) completions --- bash/bash_completion.d/nc.bash | 2 ++ bash/bash_completion.d/netcat.bash | 4 ++-- bash/bash_completion.d/nmap.bash | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 bash/bash_completion.d/nc.bash create mode 100644 bash/bash_completion.d/nmap.bash diff --git a/bash/bash_completion.d/nc.bash b/bash/bash_completion.d/nc.bash new file mode 100644 index 00000000..8ef1fe69 --- /dev/null +++ b/bash/bash_completion.d/nc.bash @@ -0,0 +1,2 @@ +# Complete nc(1) with hostnames +complete -A hostname nc diff --git a/bash/bash_completion.d/netcat.bash b/bash/bash_completion.d/netcat.bash index be4e885f..60b9d614 100644 --- a/bash/bash_completion.d/netcat.bash +++ b/bash/bash_completion.d/netcat.bash @@ -1,2 +1,2 @@ -# Complete nc(1) with hostnames -complete -A hostname netcat nc +# Complete netcat(1) with hostnames +complete -A hostname netcat diff --git a/bash/bash_completion.d/nmap.bash b/bash/bash_completion.d/nmap.bash new file mode 100644 index 00000000..7126ca68 --- /dev/null +++ b/bash/bash_completion.d/nmap.bash @@ -0,0 +1,2 @@ +# Complete nmap(1) with hostnames +complete -A hostname nmap -- cgit v1.2.3 From 1e4e9f9e7d24f58991766044aa26abd6749b4c9f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 22:22:08 +1300 Subject: Add openssl(1ssl) completion --- bash/bash_completion.d/openssl.bash | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 bash/bash_completion.d/openssl.bash diff --git a/bash/bash_completion.d/openssl.bash b/bash/bash_completion.d/openssl.bash new file mode 100644 index 00000000..b2bc1b7d --- /dev/null +++ b/bash/bash_completion.d/openssl.bash @@ -0,0 +1,32 @@ +# Some simple completion for openssl(1ssl) +_openssl() { + + # Only complete the first word: OpenSSL subcommands + case $COMP_CWORD in + 1) + while read -r subcmd ; do + case $subcmd in + '') ;; + "${COMP_WORDS[COMP_CWORD]}"*) + COMPREPLY[${#COMPREPLY[@]}]=$subcmd + ;; + esac + done < <( + for arg in \ + list-cipher-commands \ + list-standard-commands \ + list-message-digest-commands ; do + printf '%s\n' "$arg" + openssl "$arg" + done + ) + ;; + esac +} + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _openssl -o bashdefault -o default openssl +else + complete -F _openssl -o default openssl +fi -- cgit v1.2.3 From 8cd2f6c671416541a9f7c3c7508450d9beb57f33 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 22:22:29 +1300 Subject: Use FUNCNAME for self-refs in Git completion --- bash/bash_completion.d/git.bash | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bash/bash_completion.d/git.bash b/bash/bash_completion.d/git.bash index bde515ee..5cf42ed3 100644 --- a/bash/bash_completion.d/git.bash +++ b/bash/bash_completion.d/git.bash @@ -109,8 +109,8 @@ _git() { # Complete initial subcommand or alias if ((sci == COMP_CWORD)) ; then - _git subcommands - _git aliases + "${FUNCNAME[0]}" subcommands + "${FUNCNAME[0]}" aliases return fi @@ -119,13 +119,13 @@ _git() { # Complete with untracked, unignored files add) - _git untracked_files + "${FUNCNAME[0]}" untracked_files return ;; # Help on real subcommands (not aliases) help) - _git subcommands + "${FUNCNAME[0]}" subcommands return ;; @@ -149,7 +149,7 @@ _git() { update ' -- "${COMP_WORDS[COMP_CWORD]}") else - _git remotes + "${FUNCNAME[0]}" remotes fi return ;; @@ -199,15 +199,15 @@ _git() { # Complete with remotes and then refs fetch|pull|push) if ((COMP_CWORD == 2)) ; then - _git remotes + "${FUNCNAME[0]}" remotes else - _git refs + "${FUNCNAME[0]}" refs fi ;; # Commands for which I'm likely to want a ref branch|checkout|merge|rebase|tag) - _git refs + "${FUNCNAME[0]}" refs ;; # I normally only want a refspec for "reset" if I'm using the --hard or @@ -215,7 +215,7 @@ _git() { reset) case ${COMP_WORDS[COMP_CWORD-1]} in --hard|--soft) - _git refs + "${FUNCNAME[0]}" refs ;; esac ;; -- cgit v1.2.3 From 2257085f3da0b6873c3099c2ab738b381c23b8de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Jan 2017 22:30:39 +1300 Subject: Add completion for finger(1) --- bash/bash_completion.d/finger.bash | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 bash/bash_completion.d/finger.bash diff --git a/bash/bash_completion.d/finger.bash b/bash/bash_completion.d/finger.bash new file mode 100644 index 00000000..5594adde --- /dev/null +++ b/bash/bash_completion.d/finger.bash @@ -0,0 +1,2 @@ +# Completion for finger(1) +complete -A user finger -- cgit v1.2.3 From 17293f7b182715a082ec7a2611a0390bcec109be Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Jan 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index c12d4ea9..f8b2d4bd 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit c12d4ea9e5032c9e5b88e2115a80b8772d15d0df +Subproject commit f8b2d4bd21ea73ebe8eaa3e9f9bdc1b42d1b7b4c -- cgit v1.2.3 From e71835f092d969f3eb368b2d55b0f96be89402f2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 2 Feb 2017 00:18:32 +1300 Subject: Tidy descriptions for grep()/ls() --- README.markdown | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 2ae64927..a76a0641 100644 --- a/README.markdown +++ b/README.markdown @@ -189,11 +189,12 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: just for convenience when running it interactively. * `gdb()` silences startup messages from `gdb(1)`. * `gpg()` quietens `gpg(1)` down for most commands. -* `grep()` tries to apply color and other options good for interactive use, - depending on the capabilities of the system `grep(1)`. +* `grep()` tries to apply color and other options good for interactive use if + available. * `hgrep()` allows searching `$HISTFILE`. * `keychain()` keeps `$GPG_TTY` up to date if a GnuPG agent is available. -* `ls()` tries to apply color to `ls(1)` for interactive use if available. +* `ls()` tries to apply color and other options good for interactive use if + available. * `la()` runs `ls -A` if it can, or `ls -a` otherwise. * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. * `mysql()` allows shortcuts to MySQL configuration files stored in -- cgit v1.2.3 From e72cd0537b1e76b3fe9fb840a91c8e5b1ce9a22c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 2 Feb 2017 17:28:26 +1300 Subject: Add an idea --- IDEAS.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 25b79516..a3a70a72 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -9,3 +9,4 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * edio(1df), like vipe(1) +* Detect appropriate shell family to install in Makefile -- cgit v1.2.3 From d8c69a9ef5b6d89f9a902d249e869de634dd536c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Feb 2017 00:39:03 +1300 Subject: Add an idea --- IDEAS.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index a3a70a72..9a3e4686 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -10,3 +10,4 @@ Ideas * Convert all the manual pages to mandoc maybe? * edio(1df), like vipe(1) * Detect appropriate shell family to install in Makefile +* qmp(1df)--quick man page -- cgit v1.2.3 From 529c2e15c7eec527f6ad85db4409afdd98a9a67e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Feb 2017 09:42:16 +1300 Subject: Fix up quo(1df) man page formatting --- man/man1/quo.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/quo.1df b/man/man1/quo.1df index 643d8ff5..d2fd268d 100644 --- a/man/man1/quo.1df +++ b/man/man1/quo.1df @@ -12,7 +12,8 @@ Text on standard input. .B quo FILE1 [FILE2...] .br -.B quo < FILE +.B quo +< FILE .SH DESCRIPTION .B quo quotes its input by insert a right-angle bracket followed by a space at the -- cgit v1.2.3 From dec0e35c4228924ff4802cb1978ae1c500aa1b30 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Feb 2017 13:04:34 +1300 Subject: Add an idea about ad() --- IDEAS.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 9a3e4686..664181ee 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -11,3 +11,6 @@ Ideas * edio(1df), like vipe(1) * Detect appropriate shell family to install in Makefile * qmp(1df)--quick man page +* ad() could be more intelligent; if there's only one directory that matches + the *whole pattern*, we can assume it's safe to use that one, rather than + stopping each time any node has more than one match -- cgit v1.2.3 From 7d7fcde6edff965cb132dc811df5b19e07a67d64 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Feb 2017 14:16:15 +1300 Subject: Add an idea --- IDEAS.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 664181ee..f9071fc4 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -14,3 +14,7 @@ Ideas * ad() could be more intelligent; if there's only one directory that matches the *whole pattern*, we can assume it's safe to use that one, rather than stopping each time any node has more than one match +* It seems likely that testing the terminal with tput to check if we can use + --color with GNU grep(1) or ls(1) is overkill--I suspect it probably tests + that internally, which would simplify the function wrappers. Need to check + the source probably. -- cgit v1.2.3 From 1ccea6184566a6fe3f8a247f2bcd060e64b89694 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Feb 2017 14:30:48 +1300 Subject: Remove idea about --color switches Nope, we really do need to test the terminal. The source for GNU grep(1) even says (grep.c): >It would be impractical for GNU grep to become a full-fledged terminal >program linked against ncurses or the like, so it will not detect >terminfo(5) capabilities. --- IDEAS.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index f9071fc4..664181ee 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -14,7 +14,3 @@ Ideas * ad() could be more intelligent; if there's only one directory that matches the *whole pattern*, we can assume it's safe to use that one, rather than stopping each time any node has more than one match -* It seems likely that testing the terminal with tput to check if we can use - --color with GNU grep(1) or ls(1) is overkill--I suspect it probably tests - that internally, which would simplify the function wrappers. Need to check - the source probably. -- cgit v1.2.3 From 5d8f421231404ec6598bfd5c4b1b4223c8ac7f35 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Feb 2017 20:46:23 +1300 Subject: Remove double-shebang header shb(1) doubles this up when it makes an executable version of the script --- bin/quo.sed | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/quo.sed b/bin/quo.sed index 1100d5ce..26250e9e 100644 --- a/bin/quo.sed +++ b/bin/quo.sed @@ -1,3 +1,2 @@ -#!/bin/sed -f /^[^>]/s/^/ / s/^/>/ -- cgit v1.2.3 From 797e8673ed6a3eec7db0294e30f84759629e49c8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Feb 2017 20:53:32 +1300 Subject: Add wro(1df) --- README.markdown | 4 +++- bin/wro | 31 +++++++++++++++++++++++++++++++ man/man1/quo.1df | 2 ++ man/man1/wro.1df | 20 ++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 bin/wro create mode 100644 man/man1/wro.1df diff --git a/README.markdown b/README.markdown index a76a0641..7c469f0a 100644 --- a/README.markdown +++ b/README.markdown @@ -410,6 +410,9 @@ Installed by the `install-bin` target: * `htenc(1df)` encodes. * `htdec(1df)` decodes. * `htrec(1df)` wraps `a` tags around URLs. +* Two internet message quoting tools: + * `quo(1df)` indents with quoting right angle-brackets. + * `wro(1df)` adds a quote attribution header to its input. * `ap(1df)` reads arguments for a given command from the standard input, prompting if appropriate. * `apf(1df)` prepends arguments to a command with ones read from a file, @@ -486,7 +489,6 @@ Installed by the `install-bin` target: [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in `~/.plenv/non-cpan-modules`, and updates them all. * `pwg(1df)` generates just one decent password with `pwgen(1)`. -* `quo(1df)` quotes its input with right angle brackets. * `rgl(1df)` is a very crude interactive `grep(1)` loop. * `shb(1df)` attempts to build shebang lines for scripts from the system paths. diff --git a/bin/wro b/bin/wro new file mode 100755 index 00000000..82bb4415 --- /dev/null +++ b/bin/wro @@ -0,0 +1,31 @@ +#!/bin/sh +# Add an email-style quote header to input +self=wro + +# Check arguments +if [ "$#" -gt 2 ] ; then + printf >&2 '%s: Too many arguments\n' "$self" + exit 2 +fi + +# Check first argument for the person to quote; if blank, try to form a +# reasonable-looking name from the system +if [ -n "$1" ] ; then + from=$1 +else + un=$(id -n) + if [ -f /etc/mailname ] ; then + read -r hn < /etc/mailname + else + hn=$(uname -n) + fi + from="$un"@"$hn" +fi + +# Check second argument for the date; if blank, get the system date in whatever +# format it cares to give us +date=${2:-"$(date)"} + +# Print the header and then the input +printf 'On %s, %s wrote:\n' "$date" "$from" +cat diff --git a/man/man1/quo.1df b/man/man1/quo.1df index d2fd268d..0b651388 100644 --- a/man/man1/quo.1df +++ b/man/man1/quo.1df @@ -19,5 +19,7 @@ FILE1 [FILE2...] quotes its input by insert a right-angle bracket followed by a space at the start of every unquoted line. If the line was already quoted, it adds another level of right-angle bracket. +.SH SEE ALSO +wro(1df) .SH AUTHOR Tom Ryder diff --git a/man/man1/wro.1df b/man/man1/wro.1df new file mode 100644 index 00000000..350ca448 --- /dev/null +++ b/man/man1/wro.1df @@ -0,0 +1,20 @@ +.TH WRO 1df "January 2017" "Manual page for wro" +.SH NAME +.B wro +\- add a quote header to the standard input +.SH SYNOPSIS +.B wro +luser@example.com +.br +.B wro +luser@example.com '2017-01-15 9:00am' +Text on standard input. +^D +.SH DESCRIPTION +.B wro +adds an email-style quote lead-in to its standard input. It's intended to +receive input from quo(1df). +.SH SEE ALSO +quo(1df) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From f3553d4f03fd2f792d65e98877846e4f8e81f4a1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 00:37:19 +1300 Subject: Use abook --add-email-quiet --- mutt/muttrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mutt/muttrc b/mutt/muttrc index 7f40e617..3a38a7cf 100644 --- a/mutt/muttrc +++ b/mutt/muttrc @@ -128,7 +128,7 @@ macro index,pager S 's' 'Save message blindly' macro generic,index,browser,pager gm '!gms --quiet &' 'Run gms(1df)' # Shortcut to add addresses to abook -macro index,pager A 'abook --add-email' 'Add sender address to abook' +macro index,pager A 'abook --add-email-quiet' 'Add sender address to abook' # Machine or account specific settings source ~/.muttrc.d/src| -- cgit v1.2.3 From d09dac1a21c536544a726e7f386b35e156b9d762 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 01:33:51 +1300 Subject: Correct missing id(1) option --- bin/wro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/wro b/bin/wro index 82bb4415..4c465adb 100755 --- a/bin/wro +++ b/bin/wro @@ -13,7 +13,7 @@ fi if [ -n "$1" ] ; then from=$1 else - un=$(id -n) + un=$(id -nu) if [ -f /etc/mailname ] ; then read -r hn < /etc/mailname else -- cgit v1.2.3 From 309c62e84ae321729c633ffbba8fa2ae8b82ab57 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 01:51:26 +1300 Subject: Group some tools in the README --- README.markdown | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 7c469f0a..f2ef003e 100644 --- a/README.markdown +++ b/README.markdown @@ -413,6 +413,17 @@ Installed by the `install-bin` target: * Two internet message quoting tools: * `quo(1df)` indents with quoting right angle-brackets. * `wro(1df)` adds a quote attribution header to its input. +* Six Git-related tools: + * `fgscr(1df)` finds Git repositories in a directory root and scrubs them + with `gscr(1df)`. + * `grc(1df)` quietly tests whether the given directory appears to be a + Git repository with pending changes. + * `gscr(1df)` scrubs Git repositories. + * `isgr(1df)` quietly tests whether the given directory appears to be a + Git repository. + * `jfc(1df)` adds and commits lazily to a Git repository. + * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it + sees any. * `ap(1df)` reads arguments for a given command from the standard input, prompting if appropriate. * `apf(1df)` prepends arguments to a command with ones read from a file, @@ -445,8 +456,6 @@ Installed by the `install-bin` target: any options, mostly useful for scripts. * `eds(1df)` edits executable script files in `EDSPATH`, defaulting to `~/.local/bin`, for personal scripting snippets. -* `fgscr(1df)` finds Git repositories in a directory root and scrubs them - with `gscr(1df)`. * `finc(1df)` counts the number of results returned from a set of given `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary @@ -454,21 +463,13 @@ Installed by the `install-bin` target: * `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the script `getmails` in the `getmail` suite, but runs the requests in parallel and does up to three silent retries using `try(1df)`. -* `grc(1df)` quietly tests whether the given directory appears to be a Git - repository with pending changes. -* `gscr(1df)` scrubs Git repositories. * `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. * `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will look for `help` topics. You could use it from the shell too. * `igex(1df)` wraps around a command to allow you to ignore error conditions that don't actually worry you, exiting with 0 anyway. -* `isgr(1df)` quietly tests whether the given directory appears to be a Git - repository. * `ix(1df)` posts its input to the ix.io pastebin. -* `jfc(1df)` adds and commits lazily to a Git repository. * `jfp(1df)` prints its input, excluding any shebang on the first line only. -* `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it sees - any. * `loc(1df)` is a quick-search wrapped around `find(1)`. * `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of success, -- cgit v1.2.3 From 9dd4f47d8affe588bd8569d16bcb6078613ecb1a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 01:54:56 +1300 Subject: Add an idea --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 664181ee..d787947d 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -14,3 +14,5 @@ Ideas * ad() could be more intelligent; if there's only one directory that matches the *whole pattern*, we can assume it's safe to use that one, rather than stopping each time any node has more than one match +* The solution to chn(1df) not running in parallel is probably backgrounded + processes and mkfifo(1). -- cgit v1.2.3 From 4173f56fc5740a612a18ef9fdab79761e1dc0d80 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 01:56:14 +1300 Subject: Fix misplaced line from sec(1df) manual --- man/man1/sec.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/sec.1df b/man/man1/sec.1df index 589b6a74..dc95e52c 100644 --- a/man/man1/sec.1df +++ b/man/man1/sec.1df @@ -10,9 +10,9 @@ FILE1 [FILE2 ...] < FILE .br printf '1:02:54\\n' | +.B sec .br sec=$(printf '%s\n' "$timestamp" | sec) -.B sec .SH DESCRIPTION Applies awk(1) to convert hh:mm:ss or mm:ss timestamps into a count of seconds. Exits zero if all lines were successfully recognised and converted, non-zero -- cgit v1.2.3 From f9f4a04e8528b09b4a5a581acbc33b977f6578b3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 01:58:54 +1300 Subject: Escape literal backslash in sec(1df) manual --- man/man1/sec.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/sec.1df b/man/man1/sec.1df index dc95e52c..aad09ddd 100644 --- a/man/man1/sec.1df +++ b/man/man1/sec.1df @@ -12,7 +12,7 @@ FILE1 [FILE2 ...] printf '1:02:54\\n' | .B sec .br -sec=$(printf '%s\n' "$timestamp" | sec) +sec=$(printf '%s\\n' "$timestamp" | sec) .SH DESCRIPTION Applies awk(1) to convert hh:mm:ss or mm:ss timestamps into a count of seconds. Exits zero if all lines were successfully recognised and converted, non-zero -- cgit v1.2.3 From b9b5a431422c4213fe555e284fcfaa96cd692267 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Feb 2017 02:17:12 +1300 Subject: Add hms(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 4 +++- bin/hms.awk | 31 +++++++++++++++++++++++++++++++ man/man1/hms.1df | 23 +++++++++++++++++++++++ man/man1/sec.1df | 2 ++ 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 bin/hms.awk create mode 100644 man/man1/hms.1df diff --git a/.gitignore b/.gitignore index 22e40356..8ccf6b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bin/ddup bin/gwp bin/jfp bin/han +bin/hms bin/htdec bin/htenc bin/htref diff --git a/Makefile b/Makefile index ae1655fa..6a63dbb7 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,7 @@ BINS = bin/brnl \ bin/ddup \ bin/gwp \ bin/han \ + bin/hms \ bin/htdec \ bin/htenc \ bin/htref \ diff --git a/README.markdown b/README.markdown index f2ef003e..586594a4 100644 --- a/README.markdown +++ b/README.markdown @@ -424,6 +424,9 @@ Installed by the `install-bin` target: * `jfc(1df)` adds and commits lazily to a Git repository. * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it sees any. +* Two time duration functions: + * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. + * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. * `ap(1df)` reads arguments for a given command from the standard input, prompting if appropriate. * `apf(1df)` prepends arguments to a command with ones read from a file, @@ -493,7 +496,6 @@ Installed by the `install-bin` target: * `rgl(1df)` is a very crude interactive `grep(1)` loop. * `shb(1df)` attempts to build shebang lines for scripts from the system paths. -* `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. * `sqs(1df)` chops off query strings from filenames, usually downloads. * `sshi(1df)` prints human-readable SSH connection details. * `stex(1df)` strips extensions from filenames. diff --git a/bin/hms.awk b/bin/hms.awk new file mode 100644 index 00000000..3a9a1499 --- /dev/null +++ b/bin/hms.awk @@ -0,0 +1,31 @@ +BEGIN { + OFS = ":" +} + +# Refuse to deal with anything that's not a positive (unsigned) integer +/[^0-9]/ { + print "hms: Bad number" | "cat >&2" + err = 1 + next +} + +# Integer looks valid +{ + # Break it down into hours, minutes, and seconds + s = $0 + h = int(s / 3600) + s %= 3600 + m = int(s / 60) + s %= 60 + + # Print it, with the biggest number without a leading zero + if (h) + printf "%u:%02u:%02u\n", h, m, s + else if (m) + printf "%u:%02u\n", m, s + else + printf "%u\n", s +} + +# Done, exit 1 if we had any errors on the way +END { exit(err > 0) } diff --git a/man/man1/hms.1df b/man/man1/hms.1df new file mode 100644 index 00000000..5c1a287c --- /dev/null +++ b/man/man1/hms.1df @@ -0,0 +1,23 @@ +.TH HMS 1df "February 2017" "Manual page for hms" +.SH NAME +.B hms +\- convert seconds to colon-delimited durations +.SH USAGE +.B hms +FILE1 [FILE2 ...] +.br +.B hms +< FILE +.br +printf '1:02:54\\n' | +.B hms +.br +hms=$(printf '%s\\n' "$seconds" | hms) +.SH DESCRIPTION +Applies awk(1) to convert counts of seconds into hh:mm:ss or mm:ss timestamps. +Exits zero if all lines were successfully recognised and converted, non-zero +otherwise. +.SH SEE ALSO +sec(1df) +.SH AUTHOR +Tom Ryder diff --git a/man/man1/sec.1df b/man/man1/sec.1df index aad09ddd..d0011b38 100644 --- a/man/man1/sec.1df +++ b/man/man1/sec.1df @@ -17,5 +17,7 @@ sec=$(printf '%s\\n' "$timestamp" | sec) Applies awk(1) to convert hh:mm:ss or mm:ss timestamps into a count of seconds. Exits zero if all lines were successfully recognised and converted, non-zero otherwise. +.SH SEE ALSO +hms(1df) .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 3cf1544df287b05afef6e5b6ed37db46492c1d48 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Feb 2017 00:22:36 +1300 Subject: Improve and correct some comments --- bash/bashrc | 50 ++++++++++++++++++++++--------------------- bash/bashrc.d/completion.bash | 8 +++---- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/bash/bashrc b/bash/bashrc index 16669adf..b456d966 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -9,9 +9,9 @@ esac # shellcheck disable=SC2128 [ -n "$BASH_VERSINFO" ] && shopt -q restricted_shell && return -# Clear away all aliases; we do this here rather than in $ENV because the ksh -# family of shells relies on aliases to implement certain POSIX utilities like -# fc(1) and type(1) +# Clear away all aliases; we do this here rather than in the $ENV file shared +# between POSIX shells, because ksh relies on aliases to implement certain +# POSIX utilities, like fc(1) and type(1) unalias -a # If ENV is set, source it to get all the POSIX-compatible interactive stuff; @@ -30,61 +30,63 @@ unalias -a # Keep around 32K lines of history in file HISTFILESIZE=$((1 << 15)) -# Ignore duplicate commands and whitespace in history -HISTCONTROL=ignoreboth +# Ignore duplicate commands +HISTCONTROL=ignoredups # Keep the times of the commands in history HISTTIMEFORMAT='%F %T ' -# Use a more compact format for the time builtin's output +# Use a more compact format for the `time` builtin's output TIMEFORMAT='real:%lR user:%lU sys:%lS' -# Autocorrect fudged paths in cd calls +# Correct small errors in directory names given to the `cd` buildtin shopt -s cdspell -# Update the hash table properly +# Check that hashed commands still exist before running them shopt -s checkhash -# Update columns and rows if window size changes +# Update LINES and COLUMNS after each command if necessary shopt -s checkwinsize -# Put multi-line commands onto one line of history +# Put multi-line commands into one history entry shopt -s cmdhist -# Include dotfiles in pattern matching +# Include filenames with leading dots in pattern matching shopt -s dotglob -# Enable advanced pattern matching +# Enable extended globbing: !(foo), ?(bar|baz)... shopt -s extglob -# Append rather than overwrite Bash history +# Append history to $HISTFILE rather than overwriting it shopt -s histappend -# Repeat the line on failed history expansion +# If history expansion fails, reload the command to try again shopt -s histreedit -# Repeat the expanded line on successful history expansion +# Load history expansion result as the next command, don't run them directly shopt -s histverify -# Use Bash's builtin host completion +# Use Bash's builtin hostname completion shopt -s hostcomplete # Don't change newlines to semicolons in history shopt -s lithist -# Don't warn me about new mail all the time +# Don't try to tell me when my mail is read shopt -u mailwarn -# Ignore me if I try to complete an empty line +# Don't complete a Tab press on an empty line with every possible command shopt -s no_empty_cmd_completion # Use programmable completion, if available shopt -s progcomp -# Warn me if I try to shift when there's nothing there +# Warn me if I try to shift nonexistent values off an array shopt -s shift_verbose -# Don't use PATH to find files to source +# Don't search $PATH to find files for the `source` builtin shopt -u sourcepath # These options only exist since Bash 4.0-alpha if ((BASH_VERSINFO[0] >= 4)) ; then - # Autocorrect fudged paths during completion + # Correct small errors in directory names during completion shopt -s dirspell - # Enable double-starring paths + # Allow double-star globs to match files and recursive paths shopt -s globstar - # Warn me about stopped jobs when exiting; only if >=4.1 due to bug + # Warn me about stopped jobs when exiting + # Available since 4.0, but only set it if >=4.1 due to bug: # ((BASH_VERSINFO[1] >= 1)) && shopt -s checkjobs - # Expand variables in directory completion; only available since 4.3 + # Expand variables in directory completion + # Only available since 4.3 ((BASH_VERSINFO[1] >= 3)) && shopt -s direxpand fi diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index c77f8844..ed938950 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -1,9 +1,9 @@ -# Various easy completions for Bash builtins; more specific stuff goes in -# ~/.bash_completion.d +# Simple completions for Bash builtins and POSIX utilities; more specific or +# complex stuff goes in ~/.bash_completion.d, for possible dynamic loading # If COMP_WORDBREAKS has a value, strip all colons from it; this allows -# completing filenames correctly, since an unquoted colon is not a syntactic -# character: (E13) +# completing filenames correctly, since a colon is not a shell metacharacter: +# (E13) [[ -n $COMP_WORDBREAKS ]] && COMP_WORDBREAKS=${COMP_WORDBREAKS//:} # If ~/.hosts exists, use that as the host completion file rather than -- cgit v1.2.3 From c03e2aaf12e16daab6bb171eedaf939682711390 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Feb 2017 00:25:30 +1300 Subject: Break a long line --- bash/bashrc.d/completion.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index ed938950..51de24b8 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -22,7 +22,8 @@ complete -A disabled enable complete -A setopt set # Commands -complete -A command alias command complete compopt coproc exec if hash time type until while +complete -A command alias command complete compopt coproc exec if hash time \ + type until while # Directories complete -A directory cd pushd mkdir rmdir -- cgit v1.2.3 From 18a5463ea2d39cb5502eb3cfba7281f03472bfd1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Feb 2017 00:27:25 +1300 Subject: Break a long line --- bash/bashrc.d/keep.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index a13fec12..da7ff558 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -46,8 +46,8 @@ keep() { # -h given; means show help h) cat < Date: Sun, 12 Feb 2017 00:07:27 +1300 Subject: Use bashdefault if available in more completions --- bash/bash_completion.d/ftp.bash | 8 +++++++- bash/bash_completion.d/gpg.bash | 8 +++++++- bash/bash_completion.d/make.bash | 8 +++++++- bash/bash_completion.d/man.bash | 8 +++++++- bash/bash_completion.d/mysql.bash | 8 +++++++- bash/bash_completion.d/sftp.bash | 8 +++++++- bash/bash_completion.d/ssh-copy-id.bash | 8 +++++++- bash/bash_completion.d/ssh.bash | 8 +++++++- 8 files changed, 56 insertions(+), 8 deletions(-) diff --git a/bash/bash_completion.d/ftp.bash b/bash/bash_completion.d/ftp.bash index e6d292a9..335d711a 100644 --- a/bash/bash_completion.d/ftp.bash +++ b/bash/bash_completion.d/ftp.bash @@ -30,4 +30,10 @@ _ftp() { COMPREPLY[${#COMPREPLY[@]}]=$machine done } -complete -F _ftp -o default ftp + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ftp -o bashdefault -o default ftp +else + complete -F _ftp -o default ftp +fi diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash index fcb48b91..6d4cf345 100644 --- a/bash/bash_completion.d/gpg.bash +++ b/bash/bash_completion.d/gpg.bash @@ -14,4 +14,10 @@ _gpg() { COMPREPLY[${#COMPREPLY[@]}]=$option done < <(gpg --dump-options 2>/dev/null) } -complete -F _gpg -o default gpg + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _gpg -o bashdefault -o default gpg +else + complete -F _gpg -o default gpg +fi diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index b3314e21..bb01b36a 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -48,4 +48,10 @@ _make() { esac done < "$mf" } -complete -F _make -o default make + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _make -o bashdefault -o default make +else + complete -F _make -o default make +fi diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index f779d203..658b5eb7 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -69,4 +69,10 @@ _man() { fi ) } -complete -F _man -o default man + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _man -o bashdefault -o default man +else + complete -F _man -o default man +fi diff --git a/bash/bash_completion.d/mysql.bash b/bash/bash_completion.d/mysql.bash index 9755f033..2886f62e 100644 --- a/bash/bash_completion.d/mysql.bash +++ b/bash/bash_completion.d/mysql.bash @@ -35,4 +35,10 @@ _mysql() { fi ) } -complete -F _mysql -o default mysql + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _mysql -o bashdefault -o default mysql +else + complete -F _mysql -o default mysql +fi diff --git a/bash/bash_completion.d/sftp.bash b/bash/bash_completion.d/sftp.bash index 5d52c739..60044e41 100644 --- a/bash/bash_completion.d/sftp.bash +++ b/bash/bash_completion.d/sftp.bash @@ -1,4 +1,10 @@ # Completion for sftp(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default sftp + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default sftp +else + complete -F _ssh_config_hosts -o default sftp +fi diff --git a/bash/bash_completion.d/ssh-copy-id.bash b/bash/bash_completion.d/ssh-copy-id.bash index daf52751..5e4fe99b 100644 --- a/bash/bash_completion.d/ssh-copy-id.bash +++ b/bash/bash_completion.d/ssh-copy-id.bash @@ -1,4 +1,10 @@ # Completion for ssh-copy-id(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default ssh-copy-id + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default ssh-copy-id +else + complete -F _ssh_config_hosts -o default ssh-copy-id +fi diff --git a/bash/bash_completion.d/ssh.bash b/bash/bash_completion.d/ssh.bash index 03745eaa..c8212614 100644 --- a/bash/bash_completion.d/ssh.bash +++ b/bash/bash_completion.d/ssh.bash @@ -1,4 +1,10 @@ # Completion for ssh(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default ssh + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default ssh +else + complete -F _ssh_config_hosts -o default ssh +fi -- cgit v1.2.3 From 995fd3ec04c3fd7f236a21aadf41da50f58f40d3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Feb 2017 23:04:23 +1300 Subject: Add mail(1)/mutt(1) abook address completion --- bash/bash_completion.d/_abook_addresses.bash | 10 ++++++++++ bash/bash_completion.d/mail.bash | 10 ++++++++++ bash/bash_completion.d/mutt.bash | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 bash/bash_completion.d/_abook_addresses.bash create mode 100644 bash/bash_completion.d/mail.bash create mode 100644 bash/bash_completion.d/mutt.bash diff --git a/bash/bash_completion.d/_abook_addresses.bash b/bash/bash_completion.d/_abook_addresses.bash new file mode 100644 index 00000000..8e341172 --- /dev/null +++ b/bash/bash_completion.d/_abook_addresses.bash @@ -0,0 +1,10 @@ +# Email addresses from abook(1) +_abook_addresses() { + while IFS=$'\t' read -r address _ ; do + case $address in + "${COMP_WORDS[COMP_CWORD]}"*) + COMPREPLY[${#COMPREPLY[@]}]=$address + ;; + esac + done < <(abook --mutt-query \@) +} diff --git a/bash/bash_completion.d/mail.bash b/bash/bash_completion.d/mail.bash new file mode 100644 index 00000000..4476df12 --- /dev/null +++ b/bash/bash_completion.d/mail.bash @@ -0,0 +1,10 @@ +# Completion for mail(1) with abook(1) email addresses +declare -F _abook_addresses >/dev/null || + source "$HOME"/.bash_completion.d/_abook_addresses.bash + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _abook_addresses -o bashdefault -o default mail +else + complete -F _abook_addresses -o default mail +fi diff --git a/bash/bash_completion.d/mutt.bash b/bash/bash_completion.d/mutt.bash new file mode 100644 index 00000000..d8bcc15d --- /dev/null +++ b/bash/bash_completion.d/mutt.bash @@ -0,0 +1,10 @@ +# Completion for mutt(1) with abook(1) email addresses +declare -F _abook_addresses >/dev/null || + source "$HOME"/.bash_completion.d/_abook_addresses.bash + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _abook_addresses -o bashdefault -o default mutt +else + complete -F _abook_addresses -o default mutt +fi -- cgit v1.2.3 From 57a8f123c17ad95b2a725a09cd4e3b8df526d57a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Feb 2017 23:09:08 +1300 Subject: More accurate commend for hostcomplete (turn off) --- bash/bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bashrc b/bash/bashrc index b456d966..166fc501 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -57,8 +57,8 @@ shopt -s histappend shopt -s histreedit # Load history expansion result as the next command, don't run them directly shopt -s histverify -# Use Bash's builtin hostname completion -shopt -s hostcomplete +# Don't assume a word with a @ in it is a hostname +shopt -u hostcomplete # Don't change newlines to semicolons in history shopt -s lithist # Don't try to tell me when my mail is read -- cgit v1.2.3 From 245c2d6647e34fb432066360499ed02c5711271c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Feb 2017 23:17:39 +1300 Subject: Use backslash to escape single char --- bash/bashrc.d/completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index 51de24b8..92e0ce0a 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -37,8 +37,8 @@ complete -A variable for getopts let read select complete -A helptopic help # Jobspecs -complete -P '%' -A job disown fg jobs -complete -P '%' -A stopped bg +complete -P \% -A job disown fg jobs +complete -P \% -A stopped bg # Readline bindings complete -A binding bind -- cgit v1.2.3 From e58c2922c37f346c372d524f354cc8a0b124745b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 13 Feb 2017 00:45:59 +1300 Subject: Add chgrp(1) completion --- bash/bash_completion.d/chgrp.bash | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bash/bash_completion.d/chgrp.bash diff --git a/bash/bash_completion.d/chgrp.bash b/bash/bash_completion.d/chgrp.bash new file mode 100644 index 00000000..d047f97f --- /dev/null +++ b/bash/bash_completion.d/chgrp.bash @@ -0,0 +1,20 @@ +# Complete group names for first non-option chgrp(1) argument +_chgrp() { + local i + for ((i = 1; i < COMP_CWORD; i++)) ; do + case ${COMP_WORDS[i]} in + -*) ;; + *) return 1 ;; + esac + done + while read -r group ; do + COMPREPLY[${#COMPREPLY[@]}]=$group + done < <(compgen -A group -- "${COMP_WORDS[COMP_CWORD]}") +} + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _chgrp -o bashdefault -o default chgrp +else + complete -F _chgrp -o default chgrp +fi -- cgit v1.2.3 From ecd693525c4185549b3609ae9e15785f05b18215 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 13 Feb 2017 00:46:28 +1300 Subject: Correct comment in `source` completion --- bash/bash_completion.d/source.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/source.bash b/bash/bash_completion.d/source.bash index abd468af..de608813 100644 --- a/bash/bash_completion.d/source.bash +++ b/bash/bash_completion.d/source.bash @@ -1,4 +1,4 @@ -# Completion for source(1) with files that look editable +# Completion for `source` with files that look like plain text declare -F _text_filenames >/dev/null || source "$HOME"/.bash_completion.d/_text_filenames.bash complete -F _text_filenames -o filenames source -- cgit v1.2.3 From eaaa2dfe25ce87fc1a05abbb8e343e0279bcca3d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Feb 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- vim/bundle/pathogen | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 6a5cc051..66292ea3 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 6a5cc0511776b69994b5e3bb2cacccbb81fa8464 +Subproject commit 66292ea3f834bec29cf742b5a40552674016235b diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 7ba2e1b6..020ab25c 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 7ba2e1b67a8f8bcbafedaf6763580390dfd93436 +Subproject commit 020ab25c38f62627c1dab6c7a851176c6ad309f9 -- cgit v1.2.3 From 5d614f2ac301ffdb83b1f37a872b3a0fd89f08cd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Feb 2017 14:38:13 +1300 Subject: Add osc(1df) --- README.markdown | 2 ++ bin/osc | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man1/osc.1df | 22 +++++++++++++++ 3 files changed, 110 insertions(+) create mode 100755 bin/osc create mode 100644 man/man1/osc.1df diff --git a/README.markdown b/README.markdown index 586594a4..bce41cd0 100644 --- a/README.markdown +++ b/README.markdown @@ -483,6 +483,8 @@ Installed by the `install-bin` target: * `mkmv(1df)` creates a directory and moves preceding arguments into it. * `motd(1df)` shows the system MOTD. * `onl(1df)` crunches input down to one printable line. +* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s + `s_client` subcommand. * `pa(1df)` prints its arguments, one per line. * `pp(1df)` prints the full path of each argument using `$PWD`. * `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. diff --git a/bin/osc b/bin/osc new file mode 100755 index 00000000..c1fe6ed0 --- /dev/null +++ b/bin/osc @@ -0,0 +1,86 @@ +#!/bin/sh +# Sane and safe OpenSSL s_client(1ssl) connection +self=osc + +# Check we have openssl(1); we need to fail early lest we go setting up FIFOs +# needlessly +if ! command -v openssl >/dev/null 2>&1 ; then + printf >&2 '%s: openssl(1) not found in $PATH\n' + exit 1 +fi + +# Hostname is first argument; assume localhost if empty/unset +host=${1:-localhost} +# Service name or port is second argument; assume HTTPS if empty/unset +serv=${2:-https} + +# Start building the command-line string +set -- +## If we have rlwrap, use it, but don't complain if we don't +if command -v rlwrap >/dev/null 2>&1 ; then + set -- "$@" rlwrap +fi +## The actual openssl(1ssl) and subcommand call +set -- "$@" openssl s_client +## No insecure SSL methods +set -- "$@" -no_ssl2 -no_ssl3 +## Don't dump nonsense to terminal, and don't renegotiate on R or quit on Q +set -- "$@" -quiet +## But do cut the connection if I issue ^D, even though I just set -quiet +set -- "$@" -no_ign_eof +## Do verify the certificate chain and don't connect if we can't +set -- "$@" -verify 5 -verify_return_error +## We might add STARTTLS for the supported services: +case $serv in + ftp|21) + set -- "$@" -starttls ftp + ;; + smtp|25) + set -- "$@" -starttls smtp + ;; + pop3|110) + set -- "$@" -starttls pop3 + ;; + imap|143) + set -- "$@" -starttls imap + ;; +esac +## Finally, add the host and service to connect to +set -- "$@" -connect "$host":"$serv" + +# Do the POSIX dance to kill child processes and clean up temp files even if +# killed by a signal +td= fil= +cleanup() { + trap - EXIT "$1" + [ -n "$fil" ] && kill -TERM "$fil" + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + kill -"$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + trap "cleanup $sig" "$sig" +done + +# Create a temporary directory and a FIFO in it +td=$(mktd "$self") || exit +mkfifo -- "$td"/verify-filter || exit + +# Open a read-write file descriptor onto the FIFO +exec 3<>"$td"/verify-filter || exit + +# Start a background filter process on the FIFO to get rid of the leading +# verification output set to stderr; as soon as we find a single line that +# doesn't look like that routine output, print all future lines to stderr as +# normal +awk ' +body{print;next} +/^verify depth is [0-9]+$/{next} +/^depth=[0-9]+ /{next} +/^verify return:[0-9]+$/{next} +{body=1;print} +' <&3 >&2 & fil=$! + +# Start the process with the options we stacked up +"$@" 2>&3 diff --git a/man/man1/osc.1df b/man/man1/osc.1df new file mode 100644 index 00000000..9fb61dde --- /dev/null +++ b/man/man1/osc.1df @@ -0,0 +1,22 @@ +.TH OSC 1df "February 2017" "Manual page for osc" +.SH NAME +.B osc +\- netcat-like wrapper for openssl s_client +.SH SYNOPSIS +.B osc [HOST [SERVICE]] +.SH DESCRIPTION +.B osc +runs openssl(1ssl)'s s_client subcommand with some options to make it behave a +bit like netcat(1), quieting errors and even handling STARTTLS if it knows how, +but still forcing correct verification of certificates and only connecting with +TLS (not SSL). +.P +If rlwrap(1) is available, the client will be run within that to allow line +editing. +.P +It's intended to be run as an interactive tool for cases where you want to +focus more on debugging the data exchange with the actual server, and not +debugging the OpenSSL negotiation itself. The author finds it handy for poking +his STARTTLS SMTP mailserver. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From e8fa3fc42d32e8787b6d527ee9f5145a293302be Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Feb 2017 14:48:04 +1300 Subject: Add xmpp as a valid osc(1df) STARTTLS method (!) Doesn't appear to be in the man page --- bin/osc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/osc b/bin/osc index c1fe6ed0..2fc05fd1 100755 --- a/bin/osc +++ b/bin/osc @@ -44,6 +44,9 @@ case $serv in imap|143) set -- "$@" -starttls imap ;; + xmpp-client|5222) + set -- "$@" -starttls xmpp + ;; esac ## Finally, add the host and service to connect to set -- "$@" -connect "$host":"$serv" -- cgit v1.2.3 From 4e79904914f11396eb01a85b848af1f42ec684c9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Feb 2017 14:50:09 +1300 Subject: Add -servername spec to osc(1df) --- bin/osc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/osc b/bin/osc index 2fc05fd1..a477c699 100755 --- a/bin/osc +++ b/bin/osc @@ -48,6 +48,8 @@ case $serv in set -- "$@" -starttls xmpp ;; esac +## Send the host parameter as the server name (SNI) +set -- "$@" -servername "$host" ## Finally, add the host and service to connect to set -- "$@" -connect "$host":"$serv" -- cgit v1.2.3 From 5d9b71be3769cb069ec4fc3bcc969eb4b4211bff Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Feb 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 66292ea3..fc64e3d0 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 66292ea3f834bec29cf742b5a40552674016235b +Subproject commit fc64e3d0de438a02dcfbe9d6fc7d73dbf721ce21 -- cgit v1.2.3 From 38268779586458e8160445e1ee6a3557a393b76e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 17 Feb 2017 09:45:06 +1300 Subject: shellcheck suggested a more efficient assignment --- ksh/kshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ksh/kshrc b/ksh/kshrc index 5d481bb4..ec90a35f 100644 --- a/ksh/kshrc +++ b/ksh/kshrc @@ -18,7 +18,7 @@ set -o trackall # Save history HISTFILE=$HOME/.ksh_history -HISTSIZE=$((1 << 10)) +((HISTSIZE=1 << 10)) # Load any supplementary scripts for kshrc in "$HOME"/.kshrc.d/*.ksh ; do -- cgit v1.2.3 From fc04c0e9ad545fafd7d379cc5db7569e6b90af60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 17 Feb 2017 09:45:35 +1300 Subject: Condense ENV_EXT hack, unset it --- ksh/shrc.d/ksh.sh | 5 +---- sh/shrc | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh index 8e33da7c..6101fc84 100644 --- a/ksh/shrc.d/ksh.sh +++ b/ksh/shrc.d/ksh.sh @@ -28,8 +28,5 @@ if [ -z "$KSH_VERSION" ] ; then KSH_VERSION=${.sh.version} fi -# If KSH_ENV isn't already set, set it -[ -n "$KSH_ENV" ] || KSH_ENV=$HOME/.kshrc - # If ENV_EXT isn't already set, set it -[ -n "$ENV_EXT" ] || ENV_EXT=$KSH_ENV +[ -n "$ENV_EXT" ] || ENV_EXT=$HOME/.kshrc diff --git a/sh/shrc b/sh/shrc index 879c8947..33c55e8f 100644 --- a/sh/shrc +++ b/sh/shrc @@ -20,5 +20,6 @@ for sh in "$HOME"/.shrc.d/*.sh ; do done unset -v sh -# If ENV_EXT was set and exists, source that too +# If ENV_EXT was set and exists, source that too, then clean it away [ -e "$ENV_EXT" ] && . "$ENV_EXT" +unset -v ENV_EXT -- cgit v1.2.3 From beb467011bed3fc2fac495fb22052b9d87d22ab0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 17 Feb 2017 09:50:53 +1300 Subject: Revert "Use backslash to escape single char" This reverts commit 245c2d6647e34fb432066360499ed02c5711271c. shellcheck worries about this. --- bash/bashrc.d/completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index 92e0ce0a..51de24b8 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -37,8 +37,8 @@ complete -A variable for getopts let read select complete -A helptopic help # Jobspecs -complete -P \% -A job disown fg jobs -complete -P \% -A stopped bg +complete -P '%' -A job disown fg jobs +complete -P '%' -A stopped bg # Readline bindings complete -A binding bind -- cgit v1.2.3 From 5aaed964f1a11b28ff79b6a7508195bdf2801a45 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 17 Feb 2017 09:54:23 +1300 Subject: Don't re-set HISTSIZE in kshrc Already set in shrc --- ksh/kshrc | 1 - 1 file changed, 1 deletion(-) diff --git a/ksh/kshrc b/ksh/kshrc index ec90a35f..43ac14da 100644 --- a/ksh/kshrc +++ b/ksh/kshrc @@ -18,7 +18,6 @@ set -o trackall # Save history HISTFILE=$HOME/.ksh_history -((HISTSIZE=1 << 10)) # Load any supplementary scripts for kshrc in "$HOME"/.kshrc.d/*.ksh ; do -- cgit v1.2.3 From 028a94550eb6bf11314e6fe4c77ef72e7eb288a7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 17 Feb 2017 11:15:01 +1300 Subject: Add missing man page section for tm(1df) iN README --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index bce41cd0..57f25004 100644 --- a/README.markdown +++ b/README.markdown @@ -508,7 +508,7 @@ Installed by the `install-bin` target: `scp(1)`'s HOST:PATH format. * `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used to use Taskwarrior, but found it too complex and buggy. -* `tm()` runs `tmux(1)` with `attach-session -d` if a session exists, and +* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and `new-session` if it doesn't. * `try(1df)` repeats a command up to a given number of times until it succeeds, only printing error output if all three attempts failed. Good for -- cgit v1.2.3 From 9d6eab06055d26a22384d7aca34214cbcd904584 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 18 Feb 2017 21:32:35 +1300 Subject: Use short-circuits in .profile.d scripts --- sh/profile.d/games.sh | 3 ++- sh/profile.d/keychain.sh | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sh/profile.d/games.sh b/sh/profile.d/games.sh index 58db3487..ee56c593 100644 --- a/sh/profile.d/games.sh +++ b/sh/profile.d/games.sh @@ -1,2 +1,3 @@ # Add ~/.local/games to PATH if it exists -[ -d "$HOME"/.local/games ] && PATH=$HOME/.local/games:$PATH +[ -d "$HOME"/.local/games ] || return +PATH=$HOME/.local/games:$PATH diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh index 9213de7f..f3d25c62 100644 --- a/sh/profile.d/keychain.sh +++ b/sh/profile.d/keychain.sh @@ -1,5 +1,5 @@ # keychain setup -command -v keychain >/dev/null 2>&1 && - eval "$(TERM=${TERM:-ansi} keychain \ - --eval --ignore-missing --quick --quiet \ - id_dsa id_rsa id_ecsda)" +command -v keychain >/dev/null 2>&1 || return +eval "$(TERM=${TERM:-ansi} keychain \ + --eval --ignore-missing --quick --quiet \ + id_dsa id_rsa id_ecsda)" -- cgit v1.2.3 From 469ac2466a943028f9a431bc4498dd197fd9262f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 18 Feb 2017 21:42:37 +1300 Subject: Don't export GPG_TTY if null --- sh/shrc.d/keychain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/keychain.sh b/sh/shrc.d/keychain.sh index d9aaf63f..9a732384 100644 --- a/sh/shrc.d/keychain.sh +++ b/sh/shrc.d/keychain.sh @@ -1,4 +1,4 @@ # If GPG_AGENT_INFO is set, update GPG_TTY for clean use of pinentry(1) etc [ -n "$GPG_AGENT_INFO" ] || return -GPG_TTY=$(command -p tty) +GPG_TTY=$(command -p tty) || return export GPG_TTY -- cgit v1.2.3 From feaf17ec26229a8f56c2b2a5a5915c2037408c7b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:01:42 +1300 Subject: Alphabetical resources sort --- X/Xresources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X/Xresources b/X/Xresources index 487c6ab0..989f0e01 100644 --- a/X/Xresources +++ b/X/Xresources @@ -1,2 +1,2 @@ -#include ".Xresources.d/Xft" #include ".Xresources.d/URxvt" +#include ".Xresources.d/Xft" -- cgit v1.2.3 From 59c2a887503e2b0e9b39c5357bb535a94797ba09 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:01:54 +1300 Subject: Add an issue --- ISSUES.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 383d7906..ca3afabc 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,3 +18,5 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file +* Git completion for "add" is error-prone; probably best just to let it add + plain files -- cgit v1.2.3 From 17e55778237e96dc0b52f58a31e228f3ab163a3e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:11:03 +1300 Subject: Add a start at an XTerm config --- X/Xresources | 1 + X/Xresources.d/xterm | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 X/Xresources.d/xterm diff --git a/X/Xresources b/X/Xresources index 989f0e01..d7d7556f 100644 --- a/X/Xresources +++ b/X/Xresources @@ -1,2 +1,3 @@ #include ".Xresources.d/URxvt" #include ".Xresources.d/Xft" +#include ".Xresources.d/xterm" diff --git a/X/Xresources.d/xterm b/X/Xresources.d/xterm new file mode 100644 index 00000000..ffa29689 --- /dev/null +++ b/X/Xresources.d/xterm @@ -0,0 +1,9 @@ +! XTerm +xterm*bellIsUrgent : true +xterm*internalBorder : 0 +xterm*colorMode : false +xterm*eightBitInput : false +xterm*faceName : Ubuntu Mono:size=12 +xterm*locale : true +xterm*metaSendsEscape : true +xterm*termName : xterm-mono -- cgit v1.2.3 From 6524b0c45eb36086de49d771c5b065e7b3bb8740 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:34:32 +1300 Subject: Remove a dependency on non-POSIX install(1) Pretty easy to adapt mkdir(1) and cp(1) appropriately anyway --- Makefile | 170 ++++++++++++++++++++++++++++---------------------------- README.markdown | 4 +- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/Makefile b/Makefile index 6a63dbb7..d0159a3e 100644 --- a/Makefile +++ b/Makefile @@ -173,143 +173,143 @@ install : install-bash \ install-vim install-abook : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.abook - install -pm 0644 -- abook/abookrc "$(HOME)"/.abook + cp -p -- abook/abookrc "$(HOME)"/.abook install-bash : check-bash install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.bashrc.d - install -pm 0644 -- bash/bashrc "$(HOME)"/.bashrc - install -pm 0644 -- bash/bashrc.d/* "$(HOME)"/.bashrc.d - install -pm 0644 -- bash/bash_profile "$(HOME)"/.bash_profile - install -pm 0644 -- bash/bash_logout "$(HOME)"/.bash_logout + cp -p -- bash/bashrc "$(HOME)"/.bashrc + cp -p -- bash/bashrc.d/* "$(HOME)"/.bashrc.d + cp -p -- bash/bash_profile "$(HOME)"/.bash_profile + cp -p -- bash/bash_logout "$(HOME)"/.bash_logout install-bash-completion : install-bash - install -m 0755 -d -- "$(HOME)"/.bash_completion.d - install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion - install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d + mkdir -p -- "$(HOME)"/.bash_completion.d + cp -p -- bash/bash_completion "$(HOME)"/.config/bash_completion + cp -p -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d install-bin : $(BINS) install-bin-man - install -m 0755 -d -- "$(HOME)"/.local/bin + mkdir -p -- "$(HOME)"/.local/bin for name in bin/* ; do \ [ -x "$$name" ] || continue ; \ - install -m 0755 -- "$$name" "$(HOME)"/.local/bin ; \ + cp -p -- "$$name" "$(HOME)"/.local/bin ; \ done install-bin-man : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.local/share/man/man1 \ "$(HOME)"/.local/share/man/man8 - install -pm 0644 -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 - install -pm 0644 -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 + cp -p -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 + cp -p -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 install-curl : - install -pm 0644 -- curl/curlrc "$(HOME)"/.curlrc + cp -p -- curl/curlrc "$(HOME)"/.curlrc install-dotfiles-man : man/man7/dotfiles.7df - install -m 0755 -d -- "$(HOME)"/.local/share/man/man7 - install -pm 0644 -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 + mkdir -p -- "$(HOME)"/.local/share/man/man7 + cp -p -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 install-dunst : install-x - install -m 0755 -d -- "$(HOME)"/.config/dunst - install -pm 0644 -- dunst/dunstrc "$(HOME)"/.config/dunst + mkdir -p -- "$(HOME)"/.config/dunst + cp -p -- dunst/dunstrc "$(HOME)"/.config/dunst install-finger : - install -pm 0644 -- finger/plan "$(HOME)"/.plan - install -pm 0644 -- finger/project "$(HOME)"/.project - install -pm 0644 -- finger/pgpkey "$(HOME)"/.pgpkey + cp -p -- finger/plan "$(HOME)"/.plan + cp -p -- finger/project "$(HOME)"/.project + cp -p -- finger/pgpkey "$(HOME)"/.pgpkey install-games : $(GAMES) install-games-man - install -m 0755 -d -- "$(HOME)"/.local/games + mkdir -p -- "$(HOME)"/.local/games for name in games/* ; do \ [ -x "$$name" ] || continue ; \ - install -m 0755 -- "$$name" "$(HOME)"/.local/games ; \ + cp -p -- "$$name" "$(HOME)"/.local/games ; \ done install-games-man : - install -m 0755 -d -- "$(HOME)"/.local/share/man/man6 - install -pm 0644 -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 + mkdir -p -- "$(HOME)"/.local/share/man/man6 + cp -p -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 install-git : git/gitconfig - install -pm 0644 -- git/gitconfig "$(HOME)"/.gitconfig + cp -p -- git/gitconfig "$(HOME)"/.gitconfig install-gnupg : gnupg/gpg.conf - install -m 0700 -d -- \ + mkdir -m 0700 -p -- \ "$(HOME)"/.gnupg \ "$(HOME)"/.gnupg/sks-keyservers.net - install -pm 0600 -- gnupg/*.conf "$(HOME)"/.gnupg - install -pm 0644 -- gnupg/sks-keyservers.net/* \ + cp -p -- gnupg/*.conf "$(HOME)"/.gnupg + cp -p -- gnupg/sks-keyservers.net/* \ "$(HOME)"/.gnupg/sks-keyservers.net install-gtk : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config/gtkrc-3.0 - install -pm 0644 -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 - install -pm 0644 -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 + cp -p -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 + cp -p -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 install-i3 : install-x - install -m 0755 -d -- "$(HOME)"/.i3 - install -pm 0644 -- i3/* "$(HOME)"/.i3 + mkdir -p -- "$(HOME)"/.i3 + cp -p -- i3/* "$(HOME)"/.i3 install-less : - install -pm 0644 -- less/lesskey "$(HOME)"/.lesskey + cp -p -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey install-mutt : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.muttrc.d \ "$(HOME)"/.cache/mutt - install -pm 0644 -- mutt/muttrc "$(HOME)"/.muttrc - install -pm 0755 -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d + cp -p -- mutt/muttrc "$(HOME)"/.muttrc + cp -p -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d install-ncmcpp : - install -m 0755 -d -- "$(HOME)"/.ncmpcpp - install -pm 0644 -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config + mkdir -p -- "$(HOME)"/.ncmpcpp + cp -p -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config install-newsbeuter : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config/newsbeuter \ "$(HOME)"/.local/share/newsbeuter - install -pm 0644 -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config + cp -p -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config install-mysql : - install -pm 0644 -- mysql/my.cnf "$(HOME)"/.my.cnf + cp -p -- mysql/my.cnf "$(HOME)"/.my.cnf install-ksh : check-ksh install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.shrc.d \ "$(HOME)"/.kshrc.d - install -pm 0644 -- ksh/shrc.d/* "$(HOME)"/.shrc.d - install -pm 0644 -- ksh/kshrc "$(HOME)"/.kshrc - install -pm 0644 -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d + cp -p -- ksh/shrc.d/* "$(HOME)"/.shrc.d + cp -p -- ksh/kshrc "$(HOME)"/.kshrc + cp -p -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d install-perlcritic : - install -pm 0644 -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc + cp -p -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc install-perltidy : - install -pm 0644 -- perltidy/perltidyrc "$(HOME)"/.perltidyrc + cp -p -- perltidy/perltidyrc "$(HOME)"/.perltidyrc install-psql : - install -pm 0644 -- psql/psqlrc "$(HOME)"/.psqlrc + cp -p -- psql/psqlrc "$(HOME)"/.psqlrc install-readline : - install -pm 0644 -- readline/inputrc "$(HOME)"/.inputrc + cp -p -- readline/inputrc "$(HOME)"/.inputrc install-sh : check-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.shrc.d - install -pm 0644 -- sh/profile "$(HOME)"/.profile - install -pm 0644 -- sh/profile.d/* "$(HOME)"/.profile.d - install -pm 0644 -- sh/shinit "$(HOME)"/.shinit - install -pm 0644 -- sh/shrc "$(HOME)"/.shrc - install -pm 0644 -- sh/shrc.d/* "$(HOME)"/.shrc.d + cp -p -- sh/profile "$(HOME)"/.profile + cp -p -- sh/profile.d/* "$(HOME)"/.profile.d + cp -p -- sh/shinit "$(HOME)"/.shinit + cp -p -- sh/shrc "$(HOME)"/.shrc + cp -p -- sh/shrc.d/* "$(HOME)"/.shrc.d install-subversion : - install -m 0755 -d -- "$(HOME)"/.subversion - install -pm 0644 -- subversion/config "$(HOME)"/.subversion/config + mkdir -p -- "$(HOME)"/.subversion + cp -p -- subversion/config "$(HOME)"/.subversion/config install-terminfo : for info in terminfo/*.info ; do \ @@ -317,14 +317,14 @@ install-terminfo : done install-tmux : tmux/tmux.conf install-terminfo - install -pm 0644 -- tmux/tmux.conf "$(HOME)"/.tmux.conf + cp -p -- tmux/tmux.conf "$(HOME)"/.tmux.conf install-urxvt : urxvt/ext/select check-urxvt - install -m 0755 -d -- "$(HOME)"/.urxvt/ext + mkdir -p -- "$(HOME)"/.urxvt/ext for name in urxvt/ext/* ; do \ case $$name in \ *.pl) ;; \ - *) install -m 0644 -- "$$name" "$(HOME)"/.urxvt/ext ;; \ + *) cp -p -- "$$name" "$(HOME)"/.urxvt/ext ;; \ esac \ done @@ -336,50 +336,50 @@ install-gvim : install-vim \ install-gvim-config install-vim-config : - install -pm 0644 -- vim/vimrc "$(HOME)"/.vimrc + cp -p -- vim/vimrc "$(HOME)"/.vimrc install-gvim-config : - install -pm 0644 -- vim/gvimrc "$(HOME)"/.gvimrc + cp -p -- vim/gvimrc "$(HOME)"/.gvimrc install-vim-plugins : install-vim-config find vim/after vim/bundle -name .git -prune -o \ - -type d -exec sh -c 'install -m 0755 -d -- \ + -type d -exec sh -c 'mkdir -p -- \ "$(HOME)"/."$$1"' _ {} \; -o \ - -type f -exec sh -c 'install -m 0644 -- \ + -type f -exec sh -c 'cp -p -- \ "$$1" "$(HOME)"/."$$1"' _ {} \; install-vim-pathogen : install-vim-plugins - install -m 0755 -d -- "$(HOME)"/.vim/autoload + mkdir -p -- "$(HOME)"/.vim/autoload rm -f -- "$(HOME)"/.vim/autoload/pathogen.vim ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ "$(HOME)"/.vim/autoload/pathogen.vim install-x : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.xinitrc.d \ "$(HOME)"/.Xresources.d - install -pm 0644 -- X/redshift.conf "$(HOME)"/.config/redshift.conf - install -pm 0644 -- X/xbindkeysrc "$(HOME)"/.xbindkeysrc - install -pm 0644 -- X/xinitrc "$(HOME)"/.xinitrc - install -pm 0644 -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d - install -pm 0644 -- X/Xresources "$(HOME)"/.Xresources - install -pm 0644 -- X/Xresources.d/* "$(HOME)"/.Xresources.d + cp -p -- X/redshift.conf "$(HOME)"/.config/redshift.conf + cp -p -- X/xbindkeysrc "$(HOME)"/.xbindkeysrc + cp -p -- X/xinitrc "$(HOME)"/.xinitrc + cp -p -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d + cp -p -- X/Xresources "$(HOME)"/.Xresources + cp -p -- X/Xresources.d/* "$(HOME)"/.Xresources.d install-yash : check-yash install-sh - install -m 0755 -d -- "$(HOME)"/.yashrc.d - install -pm 0644 -- yash/yash_profile "$(HOME)"/.yash_profile - install -pm 0644 -- yash/yashrc "$(HOME)"/.yashrc - install -pm 0644 -- yash/yashrc.d/* "$(HOME)"/.yashrc.d + mkdir -p -- "$(HOME)"/.yashrc.d + cp -p -- yash/yash_profile "$(HOME)"/.yash_profile + cp -p -- yash/yashrc "$(HOME)"/.yashrc + cp -p -- yash/yashrc.d/* "$(HOME)"/.yashrc.d install-zsh : check-zsh install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.zshrc.d - install -pm 0644 -- zsh/profile.d/* "$(HOME)"/.profile.d - install -pm 0644 -- zsh/zprofile "$(HOME)"/.zprofile - install -pm 0644 -- zsh/zshrc "$(HOME)"/.zshrc - install -pm 0644 -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d + cp -p -- zsh/profile.d/* "$(HOME)"/.profile.d + cp -p -- zsh/zprofile "$(HOME)"/.zprofile + cp -p -- zsh/zshrc "$(HOME)"/.zshrc + cp -p -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d check : check-bash \ check-bin \ diff --git a/README.markdown b/README.markdown index 57f25004..63ffdf32 100644 --- a/README.markdown +++ b/README.markdown @@ -15,8 +15,8 @@ Installation $ make -n install $ make install -For the default `all` target, you'll need `bash(1)`, `git(1)`, `install(1)`, -`make(1)`, and `m4(1)`. +For the default `all` target, you'll need `bash(1)`, `git(1)`, `make(1)`, and +`m4(1)`. The installation `Makefile` will overwrite things standing in the way of its installed files without backing them up, so read the output of `make -n -- cgit v1.2.3 From a982bc080b6a2c9be4cec94c15eeaa283da7623b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:38:34 +1300 Subject: Remove git(1) as install dependency *Technically* not required --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 63ffdf32..662eb56e 100644 --- a/README.markdown +++ b/README.markdown @@ -15,8 +15,7 @@ Installation $ make -n install $ make install -For the default `all` target, you'll need `bash(1)`, `git(1)`, `make(1)`, and -`m4(1)`. +For the default `all` target, you'll need `bash(1)`, `make(1)`, and `m4(1)`. The installation `Makefile` will overwrite things standing in the way of its installed files without backing them up, so read the output of `make -n -- cgit v1.2.3 From bbd51c97d70f8be42e2654e63d9d882441e14282 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:40:08 +1300 Subject: Remove a lie from the README The `install-terminfo` target is not part of the default `install` --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 662eb56e..2aafa228 100644 --- a/README.markdown +++ b/README.markdown @@ -28,9 +28,9 @@ directory so you can explore: $ env -i HOME="$tmpdir" TERM="$TERM" bash -l The default target will install the core terminal-only files: cURL, Git, GnuPG, -Vim, shell scripts and functions, and shell and terminal setup files. The -remaining dotfiles can be installed with the other targets. Take a look at the -`Makefile` to see what's available. +Vim, shell scripts and functions, and shell setup files. The remaining dotfiles +can be installed with the other targets. Take a look at the `Makefile` to see +what's available. Tools ----- -- cgit v1.2.3 From 38be294676051d832e54e5f15f44ee18b3289e73 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Feb 2017 23:58:57 +1300 Subject: Remove double-spacing --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d0159a3e..9133c9ae 100644 --- a/Makefile +++ b/Makefile @@ -416,11 +416,11 @@ check-zsh : check/zsh lint : check \ - lint-bash \ - lint-bin \ - lint-games \ - lint-ksh \ - lint-sh \ + lint-bash \ + lint-bin \ + lint-games \ + lint-ksh \ + lint-sh \ lint-urxvt \ lint-yash -- cgit v1.2.3 From eb5ef9c3c1bdf2019e1f01b49c2caf6ed35e1b2b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 Feb 2017 00:02:19 +1300 Subject: Add an issue --- ISSUES.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index ca3afabc..42e1524e 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -20,3 +20,6 @@ Known issues * Zsh, either! $options[restricted] is "off" within the startup file * Git completion for "add" is error-prone; probably best just to let it add plain files +* Would be good to complete the Makefile variables for NAME, EMAIL etc with + educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding + my own stuff in there -- cgit v1.2.3 From d2687a18c9194a2b71b8c7258d1f956620d75d8e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 Feb 2017 00:37:43 +1300 Subject: Appease ShellCheck on osc(1df) --- bin/osc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/osc b/bin/osc index a477c699..87f79365 100755 --- a/bin/osc +++ b/bin/osc @@ -5,7 +5,7 @@ self=osc # Check we have openssl(1); we need to fail early lest we go setting up FIFOs # needlessly if ! command -v openssl >/dev/null 2>&1 ; then - printf >&2 '%s: openssl(1) not found in $PATH\n' + printf >&2 '%s: openssl(1) not found\n' "$self" exit 1 fi @@ -55,7 +55,7 @@ set -- "$@" -connect "$host":"$serv" # Do the POSIX dance to kill child processes and clean up temp files even if # killed by a signal -td= fil= +td='' fil='' cleanup() { trap - EXIT "$1" [ -n "$fil" ] && kill -TERM "$fil" @@ -65,6 +65,7 @@ cleanup() { fi } for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 trap "cleanup $sig" "$sig" done -- cgit v1.2.3 From bf995e606d1fb9fdbb2646c1dd5331bb06a5218f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 Feb 2017 01:20:11 +1300 Subject: Add basic ex/vi settings These are POSIX --- Makefile | 5 +++++ README.markdown | 6 +++--- ex/exrc | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 ex/exrc diff --git a/Makefile b/Makefile index 9133c9ae..ca2f8583 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ install-curl \ install-dotfiles-man \ install-dunst \ + install-ex \ install-finger \ install-games \ install-games-man \ @@ -165,6 +166,7 @@ install : install-bash \ install-bash-completion \ install-bin \ install-curl \ + install-ex \ install-git \ install-gnupg \ install-less \ @@ -216,6 +218,9 @@ install-dunst : install-x mkdir -p -- "$(HOME)"/.config/dunst cp -p -- dunst/dunstrc "$(HOME)"/.config/dunst +install-ex : + cp -p -- ex/exrc "$(HOME)"/.exrc + install-finger : cp -p -- finger/plan "$(HOME)"/.plan cp -p -- finger/project "$(HOME)"/.project diff --git a/README.markdown b/README.markdown index 2aafa228..cd91dd8b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,9 +28,9 @@ directory so you can explore: $ env -i HOME="$tmpdir" TERM="$TERM" bash -l The default target will install the core terminal-only files: cURL, Git, GnuPG, -Vim, shell scripts and functions, and shell setup files. The remaining dotfiles -can be installed with the other targets. Take a look at the `Makefile` to see -what's available. +vi/Vim, shell scripts and functions, and shell setup files. The remaining +dotfiles can be installed with the other targets. Take a look at the `Makefile` +to see what's available. Tools ----- diff --git a/ex/exrc b/ex/exrc new file mode 100644 index 00000000..0c001f36 --- /dev/null +++ b/ex/exrc @@ -0,0 +1,6 @@ +" POSIX ex/vi settings +set autoindent +set report=0 +set shiftwidth=4 +set showmode +set tabstop=4 -- cgit v1.2.3 From 3d6829b47722828aa336b7644555ddbc5239cc39 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 Feb 2017 21:34:23 +1300 Subject: Switch from xbindkeys to sxhkd Smaller, easier --- IDEAS.markdown | 1 - Makefile | 3 ++- X/sxhkdrc | 44 ++++++++++++++++++++++++++++++++++++++++++++ X/xbindkeysrc | 44 -------------------------------------------- X/xinitrc.d/sxhkd.sh | 3 +++ X/xinitrc.d/xbindkeys.sh | 3 --- man/man1/br.1df | 3 --- 7 files changed, 49 insertions(+), 52 deletions(-) create mode 100644 X/sxhkdrc delete mode 100644 X/xbindkeysrc create mode 100644 X/xinitrc.d/sxhkd.sh delete mode 100644 X/xinitrc.d/xbindkeys.sh diff --git a/IDEAS.markdown b/IDEAS.markdown index d787947d..67283ce2 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -3,7 +3,6 @@ Ideas * I can probably share my psql() completions/shortcuts after sanitizing them a bit -* sxhkd(1) might be nicer than xbindkeys; it's in Debian Testing now * Wouldn't be too hard to add some HTTP BASIC auth to ix(1df) to make pastes manageable * Have eds(1df) accept stdin with the "starting content" for the script diff --git a/Makefile b/Makefile index ca2f8583..80c91721 100644 --- a/Makefile +++ b/Makefile @@ -362,10 +362,11 @@ install-vim-pathogen : install-vim-plugins install-x : mkdir -p -- \ "$(HOME)"/.config \ + "$(HOME)"/.config/sxhkdrc \ "$(HOME)"/.xinitrc.d \ "$(HOME)"/.Xresources.d cp -p -- X/redshift.conf "$(HOME)"/.config/redshift.conf - cp -p -- X/xbindkeysrc "$(HOME)"/.xbindkeysrc + cp -p -- X/sxhkdrc "$(HOME)"/.config/sxhkd/sxhkdrc cp -p -- X/xinitrc "$(HOME)"/.xinitrc cp -p -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d cp -p -- X/Xresources "$(HOME)"/.Xresources diff --git a/X/sxhkdrc b/X/sxhkdrc new file mode 100644 index 00000000..5a75f1df --- /dev/null +++ b/X/sxhkdrc @@ -0,0 +1,44 @@ +super + Return + urxvtcd + +super + control + Return + urxvtcd -e sh + +super + shift + Return + urxvtcd -e ksh + +super + alt + Return + urxvtcd -e zsh + +super + b + br + +super + d + dmenu_run + +super + g + xgoc + +super + i + gimp + +super + m + urxvtcd -e tm + +super + p + dmp + +super + slash + i3lock --color=#000000 --image ~/.i3/lock.png --nofork + +XF86AudioMute + amixer -q sset Master toggle + +XF86AudioRaiseVolume + amixer -q sset Master 5%+ unmute + +XF86AudioLowerVolume + amixer -q sset Master 5%- unmute + +XF86Calculator + urxvtcd -e bcq diff --git a/X/xbindkeysrc b/X/xbindkeysrc deleted file mode 100644 index 16ae5b14..00000000 --- a/X/xbindkeysrc +++ /dev/null @@ -1,44 +0,0 @@ -"exec urxvtcd" - Mod4 + Return - -"exec urxvtcd -e sh" - Mod4 + Control + Return - -"exec urxvtcd -e ksh" - Mod4 + Shift + Return - -"exec urxvtcd -e zsh" - Mod4 + Alt + Return - -"exec br" - Mod4 + b - -"exec dmenu_run" - Mod4 + d - -"exec xgoc" - Mod4 + g - -"exec gimp" - Mod4 + i - -"exec urxvtcd -e tm" - Mod4 + m - -"exec dmp" - Mod4 + p - -"exec i3lock --color=#000000 --image ~/.i3/lock.png --nofork" - Mod4 + slash - -"exec amixer -q sset Master toggle" - XF86AudioMute - -"exec amixer -q sset Master 5%+ unmute" - XF86AudioRaiseVolume - -"exec amixer -q sset Master 5%- unmute" - XF86AudioLowerVolume - -"exec urxvtcd -e bcq" - XF86Calculator diff --git a/X/xinitrc.d/sxhkd.sh b/X/xinitrc.d/sxhkd.sh new file mode 100644 index 00000000..132d8f8a --- /dev/null +++ b/X/xinitrc.d/sxhkd.sh @@ -0,0 +1,3 @@ +# Start sxhkd(1) +command -v sxhkd >/dev/null 2>&1 || return +sxhkd & diff --git a/X/xinitrc.d/xbindkeys.sh b/X/xinitrc.d/xbindkeys.sh deleted file mode 100644 index b76aebdd..00000000 --- a/X/xinitrc.d/xbindkeys.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Start xbindkeys(1) -command -v xbindkeys >/dev/null 2>&1 || return -(cd -- "$HOME" && xbindkeys -n) & diff --git a/man/man1/br.1df b/man/man1/br.1df index af9645fb..05d662bc 100644 --- a/man/man1/br.1df +++ b/man/man1/br.1df @@ -14,9 +14,6 @@ BROWSER=firefox .B br just execs the program in the $BROWSER environment variable with the given arguments. That's it. -.P -It was written to have a clean way to launch $BROWSER from ~/.xbindkeysrc. It -has no other reason to exist. .SH SEE ALSO bp(1df), xgo(1df), xgoc(1df) .SH AUTHOR -- cgit v1.2.3 From 9210d7f8478a9f9942e4c11da0cc84b851d346b6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 Feb 2017 21:47:17 +1300 Subject: Make traditional PGP decoding work again --- mutt/muttrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mutt/muttrc b/mutt/muttrc index 3a38a7cf..953ab418 100644 --- a/mutt/muttrc +++ b/mutt/muttrc @@ -108,6 +108,9 @@ set crypt_use_gpgme = yes set crypt_use_pka = yes set crypt_verify_sig = yes +# Do decode classic PGP messages, though we'll never write them +set pgp_auto_decode = yes + # Vim-ish bindings bind index gg first-entry bind index G last-entry -- cgit v1.2.3 From da6f96a92ffed833e00e0f9d958ed4872dbf3e34 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 26 Feb 2017 13:27:46 +1300 Subject: Remove error-prone git-add(1) completion Just files and directories will do fine --- ISSUES.markdown | 2 -- bash/bash_completion.d/git.bash | 23 ----------------------- 2 files changed, 25 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index 42e1524e..4c78a3f3 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,8 +18,6 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file -* Git completion for "add" is error-prone; probably best just to let it add - plain files * Would be good to complete the Makefile variables for NAME, EMAIL etc with educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding my own stuff in there diff --git a/bash/bash_completion.d/git.bash b/bash/bash_completion.d/git.bash index 5cf42ed3..2bee169a 100644 --- a/bash/bash_completion.d/git.bash +++ b/bash/bash_completion.d/git.bash @@ -69,23 +69,6 @@ _git() { done return ;; - - # Untracked files - untracked_files) - local file - while IFS= read -rd '' file ; do - [[ -n $file ]] || continue - COMPREPLY[${#COMPREPLY[@]}]=$file - done < <(git ls-files \ - --directory \ - --exclude-standard \ - --no-empty-directory \ - --others \ - -z \ - -- "${COMP_WORDS[COMP_CWORD]}"'*' \ - 2>/dev/null) - return - ;; esac # Try to find the index of the Git subcommand @@ -117,12 +100,6 @@ _git() { # Test subcommand to choose completions case ${COMP_WORDS[sci]} in - # Complete with untracked, unignored files - add) - "${FUNCNAME[0]}" untracked_files - return - ;; - # Help on real subcommands (not aliases) help) "${FUNCNAME[0]}" subcommands -- cgit v1.2.3 From b9d63d76072ca5dd48d387aad8999a82531a9cf2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 26 Feb 2017 14:18:44 +1300 Subject: Add plenv scripts Probably worthwhile given I use it on several systems and it's not expensive to check whether it exists. --- sh/profile.d/plenv.sh | 5 +++++ sh/shrc.d/plenv.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 sh/profile.d/plenv.sh create mode 100644 sh/shrc.d/plenv.sh diff --git a/sh/profile.d/plenv.sh b/sh/profile.d/plenv.sh new file mode 100644 index 00000000..b2b491e1 --- /dev/null +++ b/sh/profile.d/plenv.sh @@ -0,0 +1,5 @@ +# Add plenv to PATH and MANPATH if it appears to be in use +[ -d "$HOME"/.plenv ] || return +PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH +MANPATH=$HOME/.plenv/versions/$(perl -e 'print substr($^V,1)')/man:$MANPATH +export MANPATH diff --git a/sh/shrc.d/plenv.sh b/sh/shrc.d/plenv.sh new file mode 100644 index 00000000..6e03618e --- /dev/null +++ b/sh/shrc.d/plenv.sh @@ -0,0 +1,17 @@ +# POSIX-compatible version of the plenv Bash shell wrapper +[ -d "$HOME"/.plenv ] || return +plenv() { + case $1 in + rehash) + shift + eval "$(plenv sh-rehash "$@")" + ;; + shell) + shift + eval "$(plenv sh-shell "$@")" + ;; + *) + command plenv "$@" + ;; + esac +} -- cgit v1.2.3 From 1c1998212fafee784a41373578e56c41ee2a4d42 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 28 Feb 2017 15:09:34 +1300 Subject: Use just = rather than := in Makefile --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 80c91721..33af926b 100644 --- a/Makefile +++ b/Makefile @@ -61,10 +61,10 @@ .SUFFIXES: .awk .bash .pl .sed -NAME := Tom Ryder -EMAIL := tom@sanctum.geek.nz -KEY := 0xC14286EA77BB8872 -SENDMAIL := msmtp +NAME = Tom Ryder +EMAIL = tom@sanctum.geek.nz +KEY = 0xC14286EA77BB8872 +SENDMAIL = msmtp BINS = bin/brnl \ bin/csmw \ @@ -125,7 +125,7 @@ git/gitconfig : git/gitconfig.m4 -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ git/gitconfig.m4 > git/gitconfig -KEYSERVER := hkps://hkps.pool.sks-keyservers.net +KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf : gnupg/gpg.conf.m4 m4 \ @@ -137,10 +137,10 @@ man/man7/dotfiles.7df : README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o "$@" -MAILDIR := $(HOME)/Mail +MAILDIR = $(HOME)/Mail -TMUX_BG := colour237 -TMUX_FG := colour248 +TMUX_BG = colour237 +TMUX_FG = colour248 tmux/tmux.conf : tmux/tmux.conf.m4 m4 -D TMUX_BG="$(TMUX_BG)" -D TMUX_FG="$(TMUX_FG)" \ -- cgit v1.2.3 From 9fb5ae654ac672c1745ebb6455a01169f3fedeee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 28 Feb 2017 15:11:34 +1300 Subject: Remove leading spaces before colons in Makefile --- Makefile | 140 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index 33af926b..e3d04a54 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : all \ +.PHONY: all \ clean \ distclean \ install \ @@ -105,9 +105,9 @@ GAMES = games/acq \ games/strik \ games/zs -all : $(BINS) git/gitconfig gnupg/gpg.conf +all: $(BINS) git/gitconfig gnupg/gpg.conf -clean distclean : +clean distclean: rm -f \ $(BINS) \ $(GAMES) \ @@ -117,7 +117,7 @@ clean distclean : tmux/tmux.conf \ urxvt/ext/select -git/gitconfig : git/gitconfig.m4 +git/gitconfig: git/gitconfig.m4 m4 \ -D DOTFILES_NAME="$(NAME)" \ -D DOTFILES_EMAIL="$(EMAIL)" \ @@ -127,13 +127,13 @@ git/gitconfig : git/gitconfig.m4 KEYSERVER = hkps://hkps.pool.sks-keyservers.net -gnupg/gpg.conf : gnupg/gpg.conf.m4 +gnupg/gpg.conf: gnupg/gpg.conf.m4 m4 \ -D DOTFILES_HOME="$(HOME)" \ -D DOTFILES_KEYSERVER="$(KEYSERVER)" \ gnupg/gpg.conf.m4 > gnupg/gpg.conf -man/man7/dotfiles.7df : README.markdown man/man7/dotfiles.7df.header +man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o "$@" @@ -142,27 +142,27 @@ MAILDIR = $(HOME)/Mail TMUX_BG = colour237 TMUX_FG = colour248 -tmux/tmux.conf : tmux/tmux.conf.m4 +tmux/tmux.conf: tmux/tmux.conf.m4 m4 -D TMUX_BG="$(TMUX_BG)" -D TMUX_FG="$(TMUX_FG)" \ tmux/tmux.conf.m4 > tmux/tmux.conf -.awk : +.awk: bin/shb "$<" awk -f > "$@" chmod +x "$@" -.bash : +.bash: bin/shb "$<" bash > "$@" chmod +x "$@" -.pl : +.pl: bin/shb "$<" perl > "$@" chmod +x "$@" -.sed : +.sed: bin/shb "$<" sed -f > "$@" chmod +x "$@" -install : install-bash \ +install: install-bash \ install-bash-completion \ install-bin \ install-curl \ @@ -174,12 +174,12 @@ install : install-bash \ install-sh \ install-vim -install-abook : +install-abook: mkdir -p -- \ "$(HOME)"/.abook cp -p -- abook/abookrc "$(HOME)"/.abook -install-bash : check-bash install-sh +install-bash: check-bash install-sh mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.bashrc.d @@ -188,59 +188,59 @@ install-bash : check-bash install-sh cp -p -- bash/bash_profile "$(HOME)"/.bash_profile cp -p -- bash/bash_logout "$(HOME)"/.bash_logout -install-bash-completion : install-bash +install-bash-completion: install-bash mkdir -p -- "$(HOME)"/.bash_completion.d cp -p -- bash/bash_completion "$(HOME)"/.config/bash_completion cp -p -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d -install-bin : $(BINS) install-bin-man +install-bin: $(BINS) install-bin-man mkdir -p -- "$(HOME)"/.local/bin for name in bin/* ; do \ [ -x "$$name" ] || continue ; \ cp -p -- "$$name" "$(HOME)"/.local/bin ; \ done -install-bin-man : +install-bin-man: mkdir -p -- \ "$(HOME)"/.local/share/man/man1 \ "$(HOME)"/.local/share/man/man8 cp -p -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 cp -p -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 -install-curl : +install-curl: cp -p -- curl/curlrc "$(HOME)"/.curlrc -install-dotfiles-man : man/man7/dotfiles.7df +install-dotfiles-man: man/man7/dotfiles.7df mkdir -p -- "$(HOME)"/.local/share/man/man7 cp -p -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 -install-dunst : install-x +install-dunst: install-x mkdir -p -- "$(HOME)"/.config/dunst cp -p -- dunst/dunstrc "$(HOME)"/.config/dunst -install-ex : +install-ex: cp -p -- ex/exrc "$(HOME)"/.exrc -install-finger : +install-finger: cp -p -- finger/plan "$(HOME)"/.plan cp -p -- finger/project "$(HOME)"/.project cp -p -- finger/pgpkey "$(HOME)"/.pgpkey -install-games : $(GAMES) install-games-man +install-games: $(GAMES) install-games-man mkdir -p -- "$(HOME)"/.local/games for name in games/* ; do \ [ -x "$$name" ] || continue ; \ cp -p -- "$$name" "$(HOME)"/.local/games ; \ done -install-games-man : +install-games-man: mkdir -p -- "$(HOME)"/.local/share/man/man6 cp -p -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 -install-git : git/gitconfig +install-git: git/gitconfig cp -p -- git/gitconfig "$(HOME)"/.gitconfig -install-gnupg : gnupg/gpg.conf +install-gnupg: gnupg/gpg.conf mkdir -m 0700 -p -- \ "$(HOME)"/.gnupg \ "$(HOME)"/.gnupg/sks-keyservers.net @@ -248,41 +248,41 @@ install-gnupg : gnupg/gpg.conf cp -p -- gnupg/sks-keyservers.net/* \ "$(HOME)"/.gnupg/sks-keyservers.net -install-gtk : +install-gtk: mkdir -p -- \ "$(HOME)"/.config/gtkrc-3.0 cp -p -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 cp -p -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 -install-i3 : install-x +install-i3: install-x mkdir -p -- "$(HOME)"/.i3 cp -p -- i3/* "$(HOME)"/.i3 -install-less : +install-less: cp -p -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey -install-mutt : +install-mutt: mkdir -p -- \ "$(HOME)"/.muttrc.d \ "$(HOME)"/.cache/mutt cp -p -- mutt/muttrc "$(HOME)"/.muttrc cp -p -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d -install-ncmcpp : +install-ncmcpp: mkdir -p -- "$(HOME)"/.ncmpcpp cp -p -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config -install-newsbeuter : +install-newsbeuter: mkdir -p -- \ "$(HOME)"/.config/newsbeuter \ "$(HOME)"/.local/share/newsbeuter cp -p -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config -install-mysql : +install-mysql: cp -p -- mysql/my.cnf "$(HOME)"/.my.cnf -install-ksh : check-ksh install-sh +install-ksh: check-ksh install-sh mkdir -p -- \ "$(HOME)"/.shrc.d \ "$(HOME)"/.kshrc.d @@ -290,19 +290,19 @@ install-ksh : check-ksh install-sh cp -p -- ksh/kshrc "$(HOME)"/.kshrc cp -p -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d -install-perlcritic : +install-perlcritic: cp -p -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc -install-perltidy : +install-perltidy: cp -p -- perltidy/perltidyrc "$(HOME)"/.perltidyrc -install-psql : +install-psql: cp -p -- psql/psqlrc "$(HOME)"/.psqlrc -install-readline : +install-readline: cp -p -- readline/inputrc "$(HOME)"/.inputrc -install-sh : check-sh +install-sh: check-sh mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.shrc.d @@ -312,19 +312,19 @@ install-sh : check-sh cp -p -- sh/shrc "$(HOME)"/.shrc cp -p -- sh/shrc.d/* "$(HOME)"/.shrc.d -install-subversion : +install-subversion: mkdir -p -- "$(HOME)"/.subversion cp -p -- subversion/config "$(HOME)"/.subversion/config -install-terminfo : +install-terminfo: for info in terminfo/*.info ; do \ tic -- "$$info" ; \ done -install-tmux : tmux/tmux.conf install-terminfo +install-tmux: tmux/tmux.conf install-terminfo cp -p -- tmux/tmux.conf "$(HOME)"/.tmux.conf -install-urxvt : urxvt/ext/select check-urxvt +install-urxvt: urxvt/ext/select check-urxvt mkdir -p -- "$(HOME)"/.urxvt/ext for name in urxvt/ext/* ; do \ case $$name in \ @@ -333,33 +333,33 @@ install-urxvt : urxvt/ext/select check-urxvt esac \ done -install-vim : install-vim-config \ +install-vim: install-vim-config \ install-vim-plugins \ install-vim-pathogen -install-gvim : install-vim \ +install-gvim: install-vim \ install-gvim-config -install-vim-config : +install-vim-config: cp -p -- vim/vimrc "$(HOME)"/.vimrc -install-gvim-config : +install-gvim-config: cp -p -- vim/gvimrc "$(HOME)"/.gvimrc -install-vim-plugins : install-vim-config +install-vim-plugins: install-vim-config find vim/after vim/bundle -name .git -prune -o \ -type d -exec sh -c 'mkdir -p -- \ "$(HOME)"/."$$1"' _ {} \; -o \ -type f -exec sh -c 'cp -p -- \ "$$1" "$(HOME)"/."$$1"' _ {} \; -install-vim-pathogen : install-vim-plugins +install-vim-pathogen: install-vim-plugins mkdir -p -- "$(HOME)"/.vim/autoload rm -f -- "$(HOME)"/.vim/autoload/pathogen.vim ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ "$(HOME)"/.vim/autoload/pathogen.vim -install-x : +install-x: mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.config/sxhkdrc \ @@ -372,13 +372,13 @@ install-x : cp -p -- X/Xresources "$(HOME)"/.Xresources cp -p -- X/Xresources.d/* "$(HOME)"/.Xresources.d -install-yash : check-yash install-sh +install-yash: check-yash install-sh mkdir -p -- "$(HOME)"/.yashrc.d cp -p -- yash/yash_profile "$(HOME)"/.yash_profile cp -p -- yash/yashrc "$(HOME)"/.yashrc cp -p -- yash/yashrc.d/* "$(HOME)"/.yashrc.d -install-zsh : check-zsh install-sh +install-zsh: check-zsh install-sh mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.zshrc.d @@ -387,41 +387,41 @@ install-zsh : check-zsh install-sh cp -p -- zsh/zshrc "$(HOME)"/.zshrc cp -p -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d -check : check-bash \ +check: check-bash \ check-bin \ check-games \ check-man \ check-sh \ check-urxvt -check-bash : +check-bash: check/bash -check-bin : $(BINS) +check-bin: $(BINS) check/bin -check-games : $(GAMES) +check-games: $(GAMES) check/games -check-man : +check-man: check/man -check-ksh : +check-ksh: check/ksh -check-sh : +check-sh: check/sh -check-urxvt : +check-urxvt: check/urxvt -check-yash : +check-yash: check/yash -check-zsh : +check-zsh: check/zsh -lint : check \ +lint: check \ lint-bash \ lint-bin \ lint-games \ @@ -430,23 +430,23 @@ lint : check \ lint-urxvt \ lint-yash -lint-bash : +lint-bash: lint/bash -lint-bin : $(BINS) +lint-bin: $(BINS) lint/bin -lint-games : $(GAMES) +lint-games: $(GAMES) lint/games -lint-ksh : +lint-ksh: lint/ksh -lint-sh : +lint-sh: lint/sh -lint-urxvt : +lint-urxvt: lint/urxvt -lint-yash : +lint-yash: lint/yash -- cgit v1.2.3 From 229a6c7d63565f4f0d8b25fb9171ff642c06c28f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 8 Mar 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index fc64e3d0..1e9ac963 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit fc64e3d0de438a02dcfbe9d6fc7d73dbf721ce21 +Subproject commit 1e9ac963a5c187aad6880292738426d806699066 -- cgit v1.2.3 From 96d4bcf1df427fab7f399b120e6273adfe3d6f64 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 8 Mar 2017 11:25:38 +1300 Subject: Fix wro(1df) man page synopsis formatting --- man/man1/wro.1df | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/man/man1/wro.1df b/man/man1/wro.1df index 350ca448..dc64046b 100644 --- a/man/man1/wro.1df +++ b/man/man1/wro.1df @@ -3,12 +3,16 @@ .B wro \- add a quote header to the standard input .SH SYNOPSIS +$ .B wro -luser@example.com +luser@example.com < file .br +$ .B wro luser@example.com '2017-01-15 9:00am' +.br Text on standard input. +.br ^D .SH DESCRIPTION .B wro -- cgit v1.2.3 From c431438c8de2a47527d05bbb6df8c2ff869ad2e0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 8 Mar 2017 11:45:51 +1300 Subject: More accurate description of default target --- README.markdown | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index cd91dd8b..05d53270 100644 --- a/README.markdown +++ b/README.markdown @@ -27,10 +27,23 @@ directory so you can explore: $ make install HOME="$tmpdir" $ env -i HOME="$tmpdir" TERM="$TERM" bash -l -The default target will install the core terminal-only files: cURL, Git, GnuPG, -vi/Vim, shell scripts and functions, and shell setup files. The remaining -dotfiles can be installed with the other targets. Take a look at the `Makefile` -to see what's available. +The default `install` target will install these targets and all their +dependencies: + +* `install-bash` +* `install-bin` +* `install-bin-man` +* `install-curl` +* `install-ex` +* `install-git` +* `install-gnupg` +* `install-less` +* `install-readline` +* `install-sh` +* `install-vim` + +The remaining dotfiles can be installed with the other `install-*` targets. Try +`bin/mftl Makefile` in the project's root directory to see a list. Tools ----- -- cgit v1.2.3 From b5c783b95140f3fbd40c4e1cd73649c8bdc323dd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 9 Mar 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 1e9ac963..3f3484a8 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 1e9ac963a5c187aad6880292738426d806699066 +Subproject commit 3f3484a8788f599a9eb86c363408c5cab66d66bd -- cgit v1.2.3 From c3d4f097a7282f81d4c0efc702efdb6e99cb218c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 9 Mar 2017 10:03:33 +1300 Subject: Use env vars not shell funcs for vim check Set EDITOR and VISUAL appropriately based on what's on the system. We can't assume ed(1) unfortunately, but ex(1) should be there. --- README.markdown | 2 -- sh/profile.d/editor.sh | 8 ++++++-- sh/profile.d/visual.sh | 8 ++++++-- sh/shrc.d/vim.sh | 13 ------------- 4 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 sh/shrc.d/vim.sh diff --git a/README.markdown b/README.markdown index 05d53270..4cd4820c 100644 --- a/README.markdown +++ b/README.markdown @@ -217,8 +217,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: preserved; I hate having `root`-owned files in my home directory. * `tree()` colorizes GNU `tree(1)` output if possible (without having `LS_COLORS` set). -* `vim()` defines three functions to always use `vim(1)` as my `ex(1)`, - `vi(1)` and `view(1)` implementation if it's available. * `x()` is a one-key shortcut for `exec startx`. There are a few other little tricks defined for other shells providing diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh index ee0da70b..5d6b249e 100644 --- a/sh/profile.d/editor.sh +++ b/sh/profile.d/editor.sh @@ -1,3 +1,7 @@ -# Set command-line editor -EDITOR=ed +# Set command-line editor; ed if we've got it (!), but ex will do fine +if command -v ed >/dev/null 2>&1 ; then + EDITOR=ed +else + EDITOR=ex +fi export EDITOR diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh index 95eb1d5d..d03da255 100644 --- a/sh/profile.d/visual.sh +++ b/sh/profile.d/visual.sh @@ -1,3 +1,7 @@ -# Set visual editor -VISUAL=vi +# Set visual editor; vim if we've got it, but vi will do fine +if command -v vim >/dev/null 2>&1 ; then + VISUAL=vim +else + VISUAL=vi +fi export VISUAL diff --git a/sh/shrc.d/vim.sh b/sh/shrc.d/vim.sh deleted file mode 100644 index e9174082..00000000 --- a/sh/shrc.d/vim.sh +++ /dev/null @@ -1,13 +0,0 @@ -# If Vim exists on the system, use it instead of ex, vi, and view -command -v vim >/dev/null 2>&1 || return - -# Define functions proper -ex() { - vim -e "$@" -} -vi() { - vim "$@" -} -view() { - vim -R "$@" -} -- cgit v1.2.3 From 0b3ec1c5ece3ad484158312711a8ca9b86d39bc1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 9 Mar 2017 11:00:26 +1300 Subject: Add an issue --- ISSUES.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 4c78a3f3..9a2877d3 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -21,3 +21,5 @@ Known issues * Would be good to complete the Makefile variables for NAME, EMAIL etc with educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding my own stuff in there +* vim's implementation of ex clears the screen; would be good to find a way + to prevent that (preferably without something awful like `TERM=t100 ex`). -- cgit v1.2.3 From ca174cb57c31bb4ab8227611bd7081245d639753 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Mar 2017 09:25:32 +1300 Subject: Correct two manual references --- zsh/zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh/zshrc b/zsh/zshrc index b4c60747..fa4186d4 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,6 +1,6 @@ # Clear away all aliases; we do this here rather than in $ENV because the ksh # family of shells relies on aliases to implement certain POSIX utilities like -# fc(1) and type(1). Ignore output, as older Zsh seems not to implement this +# `fc` and `type`. Ignore output, as older Zsh seems not to implement this # (quelle surprise). unalias -a >/dev/null 2>&1 -- cgit v1.2.3 From e63f37cda767dad9a5bd931fee25f2e1c14ba92f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Mar 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/abolish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/abolish b/vim/bundle/abolish index 05c7d31f..b6a8b49e 160000 --- a/vim/bundle/abolish +++ b/vim/bundle/abolish @@ -1 +1 @@ -Subproject commit 05c7d31f6b3066582017edf5198502a94f6a7cb5 +Subproject commit b6a8b49e2173ba5a1b34d00e68e0ed8addac3ebd -- cgit v1.2.3 From 2acbd7eabf928a73e5cd7515e45de96532f5c7af Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Mar 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/commentary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/commentary b/vim/bundle/commentary index 73e0d9a9..be79030b 160000 --- a/vim/bundle/commentary +++ b/vim/bundle/commentary @@ -1 +1 @@ -Subproject commit 73e0d9a9d1f51b6cc9dc965f62669194ae851cb1 +Subproject commit be79030b3e8c0ee3c5f45b4333919e4830531e80 -- cgit v1.2.3 From 8724b14537c511c00f717dc4c567cfd859cbd017 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Mar 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 3f3484a8..dfdd71a5 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 3f3484a8788f599a9eb86c363408c5cab66d66bd +Subproject commit dfdd71a5a8ac6fc5569bcd7997e099f0fc9bee7b -- cgit v1.2.3 From 9c9f6a5c9f50756492909198907a2a614bf8a33e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 Mar 2017 01:00:05 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index dfdd71a5..0a19c5aa 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit dfdd71a5a8ac6fc5569bcd7997e099f0fc9bee7b +Subproject commit 0a19c5aaf985e064b2cfc30a348a235ba91b2570 -- cgit v1.2.3 From 11cf4d35395fa1818b742511064444248967b1a0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 Mar 2017 17:21:25 +1300 Subject: Remove misleading Makefile var quoting This doesn't quote in the same way shell does and it's a bit misleading to present it as doing so. --- Makefile | 230 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/Makefile b/Makefile index e3d04a54..375b76a2 100644 --- a/Makefile +++ b/Makefile @@ -119,23 +119,23 @@ clean distclean: git/gitconfig: git/gitconfig.m4 m4 \ - -D DOTFILES_NAME="$(NAME)" \ - -D DOTFILES_EMAIL="$(EMAIL)" \ - -D DOTFILES_KEY="$(KEY)" \ - -D DOTFILES_SENDMAIL="$(SENDMAIL)" \ + -D DOTFILES_NAME=$(NAME) \ + -D DOTFILES_EMAIL=$(EMAIL) \ + -D DOTFILES_KEY=$(KEY) \ + -D DOTFILES_SENDMAIL=$(SENDMAIL) \ git/gitconfig.m4 > git/gitconfig KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf: gnupg/gpg.conf.m4 m4 \ - -D DOTFILES_HOME="$(HOME)" \ - -D DOTFILES_KEYSERVER="$(KEYSERVER)" \ + -D DOTFILES_HOME=$(HOME) \ + -D DOTFILES_KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > gnupg/gpg.conf man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ - pandoc -sS -t man -o "$@" + pandoc -sS -t man -o $@ MAILDIR = $(HOME)/Mail @@ -143,24 +143,24 @@ TMUX_BG = colour237 TMUX_FG = colour248 tmux/tmux.conf: tmux/tmux.conf.m4 - m4 -D TMUX_BG="$(TMUX_BG)" -D TMUX_FG="$(TMUX_FG)" \ + m4 -D TMUX_BG=$(TMUX_BG) -D TMUX_FG=$(TMUX_FG) \ tmux/tmux.conf.m4 > tmux/tmux.conf .awk: - bin/shb "$<" awk -f > "$@" - chmod +x "$@" + bin/shb $< awk -f > $@ + chmod +x $@ .bash: - bin/shb "$<" bash > "$@" - chmod +x "$@" + bin/shb $< bash > $@ + chmod +x $@ .pl: - bin/shb "$<" perl > "$@" - chmod +x "$@" + bin/shb $< perl > $@ + chmod +x $@ .sed: - bin/shb "$<" sed -f > "$@" - chmod +x "$@" + bin/shb $< sed -f > $@ + chmod +x $@ install: install-bash \ install-bash-completion \ @@ -176,145 +176,145 @@ install: install-bash \ install-abook: mkdir -p -- \ - "$(HOME)"/.abook - cp -p -- abook/abookrc "$(HOME)"/.abook + $(HOME)/.abook + cp -p -- abook/abookrc $(HOME)/.abook install-bash: check-bash install-sh mkdir -p -- \ - "$(HOME)"/.config \ - "$(HOME)"/.bashrc.d - cp -p -- bash/bashrc "$(HOME)"/.bashrc - cp -p -- bash/bashrc.d/* "$(HOME)"/.bashrc.d - cp -p -- bash/bash_profile "$(HOME)"/.bash_profile - cp -p -- bash/bash_logout "$(HOME)"/.bash_logout + $(HOME)/.config \ + $(HOME)/.bashrc.d + cp -p -- bash/bashrc $(HOME)/.bashrc + cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d + cp -p -- bash/bash_profile $(HOME)/.bash_profile + cp -p -- bash/bash_logout $(HOME)/.bash_logout install-bash-completion: install-bash - mkdir -p -- "$(HOME)"/.bash_completion.d - cp -p -- bash/bash_completion "$(HOME)"/.config/bash_completion - cp -p -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d + mkdir -p -- $(HOME)/.bash_completion.d + cp -p -- bash/bash_completion $(HOME)/.config/bash_completion + cp -p -- bash/bash_completion.d/* $(HOME)/.bash_completion.d install-bin: $(BINS) install-bin-man - mkdir -p -- "$(HOME)"/.local/bin + mkdir -p -- $(HOME)/.local/bin for name in bin/* ; do \ [ -x "$$name" ] || continue ; \ - cp -p -- "$$name" "$(HOME)"/.local/bin ; \ + cp -p -- "$$name" $(HOME)/.local/bin ; \ done install-bin-man: mkdir -p -- \ - "$(HOME)"/.local/share/man/man1 \ - "$(HOME)"/.local/share/man/man8 - cp -p -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 - cp -p -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 + $(HOME)/.local/share/man/man1 \ + $(HOME)/.local/share/man/man8 + cp -p -- man/man1/*.1df $(HOME)/.local/share/man/man1 + cp -p -- man/man8/*.8df $(HOME)/.local/share/man/man8 install-curl: - cp -p -- curl/curlrc "$(HOME)"/.curlrc + cp -p -- curl/curlrc $(HOME)/.curlrc install-dotfiles-man: man/man7/dotfiles.7df - mkdir -p -- "$(HOME)"/.local/share/man/man7 - cp -p -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 + mkdir -p -- $(HOME)/.local/share/man/man7 + cp -p -- man/man7/*.7df $(HOME)/.local/share/man/man7 install-dunst: install-x - mkdir -p -- "$(HOME)"/.config/dunst - cp -p -- dunst/dunstrc "$(HOME)"/.config/dunst + mkdir -p -- $(HOME)/.config/dunst + cp -p -- dunst/dunstrc $(HOME)/.config/dunst install-ex: - cp -p -- ex/exrc "$(HOME)"/.exrc + cp -p -- ex/exrc $(HOME)/.exrc install-finger: - cp -p -- finger/plan "$(HOME)"/.plan - cp -p -- finger/project "$(HOME)"/.project - cp -p -- finger/pgpkey "$(HOME)"/.pgpkey + cp -p -- finger/plan $(HOME)/.plan + cp -p -- finger/project $(HOME)/.project + cp -p -- finger/pgpkey $(HOME)/.pgpkey install-games: $(GAMES) install-games-man - mkdir -p -- "$(HOME)"/.local/games + mkdir -p -- $(HOME)/.local/games for name in games/* ; do \ [ -x "$$name" ] || continue ; \ - cp -p -- "$$name" "$(HOME)"/.local/games ; \ + cp -p -- "$$name" $(HOME)/.local/games ; \ done install-games-man: - mkdir -p -- "$(HOME)"/.local/share/man/man6 - cp -p -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 + mkdir -p -- $(HOME)/.local/share/man/man6 + cp -p -- man/man6/*.6df $(HOME)/.local/share/man/man6 install-git: git/gitconfig - cp -p -- git/gitconfig "$(HOME)"/.gitconfig + cp -p -- git/gitconfig $(HOME)/.gitconfig install-gnupg: gnupg/gpg.conf mkdir -m 0700 -p -- \ - "$(HOME)"/.gnupg \ - "$(HOME)"/.gnupg/sks-keyservers.net - cp -p -- gnupg/*.conf "$(HOME)"/.gnupg + $(HOME)/.gnupg \ + $(HOME)/.gnupg/sks-keyservers.net + cp -p -- gnupg/*.conf $(HOME)/.gnupg cp -p -- gnupg/sks-keyservers.net/* \ - "$(HOME)"/.gnupg/sks-keyservers.net + $(HOME)/.gnupg/sks-keyservers.net install-gtk: mkdir -p -- \ - "$(HOME)"/.config/gtkrc-3.0 - cp -p -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 - cp -p -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 + $(HOME)/.config/gtkrc-3.0 + cp -p -- gtk/gtkrc-2.0 $(HOME)/.gtkrc-2.0 + cp -p -- gtk/gtkrc-3.0/settings.ini $(HOME)/.config/gtkrc-3.0 install-i3: install-x - mkdir -p -- "$(HOME)"/.i3 - cp -p -- i3/* "$(HOME)"/.i3 + mkdir -p -- $(HOME)/.i3 + cp -p -- i3/* $(HOME)/.i3 install-less: - cp -p -- less/lesskey "$(HOME)"/.lesskey + cp -p -- less/lesskey $(HOME)/.lesskey command -v lesskey && lesskey install-mutt: mkdir -p -- \ - "$(HOME)"/.muttrc.d \ - "$(HOME)"/.cache/mutt - cp -p -- mutt/muttrc "$(HOME)"/.muttrc - cp -p -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d + $(HOME)/.muttrc.d \ + $(HOME)/.cache/mutt + cp -p -- mutt/muttrc $(HOME)/.muttrc + cp -p -- mutt/muttrc.d/src $(HOME)/.muttrc.d install-ncmcpp: - mkdir -p -- "$(HOME)"/.ncmpcpp - cp -p -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config + mkdir -p -- $(HOME)/.ncmpcpp + cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp/config install-newsbeuter: mkdir -p -- \ - "$(HOME)"/.config/newsbeuter \ - "$(HOME)"/.local/share/newsbeuter - cp -p -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config + $(HOME)/.config/newsbeuter \ + $(HOME)/.local/share/newsbeuter + cp -p -- newsbeuter/config $(HOME)/.config/newsbeuter/config install-mysql: - cp -p -- mysql/my.cnf "$(HOME)"/.my.cnf + cp -p -- mysql/my.cnf $(HOME)/.my.cnf install-ksh: check-ksh install-sh mkdir -p -- \ - "$(HOME)"/.shrc.d \ - "$(HOME)"/.kshrc.d - cp -p -- ksh/shrc.d/* "$(HOME)"/.shrc.d - cp -p -- ksh/kshrc "$(HOME)"/.kshrc - cp -p -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d + $(HOME)/.shrc.d \ + $(HOME)/.kshrc.d + cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d + cp -p -- ksh/kshrc $(HOME)/.kshrc + cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d install-perlcritic: - cp -p -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc + cp -p -- perlcritic/perlcriticrc $(HOME)/.perlcriticrc install-perltidy: - cp -p -- perltidy/perltidyrc "$(HOME)"/.perltidyrc + cp -p -- perltidy/perltidyrc $(HOME)/.perltidyrc install-psql: - cp -p -- psql/psqlrc "$(HOME)"/.psqlrc + cp -p -- psql/psqlrc $(HOME)/.psqlrc install-readline: - cp -p -- readline/inputrc "$(HOME)"/.inputrc + cp -p -- readline/inputrc $(HOME)/.inputrc install-sh: check-sh mkdir -p -- \ - "$(HOME)"/.profile.d \ - "$(HOME)"/.shrc.d - cp -p -- sh/profile "$(HOME)"/.profile - cp -p -- sh/profile.d/* "$(HOME)"/.profile.d - cp -p -- sh/shinit "$(HOME)"/.shinit - cp -p -- sh/shrc "$(HOME)"/.shrc - cp -p -- sh/shrc.d/* "$(HOME)"/.shrc.d + $(HOME)/.profile.d \ + $(HOME)/.shrc.d + cp -p -- sh/profile $(HOME)/.profile + cp -p -- sh/profile.d/* $(HOME)/.profile.d + cp -p -- sh/shinit $(HOME)/.shinit + cp -p -- sh/shrc $(HOME)/.shrc + cp -p -- sh/shrc.d/* $(HOME)/.shrc.d install-subversion: - mkdir -p -- "$(HOME)"/.subversion - cp -p -- subversion/config "$(HOME)"/.subversion/config + mkdir -p -- $(HOME)/.subversion + cp -p -- subversion/config $(HOME)/.subversion/config install-terminfo: for info in terminfo/*.info ; do \ @@ -322,14 +322,14 @@ install-terminfo: done install-tmux: tmux/tmux.conf install-terminfo - cp -p -- tmux/tmux.conf "$(HOME)"/.tmux.conf + cp -p -- tmux/tmux.conf $(HOME)/.tmux.conf install-urxvt: urxvt/ext/select check-urxvt - mkdir -p -- "$(HOME)"/.urxvt/ext + mkdir -p -- $(HOME)/.urxvt/ext for name in urxvt/ext/* ; do \ case $$name in \ *.pl) ;; \ - *) cp -p -- "$$name" "$(HOME)"/.urxvt/ext ;; \ + *) cp -p -- "$$name" $(HOME)/.urxvt/ext ;; \ esac \ done @@ -341,51 +341,51 @@ install-gvim: install-vim \ install-gvim-config install-vim-config: - cp -p -- vim/vimrc "$(HOME)"/.vimrc + cp -p -- vim/vimrc $(HOME)/.vimrc install-gvim-config: - cp -p -- vim/gvimrc "$(HOME)"/.gvimrc + cp -p -- vim/gvimrc $(HOME)/.gvimrc install-vim-plugins: install-vim-config find vim/after vim/bundle -name .git -prune -o \ -type d -exec sh -c 'mkdir -p -- \ - "$(HOME)"/."$$1"' _ {} \; -o \ + $(HOME)/."$$1"' _ {} \; -o \ -type f -exec sh -c 'cp -p -- \ - "$$1" "$(HOME)"/."$$1"' _ {} \; + "$$1" $(HOME)/."$$1"' _ {} \; install-vim-pathogen: install-vim-plugins - mkdir -p -- "$(HOME)"/.vim/autoload - rm -f -- "$(HOME)"/.vim/autoload/pathogen.vim + mkdir -p -- $(HOME)/.vim/autoload + rm -f -- $(HOME)/.vim/autoload/pathogen.vim ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ - "$(HOME)"/.vim/autoload/pathogen.vim + $(HOME)/.vim/autoload/pathogen.vim install-x: mkdir -p -- \ - "$(HOME)"/.config \ - "$(HOME)"/.config/sxhkdrc \ - "$(HOME)"/.xinitrc.d \ - "$(HOME)"/.Xresources.d - cp -p -- X/redshift.conf "$(HOME)"/.config/redshift.conf - cp -p -- X/sxhkdrc "$(HOME)"/.config/sxhkd/sxhkdrc - cp -p -- X/xinitrc "$(HOME)"/.xinitrc - cp -p -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d - cp -p -- X/Xresources "$(HOME)"/.Xresources - cp -p -- X/Xresources.d/* "$(HOME)"/.Xresources.d + $(HOME)/.config \ + $(HOME)/.config/sxhkdrc \ + $(HOME)/.xinitrc.d \ + $(HOME)/.Xresources.d + cp -p -- X/redshift.conf $(HOME)/.config/redshift.conf + cp -p -- X/sxhkdrc $(HOME)/.config/sxhkd/sxhkdrc + cp -p -- X/xinitrc $(HOME)/.xinitrc + cp -p -- X/xinitrc.d/* $(HOME)/.xinitrc.d + cp -p -- X/Xresources $(HOME)/.Xresources + cp -p -- X/Xresources.d/* $(HOME)/.Xresources.d install-yash: check-yash install-sh - mkdir -p -- "$(HOME)"/.yashrc.d - cp -p -- yash/yash_profile "$(HOME)"/.yash_profile - cp -p -- yash/yashrc "$(HOME)"/.yashrc - cp -p -- yash/yashrc.d/* "$(HOME)"/.yashrc.d + mkdir -p -- $(HOME)/.yashrc.d + cp -p -- yash/yash_profile $(HOME)/.yash_profile + cp -p -- yash/yashrc $(HOME)/.yashrc + cp -p -- yash/yashrc.d/* $(HOME)/.yashrc.d install-zsh: check-zsh install-sh mkdir -p -- \ - "$(HOME)"/.profile.d \ - "$(HOME)"/.zshrc.d - cp -p -- zsh/profile.d/* "$(HOME)"/.profile.d - cp -p -- zsh/zprofile "$(HOME)"/.zprofile - cp -p -- zsh/zshrc "$(HOME)"/.zshrc - cp -p -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d + $(HOME)/.profile.d \ + $(HOME)/.zshrc.d + cp -p -- zsh/profile.d/* $(HOME)/.profile.d + cp -p -- zsh/zprofile $(HOME)/.zprofile + cp -p -- zsh/zshrc $(HOME)/.zshrc + cp -p -- zsh/zshrc.d/* $(HOME)/.zshrc.d check: check-bash \ check-bin \ -- cgit v1.2.3 From 3cc0cbef08e68bed1c60adf007b567d3ff889586 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 Mar 2017 17:25:27 +1300 Subject: Single-quote name --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 375b76a2..e907b349 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ .SUFFIXES: .awk .bash .pl .sed -NAME = Tom Ryder +NAME = 'Tom Ryder' EMAIL = tom@sanctum.geek.nz KEY = 0xC14286EA77BB8872 SENDMAIL = msmtp -- cgit v1.2.3 From e078597ce1d2a974d714d493f03b4f6c1f0f2a2c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 Mar 2017 17:25:47 +1300 Subject: Use consistent m4 prefix --- Makefile | 14 +++++++------- git/gitconfig.m4 | 8 ++++---- gnupg/gpg.conf.m4 | 4 ++-- tmux/tmux.conf.m4 | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index e907b349..409f265c 100644 --- a/Makefile +++ b/Makefile @@ -119,18 +119,18 @@ clean distclean: git/gitconfig: git/gitconfig.m4 m4 \ - -D DOTFILES_NAME=$(NAME) \ - -D DOTFILES_EMAIL=$(EMAIL) \ - -D DOTFILES_KEY=$(KEY) \ - -D DOTFILES_SENDMAIL=$(SENDMAIL) \ + -D DF_NAME=$(NAME) \ + -D DF_EMAIL=$(EMAIL) \ + -D DF_KEY=$(KEY) \ + -D DF_SENDMAIL=$(SENDMAIL) \ git/gitconfig.m4 > git/gitconfig KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf: gnupg/gpg.conf.m4 m4 \ - -D DOTFILES_HOME=$(HOME) \ - -D DOTFILES_KEYSERVER=$(KEYSERVER) \ + -D DF_HOME=$(HOME) \ + -D DF_KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > gnupg/gpg.conf man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header @@ -143,7 +143,7 @@ TMUX_BG = colour237 TMUX_FG = colour248 tmux/tmux.conf: tmux/tmux.conf.m4 - m4 -D TMUX_BG=$(TMUX_BG) -D TMUX_FG=$(TMUX_FG) \ + m4 -D DF_TMUX_BG=$(TMUX_BG) -D DF_TMUX_FG=$(TMUX_FG) \ tmux/tmux.conf.m4 > tmux/tmux.conf .awk: diff --git a/git/gitconfig.m4 b/git/gitconfig.m4 index d13e7fdb..f533f02f 100644 --- a/git/gitconfig.m4 +++ b/git/gitconfig.m4 @@ -52,13 +52,13 @@ [sendemail] confirm = compose - smtpServer = DOTFILES_SENDMAIL + smtpServer = DF_SENDMAIL [status] short = true showUntrackedFiles = all [user] - name = DOTFILES_NAME - email = DOTFILES_EMAIL - signingKey = DOTFILES_KEY + name = DF_NAME + email = DF_EMAIL + signingKey = DF_KEY diff --git a/gnupg/gpg.conf.m4 b/gnupg/gpg.conf.m4 index dbbed306..29534991 100644 --- a/gnupg/gpg.conf.m4 +++ b/gnupg/gpg.conf.m4 @@ -22,11 +22,11 @@ fixed-list-mode keyid-format 0xlong # Use a pool of servers which support HKPS (encrypted key retrieval) -keyserver DOTFILES_KEYSERVER +keyserver DF_KEYSERVER # Retrieve keys automatically; check the keyserver port cert; use whichever # server is proffered from the pool -keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=DOTFILES_HOME/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem +keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=DF_HOME/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem # Include trust/validity for UIDs in listings list-options show-uid-validity diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 index 4e3cce4d..facb91ca 100644 --- a/tmux/tmux.conf.m4 +++ b/tmux/tmux.conf.m4 @@ -113,15 +113,15 @@ set-option -g message-style "bg=colour18,fg=colour231" set-window-option -g mode-style "bg=colour18,fg=colour231" # Pane borders are always in the background color -set-option -g pane-border-style "fg=TMUX_BG" -set-option -g pane-active-border-style "fg=TMUX_BG" +set-option -g pane-border-style "fg=DF_TMUX_BG" +set-option -g pane-active-border-style "fg=DF_TMUX_BG" # Inactive windows have slightly washed-out system colours set-option -g window-style "bg=colour232,fg=colour248" set-option -g window-active-style "bg=colour0,fg=colour15" # The status bar has the defined background and foreground colours -set-option -g status-style "bg=TMUX_BG,fg=TMUX_FG" +set-option -g status-style "bg=DF_TMUX_BG,fg=DF_TMUX_FG" # Titles of windows default to black text with no embellishment set-window-option -g window-status-style "fg=colour16" -- cgit v1.2.3 From 91ac2f576af2f6dbe8fbbb01fbb7979968affe1a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 23 Mar 2017 17:59:06 +1300 Subject: Add .POSIX shibboleth to Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 409f265c..1a4c8622 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.POSIX: .PHONY: all \ clean \ distclean \ -- cgit v1.2.3 From b724640f925793b3e74519046f61c965b279391f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 09:01:35 +1300 Subject: Add -- separator to Makefile inference commands --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1a4c8622..781bb690 100644 --- a/Makefile +++ b/Makefile @@ -149,19 +149,19 @@ tmux/tmux.conf: tmux/tmux.conf.m4 .awk: bin/shb $< awk -f > $@ - chmod +x $@ + chmod +x -- $@ .bash: bin/shb $< bash > $@ - chmod +x $@ + chmod +x -- $@ .pl: bin/shb $< perl > $@ - chmod +x $@ + chmod +x -- $@ .sed: bin/shb $< sed -f > $@ - chmod +x $@ + chmod +x -- $@ install: install-bash \ install-bash-completion \ -- cgit v1.2.3 From 89536815eec2dee00100604792764ab985f36d6b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 09:03:43 +1300 Subject: Use builtin macros for filenames --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 781bb690..71a5ceeb 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ git/gitconfig: git/gitconfig.m4 -D DF_EMAIL=$(EMAIL) \ -D DF_KEY=$(KEY) \ -D DF_SENDMAIL=$(SENDMAIL) \ - git/gitconfig.m4 > git/gitconfig + git/gitconfig.m4 > $@ KEYSERVER = hkps://hkps.pool.sks-keyservers.net @@ -132,7 +132,7 @@ gnupg/gpg.conf: gnupg/gpg.conf.m4 m4 \ -D DF_HOME=$(HOME) \ -D DF_KEYSERVER=$(KEYSERVER) \ - gnupg/gpg.conf.m4 > gnupg/gpg.conf + gnupg/gpg.conf.m4 > $@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ @@ -145,7 +145,7 @@ TMUX_FG = colour248 tmux/tmux.conf: tmux/tmux.conf.m4 m4 -D DF_TMUX_BG=$(TMUX_BG) -D DF_TMUX_FG=$(TMUX_FG) \ - tmux/tmux.conf.m4 > tmux/tmux.conf + tmux/tmux.conf.m4 > $@ .awk: bin/shb $< awk -f > $@ -- cgit v1.2.3 From 9d6199c5dc0911a5595e5f225ad909845ed8cc17 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 09:11:27 +1300 Subject: Change shb(1) to read stdin by default This is clearer. --- Makefile | 8 ++++---- bin/shb | 13 ++++++------- man/man1/shb.1df | 16 ++++++---------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 71a5ceeb..fd3c9931 100644 --- a/Makefile +++ b/Makefile @@ -148,19 +148,19 @@ tmux/tmux.conf: tmux/tmux.conf.m4 tmux/tmux.conf.m4 > $@ .awk: - bin/shb $< awk -f > $@ + bin/shb awk -f < $< > $@ chmod +x -- $@ .bash: - bin/shb $< bash > $@ + bin/shb bash < $< > $@ chmod +x -- $@ .pl: - bin/shb $< perl > $@ + bin/shb perl < $< > $@ chmod +x -- $@ .sed: - bin/shb $< sed -f > $@ + bin/shb sed -f < $< > $@ chmod +x -- $@ install: install-bash \ diff --git a/bin/shb b/bin/shb index 49894b0f..72ac818b 100755 --- a/bin/shb +++ b/bin/shb @@ -3,15 +3,14 @@ self=shb # Need at least two arguments -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need input file and command\n' "$self" +if [ "$#" -lt 1 ] ; then + printf >&2 '%s: Need interpreter command\n' "$self" exit 1 fi -# First argument is the script (might be - for stdin), second argument is the -# name of the interpreter -scr=$1 intn=$2 -shift 2 +# First argument is the name of the interpreter +intn=$1 +shift # Try and find the path to the interpreter command, bail out if we can't if ! intp=$(command -v "$intn" 2>/dev/null) ; then @@ -25,4 +24,4 @@ set -- "$intp" "$@" printf '#!%s\n' "$*" # Emit the rest of the input -cat -- "$scr" +cat diff --git a/man/man1/shb.1df b/man/man1/shb.1df index 1970dbde..a1cb884a 100644 --- a/man/man1/shb.1df +++ b/man/man1/shb.1df @@ -4,20 +4,16 @@ \- insert a shebang line above a file .SH SYNOPSIS .B shb -script bash +bash < foo.bash > foo .br +cat *.sed | .B shb -script sed -f -.br -command | -.B shb -- awk -f +sed -f > sedbatch .SH DESCRIPTION .B shb -searches the system paths to find a suitable program with the name given in the -second argument, forms a "shebang" line from it and any arguments beyond the -second, and then emits the contents of the first argument ('-' can be used for -stdin). +searches the system paths to find a suitable program with the name given in its +first argument, forms a "shebang" line from it and any remaining arguments, and +then emits the contents of stdin. .P This is intended as a minimal way to make portable shebang lines for Makefiles or other building or installation frameworks, handling subtleties like sed(1) -- cgit v1.2.3 From 5d6188ef72863339909a9033d9337d67ec4d9809 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 10:20:11 +1300 Subject: Turns out "--" is not specified for chmod(1) --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fd3c9931..96f93ed1 100644 --- a/Makefile +++ b/Makefile @@ -149,19 +149,19 @@ tmux/tmux.conf: tmux/tmux.conf.m4 .awk: bin/shb awk -f < $< > $@ - chmod +x -- $@ + chmod +x ./$@ .bash: bin/shb bash < $< > $@ - chmod +x -- $@ + chmod +x ./$@ .pl: bin/shb perl < $< > $@ - chmod +x -- $@ + chmod +x ./$@ .sed: bin/shb sed -f < $< > $@ - chmod +x -- $@ + chmod +x ./$@ install: install-bash \ install-bash-completion \ -- cgit v1.2.3 From 500036564541ff2d65a7b2f6f6f556202d72d6ce Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 11:01:05 +1300 Subject: Lots of Makefile tidying * Add missing "--" option terminator * Merge overzealously split lines * Favour find(1) calls over shell loops * Use `ln -fs` (both flags are POSIX) * Remove filename duplication for `cp -p` calls --- Makefile | 91 +++++++++++++++++++++------------------------------------------- 1 file changed, 30 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 96f93ed1..24c3fab5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ .POSIX: + .PHONY: all \ clean \ distclean \ @@ -109,7 +110,7 @@ GAMES = games/acq \ all: $(BINS) git/gitconfig gnupg/gpg.conf clean distclean: - rm -f \ + rm -f -- \ $(BINS) \ $(GAMES) \ git/gitconfig \ @@ -129,9 +130,7 @@ git/gitconfig: git/gitconfig.m4 KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf: gnupg/gpg.conf.m4 - m4 \ - -D DF_HOME=$(HOME) \ - -D DF_KEYSERVER=$(KEYSERVER) \ + m4 -D DF_HOME=$(HOME) -D DF_KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > $@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header @@ -176,35 +175,28 @@ install: install-bash \ install-vim install-abook: - mkdir -p -- \ - $(HOME)/.abook + mkdir -p -- $(HOME)/.abook cp -p -- abook/abookrc $(HOME)/.abook install-bash: check-bash install-sh - mkdir -p -- \ - $(HOME)/.config \ - $(HOME)/.bashrc.d + mkdir -p -- $(HOME)/.bashrc.d cp -p -- bash/bashrc $(HOME)/.bashrc cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d cp -p -- bash/bash_profile $(HOME)/.bash_profile cp -p -- bash/bash_logout $(HOME)/.bash_logout install-bash-completion: install-bash - mkdir -p -- $(HOME)/.bash_completion.d - cp -p -- bash/bash_completion $(HOME)/.config/bash_completion + mkdir -p -- $(HOME)/.bash_completion.d $(HOME)/.config + cp -p -- bash/bash_completion $(HOME)/.config cp -p -- bash/bash_completion.d/* $(HOME)/.bash_completion.d install-bin: $(BINS) install-bin-man mkdir -p -- $(HOME)/.local/bin - for name in bin/* ; do \ - [ -x "$$name" ] || continue ; \ - cp -p -- "$$name" $(HOME)/.local/bin ; \ - done + find bin -type f -perm -u=x \ + -exec cp -p -- {} $(HOME)/.local/bin \; install-bin-man: - mkdir -p -- \ - $(HOME)/.local/share/man/man1 \ - $(HOME)/.local/share/man/man8 + mkdir -p -- $(HOME)/.local/share/man/man1 $(HOME)/.local/share/man/man8 cp -p -- man/man1/*.1df $(HOME)/.local/share/man/man1 cp -p -- man/man8/*.8df $(HOME)/.local/share/man/man8 @@ -229,10 +221,8 @@ install-finger: install-games: $(GAMES) install-games-man mkdir -p -- $(HOME)/.local/games - for name in games/* ; do \ - [ -x "$$name" ] || continue ; \ - cp -p -- "$$name" $(HOME)/.local/games ; \ - done + find games -type f -perm -u=x \ + -exec cp -p -- {} $(HOME)/.local/games \; install-games-man: mkdir -p -- $(HOME)/.local/share/man/man6 @@ -242,16 +232,12 @@ install-git: git/gitconfig cp -p -- git/gitconfig $(HOME)/.gitconfig install-gnupg: gnupg/gpg.conf - mkdir -m 0700 -p -- \ - $(HOME)/.gnupg \ - $(HOME)/.gnupg/sks-keyservers.net + mkdir -m 0700 -p -- $(HOME)/.gnupg $(HOME)/.gnupg/sks-keyservers.net cp -p -- gnupg/*.conf $(HOME)/.gnupg - cp -p -- gnupg/sks-keyservers.net/* \ - $(HOME)/.gnupg/sks-keyservers.net + cp -p -- gnupg/sks-keyservers.net/* $(HOME)/.gnupg/sks-keyservers.net install-gtk: - mkdir -p -- \ - $(HOME)/.config/gtkrc-3.0 + mkdir -p -- $(HOME)/.config/gtkrc-3.0 cp -p -- gtk/gtkrc-2.0 $(HOME)/.gtkrc-2.0 cp -p -- gtk/gtkrc-3.0/settings.ini $(HOME)/.config/gtkrc-3.0 @@ -264,29 +250,23 @@ install-less: command -v lesskey && lesskey install-mutt: - mkdir -p -- \ - $(HOME)/.muttrc.d \ - $(HOME)/.cache/mutt + mkdir -p -- $(HOME)/.muttrc.d $(HOME)/.cache/mutt cp -p -- mutt/muttrc $(HOME)/.muttrc cp -p -- mutt/muttrc.d/src $(HOME)/.muttrc.d install-ncmcpp: mkdir -p -- $(HOME)/.ncmpcpp - cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp/config + cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp install-newsbeuter: - mkdir -p -- \ - $(HOME)/.config/newsbeuter \ - $(HOME)/.local/share/newsbeuter - cp -p -- newsbeuter/config $(HOME)/.config/newsbeuter/config + mkdir -p -- $(HOME)/.config/newsbeuter $(HOME)/.local/share/newsbeuter + cp -p -- newsbeuter/config $(HOME)/.config/newsbeuter install-mysql: cp -p -- mysql/my.cnf $(HOME)/.my.cnf install-ksh: check-ksh install-sh - mkdir -p -- \ - $(HOME)/.shrc.d \ - $(HOME)/.kshrc.d + mkdir -p -- $(HOME)/.shrc.d $(HOME)/.kshrc.d cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d cp -p -- ksh/kshrc $(HOME)/.kshrc cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d @@ -304,9 +284,7 @@ install-readline: cp -p -- readline/inputrc $(HOME)/.inputrc install-sh: check-sh - mkdir -p -- \ - $(HOME)/.profile.d \ - $(HOME)/.shrc.d + mkdir -p -- $(HOME)/.profile.d $(HOME)/.shrc.d cp -p -- sh/profile $(HOME)/.profile cp -p -- sh/profile.d/* $(HOME)/.profile.d cp -p -- sh/shinit $(HOME)/.shinit @@ -315,24 +293,19 @@ install-sh: check-sh install-subversion: mkdir -p -- $(HOME)/.subversion - cp -p -- subversion/config $(HOME)/.subversion/config + cp -p -- subversion/config $(HOME)/.subversion install-terminfo: - for info in terminfo/*.info ; do \ - tic -- "$$info" ; \ - done + find terminfo -type f -name '*.info' \ + -exec tic -- {} \; install-tmux: tmux/tmux.conf install-terminfo cp -p -- tmux/tmux.conf $(HOME)/.tmux.conf install-urxvt: urxvt/ext/select check-urxvt mkdir -p -- $(HOME)/.urxvt/ext - for name in urxvt/ext/* ; do \ - case $$name in \ - *.pl) ;; \ - *) cp -p -- "$$name" $(HOME)/.urxvt/ext ;; \ - esac \ - done + find urxvt/ext -type f ! -name '*.pl' \ + -exec cp -p -- {} $(HOME)/.urxvt/ext \; install-vim: install-vim-config \ install-vim-plugins \ @@ -356,9 +329,7 @@ install-vim-plugins: install-vim-config install-vim-pathogen: install-vim-plugins mkdir -p -- $(HOME)/.vim/autoload - rm -f -- $(HOME)/.vim/autoload/pathogen.vim - ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ - $(HOME)/.vim/autoload/pathogen.vim + ln -fs -- ../bundle/pathogen/autoload/pathogen.vim $(HOME)/.vim/autoload install-x: mkdir -p -- \ @@ -366,8 +337,8 @@ install-x: $(HOME)/.config/sxhkdrc \ $(HOME)/.xinitrc.d \ $(HOME)/.Xresources.d - cp -p -- X/redshift.conf $(HOME)/.config/redshift.conf - cp -p -- X/sxhkdrc $(HOME)/.config/sxhkd/sxhkdrc + cp -p -- X/redshift.conf $(HOME)/.config + cp -p -- X/sxhkdrc $(HOME)/.config/sxhkd cp -p -- X/xinitrc $(HOME)/.xinitrc cp -p -- X/xinitrc.d/* $(HOME)/.xinitrc.d cp -p -- X/Xresources $(HOME)/.Xresources @@ -380,9 +351,7 @@ install-yash: check-yash install-sh cp -p -- yash/yashrc.d/* $(HOME)/.yashrc.d install-zsh: check-zsh install-sh - mkdir -p -- \ - $(HOME)/.profile.d \ - $(HOME)/.zshrc.d + mkdir -p -- $(HOME)/.profile.d $(HOME)/.zshrc.d cp -p -- zsh/profile.d/* $(HOME)/.profile.d cp -p -- zsh/zprofile $(HOME)/.zprofile cp -p -- zsh/zshrc $(HOME)/.zshrc -- cgit v1.2.3 From 89f185d62638c682fc363d4747d8cef9c7f39fd5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 11:10:10 +1300 Subject: Remove double-up colon check in path() --- sh/shrc.d/path.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 2759e11f..79b48fd5 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -1,14 +1,6 @@ # Function to manage contents of PATH variable within the current shell path() { - # The second argument, the directory, can never have a colon - case $2 in - *:*) - printf >&2 'path(): %s illegal colon\n' "$2" - return 2 - ;; - esac - # Check first argument to figure out operation case $1 in -- cgit v1.2.3 From 2e28d5a885608fddd1e0b7464ba3c9582a9e8ca4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 14:02:59 +1300 Subject: Add exm(1df) to work around Vim's screen-clearing --- README.markdown | 1 + bin/exm | 10 ++++++++++ man/man1/exm.1df | 22 ++++++++++++++++++++++ sh/profile.d/editor.sh | 11 ++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 bin/exm create mode 100644 man/man1/exm.1df diff --git a/README.markdown b/README.markdown index 4cd4820c..8b95e1a9 100644 --- a/README.markdown +++ b/README.markdown @@ -469,6 +469,7 @@ Installed by the `install-bin` target: any options, mostly useful for scripts. * `eds(1df)` edits executable script files in `EDSPATH`, defaulting to `~/.local/bin`, for personal scripting snippets. +* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. * `finc(1df)` counts the number of results returned from a set of given `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary diff --git a/bin/exm b/bin/exm new file mode 100755 index 00000000..cfae82d4 --- /dev/null +++ b/bin/exm @@ -0,0 +1,10 @@ +#!/bin/sh +# If input is a terminal and ex(1) is the Vim version, force it to use a dumb +# terminal so it doesn't clear the screen +if [ -t 0 ] ; then + ver=$(ex --version | sed '1{s/ .*//;q}') 2>/dev/null + case $ver in + VIM) set -- -T builtin_dumb "$@" ;; + esac +fi +exec ex "$@" diff --git a/man/man1/exm.1df b/man/man1/exm.1df new file mode 100644 index 00000000..892ca326 --- /dev/null +++ b/man/man1/exm.1df @@ -0,0 +1,22 @@ +.TH EXM 1df "March 2017" "Manual page for exm" +.SH NAME +.B exm +\- invoke Vim's ex(1) with a dumb terminal +.SH SYNOPSIS +.B exm +[EX_OPTIONS...] [FILES] +.SH DESCRIPTION +.B exm +works around a quirk of Vim that causes it to clear the screen when invoked as +ex(1) interactively. It applies Vim's -T option to force the terminal to the +builtin "dumb" terminal. +.SH CAVEATS +This doesn't work on its first invocation from any given terminal, but does +work thereafter. I haven't yet figured out why. +.P +This breaks switching to visual mode with :visual somewhat, as the terminal +will persist in its dumb state. I'm not sure there's a way to fix this. If +there were a Vim :autocmd for mode switching, it might be possible, or perhaps +by wrapping :visual somehow to :set terminal=$TERM. +.SH AUTHOR +Tom Ryder diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh index 5d6b249e..307879fe 100644 --- a/sh/profile.d/editor.sh +++ b/sh/profile.d/editor.sh @@ -1,7 +1,16 @@ -# Set command-line editor; ed if we've got it (!), but ex will do fine +# Ideally, we'd use plain old ed(1), but many Linux distributions don't install +# it by default if command -v ed >/dev/null 2>&1 ; then EDITOR=ed + +# Failing that, if we have both vim(1) and exm(1df) in our $PATH, use the +# latter to work around Vim's ex mode screen-clearing +elif { command -v vim && command -v exm ; } >/dev/null 2>&1 ; then + EDITOR=exm + +# Otherwise, just call ex(1) directly else EDITOR=ex fi + export EDITOR -- cgit v1.2.3 From ebda819bd699ebc75d3ff37561c18023e8ac0165 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:01:33 +1300 Subject: Better exm(1df) implementation --- bin/exm | 7 ++++--- man/man1/exm.1df | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bin/exm b/bin/exm index cfae82d4..7f4b4de0 100755 --- a/bin/exm +++ b/bin/exm @@ -1,10 +1,11 @@ #!/bin/sh -# If input is a terminal and ex(1) is the Vim version, force it to use a dumb -# terminal so it doesn't clear the screen +# Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then ver=$(ex --version | sed '1{s/ .*//;q}') 2>/dev/null case $ver in - VIM) set -- -T builtin_dumb "$@" ;; + # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" + # feature is invoked with a newline character. + VIM) set -- -T dumb -c 'exe "set t_cm=\"' "$@" ;; esac fi exec ex "$@" diff --git a/man/man1/exm.1df b/man/man1/exm.1df index 892ca326..7a68a031 100644 --- a/man/man1/exm.1df +++ b/man/man1/exm.1df @@ -11,12 +11,9 @@ works around a quirk of Vim that causes it to clear the screen when invoked as ex(1) interactively. It applies Vim's -T option to force the terminal to the builtin "dumb" terminal. .SH CAVEATS -This doesn't work on its first invocation from any given terminal, but does -work thereafter. I haven't yet figured out why. -.P -This breaks switching to visual mode with :visual somewhat, as the terminal +This breaks switching to visual mode with :visual completely, as the terminal will persist in its dumb state. I'm not sure there's a way to fix this. If there were a Vim :autocmd for mode switching, it might be possible, or perhaps -by wrapping :visual somehow to :set terminal=$TERM. +by wrapping :visual somehow to :set terminal=$TERM before the switch. .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 80060a5f66f6da4ecd4b73f34bd83b328e666fc8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:31:54 +1300 Subject: Replace -c with --cmd in exm(1df) This appears to do it, at least on Vim 8 --- bin/exm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/exm b/bin/exm index 7f4b4de0..4b2afbda 100755 --- a/bin/exm +++ b/bin/exm @@ -5,7 +5,7 @@ if [ -t 0 ] ; then case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" # feature is invoked with a newline character. - VIM) set -- -T dumb -c 'exe "set t_cm=\"' "$@" ;; + VIM) set -- -T dumb --cmd 'exe "set t_cm=\"' "$@" ;; esac fi exec ex "$@" -- cgit v1.2.3 From 1d053c5713b0adef23847529692ce63f6cf92d8b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:34:07 +1300 Subject: Add a semicolon to appease old sed(1) --- bin/exm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/exm b/bin/exm index 4b2afbda..3850f118 100755 --- a/bin/exm +++ b/bin/exm @@ -1,7 +1,7 @@ #!/bin/sh # Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then - ver=$(ex --version | sed '1{s/ .*//;q}') 2>/dev/null + ver=$(ex --version | sed '1{s/ .*//;q;}') 2>/dev/null case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" # feature is invoked with a newline character. -- cgit v1.2.3 From 29930411138761742bfc289b4eab5c6d49d7672d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:36:13 +1300 Subject: Move stderr block to within subst --- bin/exm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/exm b/bin/exm index 3850f118..f18da08b 100755 --- a/bin/exm +++ b/bin/exm @@ -1,7 +1,7 @@ #!/bin/sh # Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then - ver=$(ex --version | sed '1{s/ .*//;q;}') 2>/dev/null + ver=$(ex --version | sed '1{s/ .*//;q;}' 2>/dev/null) case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" # feature is invoked with a newline character. -- cgit v1.2.3 From 25d7fce47f1841c9dfabc05f4720c4c2b325f85b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:38:58 +1300 Subject: Move redirect to correct process --- bin/exm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/exm b/bin/exm index f18da08b..4631c8fa 100755 --- a/bin/exm +++ b/bin/exm @@ -1,7 +1,7 @@ #!/bin/sh # Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then - ver=$(ex --version | sed '1{s/ .*//;q;}' 2>/dev/null) + ver=$(ex --version 2>/dev/null | sed '1{s/ .*//;q;}') case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" # feature is invoked with a newline character. -- cgit v1.2.3 From c1d9384b36ff86a1bd48fe4e8433326a5300390a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:55:57 +1300 Subject: This version works on vim.tiny --- bin/exm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/exm b/bin/exm index 4631c8fa..3f4b4c1b 100755 --- a/bin/exm +++ b/bin/exm @@ -4,8 +4,10 @@ if [ -t 0 ] ; then ver=$(ex --version 2>/dev/null | sed '1{s/ .*//;q;}') case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" - # feature is invoked with a newline character. - VIM) set -- -T dumb --cmd 'exe "set t_cm=\"' "$@" ;; + # feature is invoked with a carriage return. + VIM) + cmd=$(printf 'set t_cm=\r|') + set -- -T dumb --cmd "${cmd%|}" "$@" ;; esac fi exec ex "$@" -- cgit v1.2.3 From ec9a14c023404eaf85be3a877ba5f7121ee39abc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 Mar 2017 15:58:46 +1300 Subject: Remove lie --- man/man1/exm.1df | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/man1/exm.1df b/man/man1/exm.1df index 7a68a031..25b3cf4a 100644 --- a/man/man1/exm.1df +++ b/man/man1/exm.1df @@ -8,8 +8,8 @@ .SH DESCRIPTION .B exm works around a quirk of Vim that causes it to clear the screen when invoked as -ex(1) interactively. It applies Vim's -T option to force the terminal to the -builtin "dumb" terminal. +ex(1) interactively. It applies Vim's -T option to force the terminal to a +"dumb" terminal. .SH CAVEATS This breaks switching to visual mode with :visual completely, as the terminal will persist in its dumb state. I'm not sure there's a way to fix this. If -- cgit v1.2.3 From 9a522521d552f42b222aca880d75c7f8efa60823 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Mar 2017 01:00:05 +1300 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index f8b2d4bd..050335f8 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit f8b2d4bd21ea73ebe8eaa3e9f9bdc1b42d1b7b4c +Subproject commit 050335f848d57cb1c59bffe6f32f901307b7e504 -- cgit v1.2.3 From 162f108b44470d34d2dec149b295c6d2a8356d6d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Mar 2017 10:50:26 +1300 Subject: Add gt() (go to) --- README.markdown | 3 ++- sh/shrc.d/gt.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 sh/shrc.d/gt.sh diff --git a/README.markdown b/README.markdown index 8b95e1a9..874e0fc2 100644 --- a/README.markdown +++ b/README.markdown @@ -180,10 +180,11 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: * `gd()` goes to the marked directory. * `pmd()` prints the marked directory. * `xd()` swaps the current and marked directories. -* Nine other directory management and navigation functions: +* Ten other directory management and navigation functions: * `ad()` is a `cd` shortcut accepting targets like `/u/l/b` for `/usr/local/bin`, as long as they are unique. * `bd()` changes into a named ancestor of the current directory. + * `gt()` changes into a directory or into a file's directory. * `mkcd()` creates a directory and changes into it. * `pd()` changes to the argument's parent directory. * `rd()` replaces the first instance of its first argument with its diff --git a/sh/shrc.d/gt.sh b/sh/shrc.d/gt.sh new file mode 100644 index 00000000..d18a4ab8 --- /dev/null +++ b/sh/shrc.d/gt.sh @@ -0,0 +1,28 @@ +# If the argument is a directory, change to it. If it's a file, change to its +# parent. Stands for "get to". +gt() { + + # Check argument count + if [ "$#" -gt 1 ] ; then + printf >&2 'gd(): Too many arguments\n' + return 2 + fi + + # Strip trailing slash + set -- "${1%/}" + + # If target doesn't have a leading slash, add PWD prefix + case $1 in + /*) ;; + *) set -- "${PWD%/}"/"$1" + esac + + # If target isn't a directory, chop to its parent + [ -d "$1" ] || set -- "${1%/*}" + + # If target is now empty, go to the root + [ -n "$1" ] || set -- / + + # Try to change into the determined directory + command cd -- "$@" +} -- cgit v1.2.3 From ece8b924343c45cbb68c93917742dab523750975 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Mar 2017 10:58:42 +1300 Subject: Add lgt() --- README.markdown | 1 + sh/shrc.d/lgt.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sh/shrc.d/lgt.sh diff --git a/README.markdown b/README.markdown index 874e0fc2..43dddf0c 100644 --- a/README.markdown +++ b/README.markdown @@ -185,6 +185,7 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: `/usr/local/bin`, as long as they are unique. * `bd()` changes into a named ancestor of the current directory. * `gt()` changes into a directory or into a file's directory. + * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. * `mkcd()` creates a directory and changes into it. * `pd()` changes to the argument's parent directory. * `rd()` replaces the first instance of its first argument with its diff --git a/sh/shrc.d/lgt.sh b/sh/shrc.d/lgt.sh new file mode 100644 index 00000000..fbe43369 --- /dev/null +++ b/sh/shrc.d/lgt.sh @@ -0,0 +1,28 @@ +# Run loc(1df) with given arguments and then run gt() to get to the first +# argument found +lgt() { + + # Check argument count + if [ "$#" -eq 0 ] ; then + printf >&2 'lgt(): Need a search term\n' + return 2 + fi + + # Change the positional parameters from the loc(1df) arguments to the first + # result with a trailing slash + set -- "$( + loc "$@" | { + IFS= read -r target + printf '%s/' "$target" + } + )" + + # Strip the trailing slash + set -- "${1%/}" + + # If the subshell printed nothing, return with failure + [ -n "$1" ] || return + + # Run gt() with the new arguments + gt "$@" +} -- cgit v1.2.3 From 8427c06262a075820dc91133a2be242690197b85 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Mar 2017 15:12:39 +1300 Subject: Remove SC2154 ignore for $.sh from ksh startup --- ksh/shrc.d/ksh.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh index 6101fc84..aa5c4cbc 100644 --- a/ksh/shrc.d/ksh.sh +++ b/ksh/shrc.d/ksh.sh @@ -21,7 +21,6 @@ if [ -z "$KSH_VERSION" ] ; then # Test whether we have content in the .sh.version variable. Suppress errors # and run it in a subshell to work around parsing error precedence. - # shellcheck disable=SC2154 ( test -n "${.sh.version}" ) 2>/dev/null || return # If that peculiarly named variable was set, then that's our KSH_VERSION -- cgit v1.2.3 From 91aa4123f4c90b0176682a80e9dfe7d9b90bf553 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Mar 2017 15:19:44 +1300 Subject: Remove SC2030 ignore for path logic Can't find where this was fixed --- sh/shrc.d/path.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 79b48fd5..b6b1820f 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -6,7 +6,6 @@ path() { # List current directories in PATH list|'') ( - # shellcheck disable=SC2030 path=$PATH: while [ -n "$path" ] ; do dir=${path%%:*} -- cgit v1.2.3 From 04988a32bf5de10d25f0d421e0504e6d715f54af Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Mar 2017 20:04:42 +1300 Subject: Use awk for "get first word" A little clearer than the sed, if longer --- bin/exm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/exm b/bin/exm index 3f4b4c1b..f1afa17a 100755 --- a/bin/exm +++ b/bin/exm @@ -1,7 +1,7 @@ #!/bin/sh # Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then - ver=$(ex --version 2>/dev/null | sed '1{s/ .*//;q;}') + ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}') case $ver in # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" # feature is invoked with a carriage return. -- cgit v1.2.3 From 1e5d85545fb0b12bd81eb350b1a0e6521a31d484 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 30 Mar 2017 01:00:18 +1300 Subject: Update submodules --- vim/bundle/unimpaired | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired index 11dc568d..e9397719 160000 --- a/vim/bundle/unimpaired +++ b/vim/bundle/unimpaired @@ -1 +1 @@ -Subproject commit 11dc568dbfd7a56866a4354c737515769f08e9fe +Subproject commit e939771979393c502e2331fc7d44a963efd7bb46 -- cgit v1.2.3 From 3642ed5814cf0077163897964b8a168afa014089 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 30 Mar 2017 01:53:01 +1300 Subject: Remove resolved issue --- ISSUES.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index 9a2877d3..4c78a3f3 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -21,5 +21,3 @@ Known issues * Would be good to complete the Makefile variables for NAME, EMAIL etc with educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding my own stuff in there -* vim's implementation of ex clears the screen; would be good to find a way - to prevent that (preferably without something awful like `TERM=t100 ex`). -- cgit v1.2.3 From 843731cd282c3c8edd88ffae132466718be50a0a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 31 Mar 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 0a19c5aa..fcbe2d3e 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 0a19c5aaf985e064b2cfc30a348a235ba91b2570 +Subproject commit fcbe2d3eaf3ac1438da122e65badbf410d7990ef -- cgit v1.2.3 From 81f033d33b0df7af0243ff0b81ae5bc23e3dcbd4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 31 Mar 2017 09:06:40 +1300 Subject: Handle POSIX correctness in ~/.bash_profile --- bash/bash_profile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bash/bash_profile b/bash/bash_profile index a520f051..0376ee57 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -1,6 +1,13 @@ # Load ~/.profile regardless of shell version [ -e "$HOME"/.profile ] && . "$HOME"/.profile +# If POSIXLY_CORRECT is set after doing that, force the `posix` option on and +# don't load the rest of this stuff--so, just ~/.profile and ENV +if [ -n "$POSIXLY_CORRECT" ] ; then + set -o posix + return +fi + # If ~/.bashrc exists, source that too; the tests for both interactivity and # >=2.05a (for features like [[) are in there [ -f "$HOME"/.bashrc ] && . "$HOME"/.bashrc -- cgit v1.2.3 From c8ab406749124d2e762ad5cf53963070113afd0f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 20:06:39 +1200 Subject: Apply runtime shebanging to POSIX shell --- .gitignore | 88 ++++++++++++++++++++++++++++++++++++++++++++- Makefile | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++----- README.markdown | 5 ++- bin/ap | 34 ------------------ bin/ap.sh | 33 +++++++++++++++++ bin/apf | 63 -------------------------------- bin/apf.sh | 62 ++++++++++++++++++++++++++++++++ bin/ax | 28 --------------- bin/ax.sh | 27 ++++++++++++++ bin/bcq | 4 --- bin/bcq.sh | 3 ++ bin/bel | 3 -- bin/bel.sh | 2 ++ bin/bl | 11 ------ bin/bl.sh | 10 ++++++ bin/bp | 3 -- bin/bp.sh | 2 ++ bin/br | 3 -- bin/br.sh | 2 ++ bin/ca | 3 -- bin/ca.sh | 2 ++ bin/cf | 25 ------------- bin/cf.sh | 24 +++++++++++++ bin/cfr | 25 ------------- bin/cfr.sh | 24 +++++++++++++ bin/chc | 31 ---------------- bin/chc.sh | 30 ++++++++++++++++ bin/chn | 70 ------------------------------------ bin/chn.sh | 69 +++++++++++++++++++++++++++++++++++ bin/clog | 10 ------ bin/clog.sh | 9 +++++ bin/clrd | 16 --------- bin/clrd.sh | 15 ++++++++ bin/clwr | 24 ------------- bin/clwr.sh | 23 ++++++++++++ bin/d2u | 26 -------------- bin/d2u.sh | 25 +++++++++++++ bin/dmp | 31 ---------------- bin/dmp.sh | 30 ++++++++++++++++ bin/dub | 32 ----------------- bin/dub.sh | 31 ++++++++++++++++ bin/edda | 34 ------------------ bin/edda.sh | 33 +++++++++++++++++ bin/eds | 51 -------------------------- bin/eds.sh | 50 ++++++++++++++++++++++++++ bin/exm | 13 ------- bin/exm.sh | 12 +++++++ bin/fgscr | 9 ----- bin/fgscr.sh | 8 +++++ bin/finc | 3 -- bin/finc.sh | 2 ++ bin/fnl | 21 ----------- bin/fnl.sh | 20 +++++++++++ bin/gms | 31 ---------------- bin/gms.sh | 30 ++++++++++++++++ bin/grc | 16 --------- bin/grc.sh | 15 ++++++++ bin/gscr | 29 --------------- bin/gscr.sh | 28 +++++++++++++++ bin/hurl | 11 ------ bin/hurl.sh | 10 ++++++ bin/igex | 34 ------------------ bin/igex.sh | 33 +++++++++++++++++ bin/isgr | 13 ------- bin/isgr.sh | 12 +++++++ bin/ix | 4 --- bin/ix.sh | 3 ++ bin/jfc | 14 -------- bin/jfc.sh | 13 +++++++ bin/jfcd | 23 ------------ bin/jfcd.sh | 22 ++++++++++++ bin/loc | 19 ---------- bin/loc.sh | 18 ++++++++++ bin/maybe | 24 ------------- bin/maybe.sh | 23 ++++++++++++ bin/mex | 53 --------------------------- bin/mex.sh | 52 +++++++++++++++++++++++++++ bin/mkcp | 18 ---------- bin/mkcp.sh | 17 +++++++++ bin/mkmv | 18 ---------- bin/mkmv.sh | 17 +++++++++ bin/mktd | 12 ------- bin/mktd.sh | 11 ++++++ bin/motd | 5 --- bin/motd.sh | 4 +++ bin/murl | 6 ---- bin/murl.sh | 5 +++ bin/osc | 92 ----------------------------------------------- bin/osc.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++ bin/pa | 4 --- bin/pa.sh | 3 ++ bin/paz | 4 --- bin/paz.sh | 3 ++ bin/pit | 17 --------- bin/pit.sh | 16 +++++++++ bin/plmu | 23 ------------ bin/plmu.sh | 22 ++++++++++++ bin/pp | 9 ----- bin/pp.sh | 8 +++++ bin/pph | 5 --- bin/pph.sh | 4 +++ bin/pwg | 7 ---- bin/pwg.sh | 6 ++++ bin/rfcf | 13 ------- bin/rfcf.sh | 12 +++++++ bin/rfcr | 19 ---------- bin/rfcr.sh | 18 ++++++++++ bin/rgl | 35 ------------------ bin/rgl.sh | 34 ++++++++++++++++++ bin/rnda | 20 ----------- bin/rnda.sh | 19 ++++++++++ bin/rndf | 18 ---------- bin/rndf.sh | 17 +++++++++ bin/rndl | 51 -------------------------- bin/rndl.sh | 50 ++++++++++++++++++++++++++ bin/rnds | 22 ------------ bin/rnds.sh | 21 +++++++++++ bin/shb | 27 -------------- bin/shb.sh | 26 ++++++++++++++ bin/slow | 4 --- bin/slow.sh | 3 ++ bin/sls | 20 ----------- bin/sls.sh | 19 ++++++++++ bin/sqs | 34 ------------------ bin/sqs.sh | 33 +++++++++++++++++ bin/sra | 8 ----- bin/sra.sh | 7 ++++ bin/sshi | 28 --------------- bin/sshi.sh | 27 ++++++++++++++ bin/sta | 8 ----- bin/sta.sh | 7 ++++ bin/stbl | 19 ---------- bin/stbl.sh | 18 ++++++++++ bin/stex | 39 -------------------- bin/stex.sh | 38 ++++++++++++++++++++ bin/stws | 19 ---------- bin/stws.sh | 18 ++++++++++ bin/sue | 27 -------------- bin/sue.sh | 26 ++++++++++++++ bin/supp | 4 --- bin/supp.sh | 3 ++ bin/swr | 65 --------------------------------- bin/swr.sh | 64 +++++++++++++++++++++++++++++++++ bin/td | 32 ----------------- bin/td.sh | 31 ++++++++++++++++ bin/tl | 29 --------------- bin/tl.sh | 28 +++++++++++++++ bin/tlcs | 94 ------------------------------------------------ bin/tlcs.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++++ bin/tm | 18 ---------- bin/tm.sh | 17 +++++++++ bin/try | 78 ---------------------------------------- bin/try.sh | 77 +++++++++++++++++++++++++++++++++++++++ bin/u2d | 27 -------------- bin/u2d.sh | 26 ++++++++++++++ bin/umake | 11 ------ bin/umake.sh | 10 ++++++ bin/urlc | 77 --------------------------------------- bin/urlc.sh | 76 +++++++++++++++++++++++++++++++++++++++ bin/urlh | 30 ---------------- bin/urlh.sh | 29 +++++++++++++++ bin/urlmt | 9 ----- bin/urlmt.sh | 8 +++++ bin/vest | 7 ---- bin/vest.sh | 6 ++++ bin/vex | 14 -------- bin/vex.sh | 13 +++++++ bin/wro | 31 ---------------- bin/wro.sh | 30 ++++++++++++++++ bin/xgo | 79 ---------------------------------------- bin/xgo.sh | 78 ++++++++++++++++++++++++++++++++++++++++ bin/xgoc | 3 -- bin/xgoc.sh | 2 ++ bin/xrbg | 4 --- bin/xrbg.sh | 3 ++ games/aaf | 3 -- games/aaf.sh | 3 ++ games/dr | 36 ------------------- games/dr.sh | 36 +++++++++++++++++++ games/rndn | 43 ---------------------- games/rndn.sh | 43 ++++++++++++++++++++++ games/xyzzy | 6 ---- games/xyzzy.sh | 6 ++++ lint/bin | 11 +----- lint/games | 11 +----- 185 files changed, 2284 insertions(+), 2205 deletions(-) delete mode 100755 bin/ap create mode 100644 bin/ap.sh delete mode 100755 bin/apf create mode 100644 bin/apf.sh delete mode 100755 bin/ax create mode 100644 bin/ax.sh delete mode 100755 bin/bcq create mode 100644 bin/bcq.sh delete mode 100755 bin/bel create mode 100644 bin/bel.sh delete mode 100755 bin/bl create mode 100644 bin/bl.sh delete mode 100755 bin/bp create mode 100644 bin/bp.sh delete mode 100755 bin/br create mode 100644 bin/br.sh delete mode 100755 bin/ca create mode 100644 bin/ca.sh delete mode 100755 bin/cf create mode 100644 bin/cf.sh delete mode 100755 bin/cfr create mode 100644 bin/cfr.sh delete mode 100755 bin/chc create mode 100644 bin/chc.sh delete mode 100755 bin/chn create mode 100644 bin/chn.sh delete mode 100755 bin/clog create mode 100644 bin/clog.sh delete mode 100755 bin/clrd create mode 100644 bin/clrd.sh delete mode 100755 bin/clwr create mode 100644 bin/clwr.sh delete mode 100755 bin/d2u create mode 100644 bin/d2u.sh delete mode 100755 bin/dmp create mode 100644 bin/dmp.sh delete mode 100755 bin/dub create mode 100644 bin/dub.sh delete mode 100755 bin/edda create mode 100644 bin/edda.sh delete mode 100755 bin/eds create mode 100644 bin/eds.sh delete mode 100755 bin/exm create mode 100644 bin/exm.sh delete mode 100755 bin/fgscr create mode 100644 bin/fgscr.sh delete mode 100755 bin/finc create mode 100644 bin/finc.sh delete mode 100755 bin/fnl create mode 100644 bin/fnl.sh delete mode 100755 bin/gms create mode 100644 bin/gms.sh delete mode 100755 bin/grc create mode 100644 bin/grc.sh delete mode 100755 bin/gscr create mode 100644 bin/gscr.sh delete mode 100755 bin/hurl create mode 100644 bin/hurl.sh delete mode 100755 bin/igex create mode 100644 bin/igex.sh delete mode 100755 bin/isgr create mode 100644 bin/isgr.sh delete mode 100755 bin/ix create mode 100644 bin/ix.sh delete mode 100755 bin/jfc create mode 100644 bin/jfc.sh delete mode 100755 bin/jfcd create mode 100644 bin/jfcd.sh delete mode 100755 bin/loc create mode 100644 bin/loc.sh delete mode 100755 bin/maybe create mode 100644 bin/maybe.sh delete mode 100755 bin/mex create mode 100644 bin/mex.sh delete mode 100755 bin/mkcp create mode 100644 bin/mkcp.sh delete mode 100755 bin/mkmv create mode 100644 bin/mkmv.sh delete mode 100755 bin/mktd create mode 100644 bin/mktd.sh delete mode 100755 bin/motd create mode 100644 bin/motd.sh delete mode 100755 bin/murl create mode 100644 bin/murl.sh delete mode 100755 bin/osc create mode 100644 bin/osc.sh delete mode 100755 bin/pa create mode 100644 bin/pa.sh delete mode 100755 bin/paz create mode 100644 bin/paz.sh delete mode 100755 bin/pit create mode 100644 bin/pit.sh delete mode 100755 bin/plmu create mode 100644 bin/plmu.sh delete mode 100755 bin/pp create mode 100644 bin/pp.sh delete mode 100755 bin/pph create mode 100644 bin/pph.sh delete mode 100755 bin/pwg create mode 100644 bin/pwg.sh delete mode 100755 bin/rfcf create mode 100644 bin/rfcf.sh delete mode 100755 bin/rfcr create mode 100644 bin/rfcr.sh delete mode 100755 bin/rgl create mode 100644 bin/rgl.sh delete mode 100755 bin/rnda create mode 100644 bin/rnda.sh delete mode 100755 bin/rndf create mode 100644 bin/rndf.sh delete mode 100755 bin/rndl create mode 100644 bin/rndl.sh delete mode 100755 bin/rnds create mode 100644 bin/rnds.sh delete mode 100755 bin/shb create mode 100644 bin/shb.sh delete mode 100755 bin/slow create mode 100644 bin/slow.sh delete mode 100755 bin/sls create mode 100644 bin/sls.sh delete mode 100755 bin/sqs create mode 100644 bin/sqs.sh delete mode 100755 bin/sra create mode 100644 bin/sra.sh delete mode 100755 bin/sshi create mode 100644 bin/sshi.sh delete mode 100755 bin/sta create mode 100644 bin/sta.sh delete mode 100755 bin/stbl create mode 100644 bin/stbl.sh delete mode 100755 bin/stex create mode 100644 bin/stex.sh delete mode 100755 bin/stws create mode 100644 bin/stws.sh delete mode 100755 bin/sue create mode 100644 bin/sue.sh delete mode 100755 bin/supp create mode 100644 bin/supp.sh delete mode 100755 bin/swr create mode 100644 bin/swr.sh delete mode 100755 bin/td create mode 100644 bin/td.sh delete mode 100755 bin/tl create mode 100644 bin/tl.sh delete mode 100755 bin/tlcs create mode 100644 bin/tlcs.sh delete mode 100755 bin/tm create mode 100644 bin/tm.sh delete mode 100755 bin/try create mode 100644 bin/try.sh delete mode 100755 bin/u2d create mode 100644 bin/u2d.sh delete mode 100755 bin/umake create mode 100644 bin/umake.sh delete mode 100755 bin/urlc create mode 100644 bin/urlc.sh delete mode 100755 bin/urlh create mode 100644 bin/urlh.sh delete mode 100755 bin/urlmt create mode 100644 bin/urlmt.sh delete mode 100755 bin/vest create mode 100644 bin/vest.sh delete mode 100755 bin/vex create mode 100644 bin/vex.sh delete mode 100755 bin/wro create mode 100644 bin/wro.sh delete mode 100755 bin/xgo create mode 100644 bin/xgo.sh delete mode 100755 bin/xgoc create mode 100644 bin/xgoc.sh delete mode 100755 bin/xrbg create mode 100644 bin/xrbg.sh delete mode 100755 games/aaf create mode 100644 games/aaf.sh delete mode 100755 games/dr create mode 100644 games/dr.sh delete mode 100755 games/rndn create mode 100644 games/rndn.sh delete mode 100755 games/xyzzy create mode 100644 games/xyzzy.sh diff --git a/.gitignore b/.gitignore index 8ccf6b5f..ca6f199b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,117 @@ +bin/ap +bin/apf +bin/ax +bin/bcq +bin/bel +bin/bl +bin/bp +bin/br bin/brnl +bin/ca +bin/cf +bin/cfr +bin/chc +bin/chn +bin/clog +bin/clrd +bin/clwr bin/csmw +bin/d2u bin/ddup +bin/dmp +bin/dub +bin/edda +bin/eds +bin/exm +bin/fgscr +bin/finc +bin/fnl +bin/gms +bin/grc +bin/gscr bin/gwp -bin/jfp bin/han bin/hms bin/htdec bin/htenc bin/htref +bin/hurl +bin/igex +bin/isgr +bin/ix +bin/jfc +bin/jfcd +bin/jfp +bin/loc bin/max +bin/maybe bin/mean bin/med +bin/mex bin/mftl bin/min +bin/mkcp +bin/mkmv +bin/mktd bin/mode +bin/motd +bin/murl bin/nlbr bin/onl +bin/osc +bin/pa +bin/paz +bin/pit +bin/plmu +bin/pp +bin/pph +bin/pwg bin/quo +bin/rfcf +bin/rfcr bin/rfct +bin/rgl +bin/rnda +bin/rndf bin/rndi +bin/rndl +bin/rnds bin/sd2u bin/sec +bin/shb +bin/slow +bin/sls bin/slsf +bin/sqs +bin/sra +bin/sshi +bin/sta +bin/stbl +bin/stex +bin/stws bin/su2d +bin/sue +bin/supp +bin/swr +bin/td +bin/tl +bin/tlcs +bin/tm bin/tot +bin/try +bin/u2d +bin/umake bin/unf +bin/urlc +bin/urlh +bin/urlmt bin/uts +bin/vest +bin/vex +bin/wro +bin/xgo +bin/xgoc +bin/xrbg bin/xrq games/acq games/aesth diff --git a/Makefile b/Makefile index 24c3fab5..7dc69c2e 100644 --- a/Makefile +++ b/Makefile @@ -68,43 +68,133 @@ EMAIL = tom@sanctum.geek.nz KEY = 0xC14286EA77BB8872 SENDMAIL = msmtp -BINS = bin/brnl \ +BINS = bin/ap \ + bin/apf \ + bin/ax \ + bin/bcq \ + bin/bel \ + bin/bl \ + bin/bp \ + bin/br \ + bin/brnl \ + bin/ca \ + bin/cf \ + bin/cfr \ + bin/chc \ + bin/chn \ + bin/clog \ + bin/clrd \ + bin/clwr \ bin/csmw \ + bin/d2u \ bin/ddup \ + bin/dmp \ + bin/dub \ + bin/edda \ + bin/eds \ + bin/exm \ + bin/fgscr \ + bin/finc \ + bin/fnl \ + bin/gms \ + bin/grc \ + bin/gscr \ bin/gwp \ bin/han \ bin/hms \ bin/htdec \ bin/htenc \ bin/htref \ + bin/hurl \ + bin/igex \ + bin/isgr \ + bin/ix \ + bin/jfc \ + bin/jfcd \ bin/jfp \ + bin/loc \ bin/max \ + bin/maybe \ bin/mean \ bin/med \ + bin/mex \ bin/mftl \ bin/min \ + bin/mkcp \ + bin/mkmv \ + bin/mktd \ bin/mode \ + bin/motd \ + bin/murl \ bin/nlbr \ bin/onl \ + bin/osc \ + bin/pa \ + bin/paz \ + bin/pit \ + bin/plmu \ + bin/pp \ + bin/pph \ + bin/pwg \ bin/quo \ + bin/rfcf \ + bin/rfcr \ bin/rfct \ + bin/rgl \ + bin/rnda \ + bin/rndf \ bin/rndi \ + bin/rndl \ + bin/rnds \ bin/sd2u \ bin/sec \ + bin/shb \ + bin/slow \ + bin/sls \ bin/slsf \ + bin/sqs \ + bin/sra \ + bin/sshi \ + bin/sta \ + bin/stbl \ + bin/stex \ + bin/stws \ bin/su2d \ + bin/sue \ + bin/supp \ + bin/swr \ + bin/td \ + bin/tl \ + bin/tlcs \ + bin/tm \ bin/tot \ + bin/try \ + bin/u2d \ + bin/umake \ bin/unf \ + bin/urlc \ + bin/urlh \ + bin/urlmt \ bin/uts \ + bin/vest \ + bin/vex \ + bin/wro \ + bin/xgo \ + bin/xgoc \ + bin/xrbg \ bin/xrq -GAMES = games/acq \ +GAMES = games/aaf \ + games/acq \ games/aesth \ games/chkl \ + games/dr \ games/drakon \ games/kvlt \ + games/rndn \ games/rot13 \ games/strik \ + games/xyzzy \ games/zs all: $(BINS) git/gitconfig gnupg/gpg.conf @@ -147,19 +237,23 @@ tmux/tmux.conf: tmux/tmux.conf.m4 tmux/tmux.conf.m4 > $@ .awk: - bin/shb awk -f < $< > $@ + sh bin/shb.sh awk -f < $< > $@ chmod +x ./$@ .bash: - bin/shb bash < $< > $@ + sh bin/shb.sh bash < $< > $@ chmod +x ./$@ .pl: - bin/shb perl < $< > $@ + sh bin/shb.sh perl < $< > $@ chmod +x ./$@ .sed: - bin/shb sed -f < $< > $@ + sh bin/shb.sh sed -f < $< > $@ + chmod +x ./$@ + +.sh: + sh bin/shb.sh sh < $< > $@ chmod +x ./$@ install: install-bash \ @@ -403,10 +497,10 @@ lint: check \ lint-bash: lint/bash -lint-bin: $(BINS) +lint-bin: lint/bin -lint-games: $(GAMES) +lint-games: lint/games lint-ksh: diff --git a/README.markdown b/README.markdown index 43dddf0c..8fd19dff 100644 --- a/README.markdown +++ b/README.markdown @@ -15,7 +15,10 @@ Installation $ make -n install $ make install -For the default `all` target, you'll need `bash(1)`, `make(1)`, and `m4(1)`. +For the default `all` target, you'll need `make(1)`, `m4(1)`, and a +POSIX-fearing `sh(1)`. If you're on a system where `/bin/sh` is not a POSIX +shell, you may need to check you have e.g. `/usr/xpg4/bin` at the front of your +`$PATH` at build time. The installation `Makefile` will overwrite things standing in the way of its installed files without backing them up, so read the output of `make -n diff --git a/bin/ap b/bin/ap deleted file mode 100755 index b6ee36d4..00000000 --- a/bin/ap +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Run a program with args read from standard input, prompted if from term -if [ "$#" -eq 0 ] ; then - printf >&2 'ap: Need at least one argument (command name)\n' - exit 2 -fi - -# Get the command name and shift it off -cmd=$1 -shift - -# Iterate through the remaining args; it's legal for there to be none, but in -# that case the user may as well just have invoked the command directly -for arg ; do - - # If this is the first iteration, clear the params away (we grabbed them in - # the for statement) - if [ -z "$reset" ] ; then - set -- - reset=1 - fi - - # If stdin is a terminal, prompt with the name of the argument - if [ -t 0 ] ; then - printf '%s: ' "$arg" - fi - - # Note that a whitespace or even empty argument is allowed - IFS= read -r val - set -- "$@" "$val" -done - -# Execute the command with the given parameters -exec "$cmd" "$@" diff --git a/bin/ap.sh b/bin/ap.sh new file mode 100644 index 00000000..1d6376cc --- /dev/null +++ b/bin/ap.sh @@ -0,0 +1,33 @@ +# Run a program with args read from standard input, prompted if from term +if [ "$#" -eq 0 ] ; then + printf >&2 'ap: Need at least one argument (command name)\n' + exit 2 +fi + +# Get the command name and shift it off +cmd=$1 +shift + +# Iterate through the remaining args; it's legal for there to be none, but in +# that case the user may as well just have invoked the command directly +for arg ; do + + # If this is the first iteration, clear the params away (we grabbed them in + # the for statement) + if [ -z "$reset" ] ; then + set -- + reset=1 + fi + + # If stdin is a terminal, prompt with the name of the argument + if [ -t 0 ] ; then + printf '%s: ' "$arg" + fi + + # Note that a whitespace or even empty argument is allowed + IFS= read -r val + set -- "$@" "$val" +done + +# Execute the command with the given parameters +exec "$cmd" "$@" diff --git a/bin/apf b/bin/apf deleted file mode 100755 index 39bc0720..00000000 --- a/bin/apf +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Prepend arguments from a file to the given arguments for a command -self=apf - -# Require at least two arguments -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need an arguments file and a command\n' "$self" - exit 2 -fi - -# First argument is the file containing the null-delimited arguments -argf=$1 cmd=$2 -shift 2 - -# If there were arguments given on the command line, we need to be careful and -# prepend our ones first -if [ "$#" -gt 0 ] ; then - - # Iterate through any remaining arguments - for carg ; do - - # If this is the first command argument, then before we add it, we'll - # add all the ones from the file first if it exists - if [ -n "$argf" ] ; then - - # Reset the positional parameters - set -- - - # Put our file arguments in first before we continue with the loop - if [ -e "$argf" ] ; then - while IFS= read -r farg ; do - case $farg in - '#'*) continue ;; - *[![:space:]]*) ;; - *) continue ;; - esac - set -- "$@" "$farg" - done < "$argf" - fi - - # Unset the argfile so we don't repeat this bit - unset -v argf - fi - - # Stack the original invocation argument back onto the positional - # parameters - set -- "$@" "$carg" - done - -# If there weren't, we can just read the file and slap them in -elif [ -e "$argf" ] ; then - while IFS= read -r farg ; do - case $farg in - '#'*) continue ;; - *[![:space:]]*) ;; - *) continue ;; - esac - set -- "$@" "$farg" - done < "$argf" -fi - -# Run the command with the changed arguments -exec "$cmd" "$@" diff --git a/bin/apf.sh b/bin/apf.sh new file mode 100644 index 00000000..5e40e9b8 --- /dev/null +++ b/bin/apf.sh @@ -0,0 +1,62 @@ +# Prepend arguments from a file to the given arguments for a command +self=apf + +# Require at least two arguments +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need an arguments file and a command\n' "$self" + exit 2 +fi + +# First argument is the file containing the null-delimited arguments +argf=$1 cmd=$2 +shift 2 + +# If there were arguments given on the command line, we need to be careful and +# prepend our ones first +if [ "$#" -gt 0 ] ; then + + # Iterate through any remaining arguments + for carg ; do + + # If this is the first command argument, then before we add it, we'll + # add all the ones from the file first if it exists + if [ -n "$argf" ] ; then + + # Reset the positional parameters + set -- + + # Put our file arguments in first before we continue with the loop + if [ -e "$argf" ] ; then + while IFS= read -r farg ; do + case $farg in + '#'*) continue ;; + *[![:space:]]*) ;; + *) continue ;; + esac + set -- "$@" "$farg" + done < "$argf" + fi + + # Unset the argfile so we don't repeat this bit + unset -v argf + fi + + # Stack the original invocation argument back onto the positional + # parameters + set -- "$@" "$carg" + done + +# If there weren't, we can just read the file and slap them in +elif [ -e "$argf" ] ; then + while IFS= read -r farg ; do + case $farg in + '#'*) continue ;; + *[![:space:]]*) ;; + *) continue ;; + esac + set -- "$@" "$farg" + done < "$argf" +fi + +# Run the command with the changed arguments +exec "$cmd" "$@" diff --git a/bin/ax b/bin/ax deleted file mode 100755 index 8dea72da..00000000 --- a/bin/ax +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Evaluate an Awk expression given on the command line with an optional format - -# Count arguments -case $# in - - # If one argument, we assume format is %s - 1) form=%s expr=$1 ;; - - # If two arguments, first is format, second expression - 2) form=$1 expr=$2 ;; - - # Any other number of arguments is wrong - *) - printf >&2 'ax: Need an expression\n' - exit 2 - ;; -esac - -# Form program -prog=$(printf ' - BEGIN { - printf "%s\\n", %s - } -' "$form" "$expr") - -# Run program -awk "$prog" diff --git a/bin/ax.sh b/bin/ax.sh new file mode 100644 index 00000000..6ce1e9ea --- /dev/null +++ b/bin/ax.sh @@ -0,0 +1,27 @@ +# Evaluate an Awk expression given on the command line with an optional format + +# Count arguments +case $# in + + # If one argument, we assume format is %s + 1) form=%s expr=$1 ;; + + # If two arguments, first is format, second expression + 2) form=$1 expr=$2 ;; + + # Any other number of arguments is wrong + *) + printf >&2 'ax: Need an expression\n' + exit 2 + ;; +esac + +# Form program +prog=$(printf ' + BEGIN { + printf "%s\\n", %s + } +' "$form" "$expr") + +# Run program +awk "$prog" diff --git a/bin/bcq b/bin/bcq deleted file mode 100755 index 7b950b56..00000000 --- a/bin/bcq +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Fire up bc(1), hushing it if it looks like GNU -[ -e "$HOME"/.cache/bc/quiet ] && set -- --quiet "$@" -exec bc "$@" diff --git a/bin/bcq.sh b/bin/bcq.sh new file mode 100644 index 00000000..71a79666 --- /dev/null +++ b/bin/bcq.sh @@ -0,0 +1,3 @@ +# Fire up bc(1), hushing it if it looks like GNU +[ -e "$HOME"/.cache/bc/quiet ] && set -- --quiet "$@" +exec bc "$@" diff --git a/bin/bel b/bin/bel deleted file mode 100755 index c1c2ce1c..00000000 --- a/bin/bel +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Print a terminal bell -printf '\a' diff --git a/bin/bel.sh b/bin/bel.sh new file mode 100644 index 00000000..e87eceda --- /dev/null +++ b/bin/bel.sh @@ -0,0 +1,2 @@ +# Print a terminal bell +printf '\a' diff --git a/bin/bl b/bin/bl deleted file mode 100755 index b1831387..00000000 --- a/bin/bl +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Generate blank lines -if [ "$#" -ne 1 ] || [ "$1" -lt 0 ] ; then - printf >&2 'bl: Non-negative line count needed as sole argument\n' - exit 2 -fi -n=0 -while [ "$n" -lt "${1:-0}" ] ; do - printf '\n' - n=$((n+1)) -done diff --git a/bin/bl.sh b/bin/bl.sh new file mode 100644 index 00000000..6dd3d687 --- /dev/null +++ b/bin/bl.sh @@ -0,0 +1,10 @@ +# Generate blank lines +if [ "$#" -ne 1 ] || [ "$1" -lt 0 ] ; then + printf >&2 'bl: Non-negative line count needed as sole argument\n' + exit 2 +fi +n=0 +while [ "$n" -lt "${1:-0}" ] ; do + printf '\n' + n=$((n+1)) +done diff --git a/bin/bp b/bin/bp deleted file mode 100755 index 6b78fbbc..00000000 --- a/bin/bp +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Read an URL and then browse to it, saving the annoyance of quoting URLs -ap br URL diff --git a/bin/bp.sh b/bin/bp.sh new file mode 100644 index 00000000..34065ca3 --- /dev/null +++ b/bin/bp.sh @@ -0,0 +1,2 @@ +# Read an URL and then browse to it, saving the annoyance of quoting URLs +ap br URL diff --git a/bin/br b/bin/br deleted file mode 100755 index 399c6038..00000000 --- a/bin/br +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Just launch $BROWSER with any given arguments -exec "$BROWSER" "$@" diff --git a/bin/br.sh b/bin/br.sh new file mode 100644 index 00000000..72507528 --- /dev/null +++ b/bin/br.sh @@ -0,0 +1,2 @@ +# Just launch $BROWSER with any given arguments +exec "$BROWSER" "$@" diff --git a/bin/ca b/bin/ca deleted file mode 100755 index 836299ce..00000000 --- a/bin/ca +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Print a count of the number of arguments -printf '%u\n' "$#" diff --git a/bin/ca.sh b/bin/ca.sh new file mode 100644 index 00000000..1d6333ad --- /dev/null +++ b/bin/ca.sh @@ -0,0 +1,2 @@ +# Print a count of the number of arguments +printf '%u\n' "$#" diff --git a/bin/cf b/bin/cf deleted file mode 100755 index 347481f1..00000000 --- a/bin/cf +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Count entries in a given set of directories - -# Iterate over remaining non-option arguments (directories); default to current -# directory if none given -for dir in "${@:-.}" ; do - - # Attempt to count the files in a subshell - if count=$( - cd -- "$dir" || exit - find . ! -name . -prune -exec printf %.sx {} + | - wc -c - ) ; then - - # If it worked, print the count - printf '%u\t%s\n' "$count" "$dir" - else - - # If not, set the error flag and continue - ex=1 - fi -done - -# Exit non-zero if a non-directory was given as an argument -exit "${ex:-0}" diff --git a/bin/cf.sh b/bin/cf.sh new file mode 100644 index 00000000..ea3a2887 --- /dev/null +++ b/bin/cf.sh @@ -0,0 +1,24 @@ +# Count entries in a given set of directories + +# Iterate over remaining non-option arguments (directories); default to current +# directory if none given +for dir in "${@:-.}" ; do + + # Attempt to count the files in a subshell + if count=$( + cd -- "$dir" || exit + find . ! -name . -prune -exec printf %.sx {} + | + wc -c + ) ; then + + # If it worked, print the count + printf '%u\t%s\n' "$count" "$dir" + else + + # If not, set the error flag and continue + ex=1 + fi +done + +# Exit non-zero if a non-directory was given as an argument +exit "${ex:-0}" diff --git a/bin/cfr b/bin/cfr deleted file mode 100755 index d49ab3d9..00000000 --- a/bin/cfr +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Count entries in a given set of directories - -# Iterate over remaining non-option arguments (directories); default to current -# directory if none given -for dir in "${@:-.}" ; do - - # Attempt to count the files in a subshell - if count=$( - cd -- "$dir" || exit - find . ! -name . -exec printf %.sx {} + | - wc -c - ) ; then - - # If it worked, print the count - printf '%u\t%s\n' "$count" "$dir" - else - - # If not, set the error flag and continue - ex=1 - fi -done - -# Exit non-zero if a non-directory was given as an argument -exit "${ex:-0}" diff --git a/bin/cfr.sh b/bin/cfr.sh new file mode 100644 index 00000000..9d13785c --- /dev/null +++ b/bin/cfr.sh @@ -0,0 +1,24 @@ +# Count entries in a given set of directories + +# Iterate over remaining non-option arguments (directories); default to current +# directory if none given +for dir in "${@:-.}" ; do + + # Attempt to count the files in a subshell + if count=$( + cd -- "$dir" || exit + find . ! -name . -exec printf %.sx {} + | + wc -c + ) ; then + + # If it worked, print the count + printf '%u\t%s\n' "$count" "$dir" + else + + # If not, set the error flag and continue + ex=1 + fi +done + +# Exit non-zero if a non-directory was given as an argument +exit "${ex:-0}" diff --git a/bin/chc b/bin/chc deleted file mode 100755 index b1e4000d..00000000 --- a/bin/chc +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Cache the output of a command and emit it straight from the cache if not -# expired on each run - -# First argument is the cache path, second is the duration in seconds -cac=$1 dur=$2 -shift 2 - -# Get the current timestamp with uts(1df) -uts=$(uts) || exit - -# Function checks cache exists, is readable, and not expired -fresh() { - [ -f "$cac" ] || return - [ -r "$cac" ] || return - exp=$(sed 1q -- "$cac") || return - [ "$((exp > uts))" -eq 1 ] -} - -# Write runs the command and writes it to the cache -write() { - exp=$((uts + dur)) - printf '%u\n' "$exp" - "$@" -} - -# If the cache isn't fresh, try to write a new one, or bail out -fresh "$cac" || write "$@" > "$cac" || exit - -# Emit the content (exclude the first line, which is the timestamp) -sed 1d -- "$cac" diff --git a/bin/chc.sh b/bin/chc.sh new file mode 100644 index 00000000..8b15317c --- /dev/null +++ b/bin/chc.sh @@ -0,0 +1,30 @@ +# Cache the output of a command and emit it straight from the cache if not +# expired on each run + +# First argument is the cache path, second is the duration in seconds +cac=$1 dur=$2 +shift 2 + +# Get the current timestamp with uts(1df) +uts=$(uts) || exit + +# Function checks cache exists, is readable, and not expired +fresh() { + [ -f "$cac" ] || return + [ -r "$cac" ] || return + exp=$(sed 1q -- "$cac") || return + [ "$((exp > uts))" -eq 1 ] +} + +# Write runs the command and writes it to the cache +write() { + exp=$((uts + dur)) + printf '%u\n' "$exp" + "$@" +} + +# If the cache isn't fresh, try to write a new one, or bail out +fresh "$cac" || write "$@" > "$cac" || exit + +# Emit the content (exclude the first line, which is the timestamp) +sed 1d -- "$cac" diff --git a/bin/chn b/bin/chn deleted file mode 100755 index 46a8a27a..00000000 --- a/bin/chn +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Repeat a command to filter input several times -self=chn - -# Check arguments. -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need a count and a program name\n' "$self" - exit 2 -fi - -# Shift off the repetition count. -c=$1 -shift - -# Check the repetition count looks sane. Zero is fine! -if [ "$c" -lt 0 ] ; then - printf >&2 '%s: Nonsensical negative count\n' "$self" - exit 2 -fi - -# If the count is zero, just run the input straight through! -if [ "$c" -eq 0 ] ; then - cat - exit -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Define and create input and output files -if=$td/if of=$td/of -touch -- "$if" "$of" - -# Iterate through the count -while [ "${n=1}" -le "$c" ] ; do - - # Start a subshell so we can deal with FDs cleanly - ( - # If this isn't the first iteration, our input comes from $if - [ "$n" -eq 1 ] || - exec <"$if" - - # If this isn't the last iteration, our output goes to $of - [ "$n" -eq "$c" ] || - exec >"$of" - - # Run the command with the descriptors above; if the command fails, the - # subshell will exit, which will in turn exit the program - "$@" - ) || exit - - # Copy the output file over the input one - cp -- "$of" "$if" - - # Increment the counter for the next while loop run - n=$((n+1)) -done diff --git a/bin/chn.sh b/bin/chn.sh new file mode 100644 index 00000000..9103dd07 --- /dev/null +++ b/bin/chn.sh @@ -0,0 +1,69 @@ +# Repeat a command to filter input several times +self=chn + +# Check arguments. +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need a count and a program name\n' "$self" + exit 2 +fi + +# Shift off the repetition count. +c=$1 +shift + +# Check the repetition count looks sane. Zero is fine! +if [ "$c" -lt 0 ] ; then + printf >&2 '%s: Nonsensical negative count\n' "$self" + exit 2 +fi + +# If the count is zero, just run the input straight through! +if [ "$c" -eq 0 ] ; then + cat + exit +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Define and create input and output files +if=$td/if of=$td/of +touch -- "$if" "$of" + +# Iterate through the count +while [ "${n=1}" -le "$c" ] ; do + + # Start a subshell so we can deal with FDs cleanly + ( + # If this isn't the first iteration, our input comes from $if + [ "$n" -eq 1 ] || + exec <"$if" + + # If this isn't the last iteration, our output goes to $of + [ "$n" -eq "$c" ] || + exec >"$of" + + # Run the command with the descriptors above; if the command fails, the + # subshell will exit, which will in turn exit the program + "$@" + ) || exit + + # Copy the output file over the input one + cp -- "$of" "$if" + + # Increment the counter for the next while loop run + n=$((n+1)) +done diff --git a/bin/clog b/bin/clog deleted file mode 100755 index 037f24c7..00000000 --- a/bin/clog +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Record a timestamped message to a logfile, defaulting to ~/.clog -self=clog -command -v rlwrap >/dev/null 2>&1 && - set -- rlwrap -C "$self" "$@" -{ - date - "$@" cat - - printf '%s\n' -- -} >>"${CLOG:-"$HOME"/.clog}" diff --git a/bin/clog.sh b/bin/clog.sh new file mode 100644 index 00000000..0964ce90 --- /dev/null +++ b/bin/clog.sh @@ -0,0 +1,9 @@ +# Record a timestamped message to a logfile, defaulting to ~/.clog +self=clog +command -v rlwrap >/dev/null 2>&1 && + set -- rlwrap -C "$self" "$@" +{ + date + "$@" cat - + printf '%s\n' -- +} >>"${CLOG:-"$HOME"/.clog}" diff --git a/bin/clrd b/bin/clrd deleted file mode 100755 index 0b460671..00000000 --- a/bin/clrd +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# Clear the screen and read a file as it's written line-by-line -self=clrd - -# Check we have an input file and are writing to a terminal -if [ "$#" -ne 1 ] ; then - printf >&2 '%s: Need input file\n' "$self" - exit 2 -elif ! [ -t 1 ] ; then - printf >&2 '%s: stdout not a terminal\n' "$self" - exit 2 -fi - -# Clear the screen and start tailing out the file -clear -tail -f -- "$@" diff --git a/bin/clrd.sh b/bin/clrd.sh new file mode 100644 index 00000000..bf239033 --- /dev/null +++ b/bin/clrd.sh @@ -0,0 +1,15 @@ +# Clear the screen and read a file as it's written line-by-line +self=clrd + +# Check we have an input file and are writing to a terminal +if [ "$#" -ne 1 ] ; then + printf >&2 '%s: Need input file\n' "$self" + exit 2 +elif ! [ -t 1 ] ; then + printf >&2 '%s: stdout not a terminal\n' "$self" + exit 2 +fi + +# Clear the screen and start tailing out the file +clear +tail -f -- "$@" diff --git a/bin/clwr b/bin/clwr deleted file mode 100755 index dc045e9d..00000000 --- a/bin/clwr +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Write lines of terminal input into a file, clearing in between each one -self=clwr - -# Check our inputs for sanity -if [ "$#" -ne 1 ] ; then - printf >&2 '%s: Need output file\n' "$self" - exit 2 -elif ! [ -t 0 ] ; then - printf >&2 '%s: stdin not a terminal\n' "$self" - exit 2 -elif ! [ -t 1 ] ; then - printf >&2 '%s: stdout not a terminal\n' "$self" - exit 2 -fi - -# Open a file descriptor onto the output file to save on open(2)/close(2) -# system calls -exec 3>"$1" || exit - -# Start looping through clearing and accepting lines -while { tput clear && IFS= read -r line ; } ; do - printf '%s\n' "$line" >&3 -done diff --git a/bin/clwr.sh b/bin/clwr.sh new file mode 100644 index 00000000..897c1a01 --- /dev/null +++ b/bin/clwr.sh @@ -0,0 +1,23 @@ +# Write lines of terminal input into a file, clearing in between each one +self=clwr + +# Check our inputs for sanity +if [ "$#" -ne 1 ] ; then + printf >&2 '%s: Need output file\n' "$self" + exit 2 +elif ! [ -t 0 ] ; then + printf >&2 '%s: stdin not a terminal\n' "$self" + exit 2 +elif ! [ -t 1 ] ; then + printf >&2 '%s: stdout not a terminal\n' "$self" + exit 2 +fi + +# Open a file descriptor onto the output file to save on open(2)/close(2) +# system calls +exec 3>"$1" || exit + +# Start looping through clearing and accepting lines +while { tput clear && IFS= read -r line ; } ; do + printf '%s\n' "$line" >&3 +done diff --git a/bin/d2u b/bin/d2u deleted file mode 100755 index 6fe362b7..00000000 --- a/bin/d2u +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Convert DOS line endings to UNIX ones - -# Check arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'd2u: Need a filename\n' - exit 2 -fi - -# Put a carriage return into a variable for convenience -r=$(printf '\r') - -# Iterate over arguments and apply the same ed(1) script to each of them -for fn ; do - - # Note the heredoc WORD is intentionally unquoted because we want to expand - # $r within it to get a literal carriage return; the escape characters - # prescribed for ed(1) by POSIX are very limited - ed -s -- "$fn" <&2 'd2u: Need a filename\n' + exit 2 +fi + +# Put a carriage return into a variable for convenience +r=$(printf '\r') + +# Iterate over arguments and apply the same ed(1) script to each of them +for fn ; do + + # Note the heredoc WORD is intentionally unquoted because we want to expand + # $r within it to get a literal carriage return; the escape characters + # prescribed for ed(1) by POSIX are very limited + ed -s -- "$fn" </dev/null >&2 ; then - notify-send "$(printf '%s in clipboard' "$pw")" -fi diff --git a/bin/dmp.sh b/bin/dmp.sh new file mode 100644 index 00000000..ea79214f --- /dev/null +++ b/bin/dmp.sh @@ -0,0 +1,30 @@ + +# Get the password store directory, bail if we can't +pwsd=${PASSWORD_STORE_DIR:-"$HOME"/.password-store} +pwsd=${pwsd%/} +[ -n "$pwsd" ] || exit + +# Get the password; get all the names from find(1) +# shellcheck disable=SC2016 +pw=$( + cd -- "$pwsd" || exit + # Get all the names from find(1) + find ./ -name \*.gpg | + # Sort them + sort | + # Strip the leading directory and the trailing .gpg + sed 's_^\./__;s_\.gpg$__' | + # Use dmenu(1) to prompt the user to select one + dmenu +) || exit + +# Bail if we don't have a password +[ -n "$pw" ] || exit + +# Pump the first line of the password into the clipboard +pass show "$pw" | sed 1q | xsel -ib || exit + +# If we have notify-send(1), alert that the password has been copied +if command -v notify-send >/dev/null >&2 ; then + notify-send "$(printf '%s in clipboard' "$pw")" +fi diff --git a/bin/dub b/bin/dub deleted file mode 100755 index 36d787a4..00000000 --- a/bin/dub +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# List the biggest files in a directory - -# First optional argument is the directory, defaulting to the -# current dir; second optional argument is the number of files to -# show, defaulting to 20 -dir=${1:-.} lines=${2:-10} - -# Enter the target dir or bail -cd -- "$dir" || exit - -# Add files matching glob, shift them off if unexpanded (first and -# only entry doesn't exist) -set -- * -[ -e "$1" ] || shift - -# Add dot files, shift off the "." and ".." entries (sh(1) -# implementations seem to vary on whether they include these) -set -- .* "$@" -[ -e "$1" ] || shift -[ "$1" = . ] && shift -[ "$1" = .. ] && shift - -# Run du(1) with POSIX compatible flags -k for kilobyte unit and -# -s for total over the arguments -du -ks -- "$@" | - -# Sort the first field (the sizes) numerically, in reverse -sort -k1,1nr | - -# Limit the output to the given number of lines -sed "$lines"q diff --git a/bin/dub.sh b/bin/dub.sh new file mode 100644 index 00000000..f42c5ac9 --- /dev/null +++ b/bin/dub.sh @@ -0,0 +1,31 @@ +# List the biggest files in a directory + +# First optional argument is the directory, defaulting to the +# current dir; second optional argument is the number of files to +# show, defaulting to 20 +dir=${1:-.} lines=${2:-10} + +# Enter the target dir or bail +cd -- "$dir" || exit + +# Add files matching glob, shift them off if unexpanded (first and +# only entry doesn't exist) +set -- * +[ -e "$1" ] || shift + +# Add dot files, shift off the "." and ".." entries (sh(1) +# implementations seem to vary on whether they include these) +set -- .* "$@" +[ -e "$1" ] || shift +[ "$1" = . ] && shift +[ "$1" = .. ] && shift + +# Run du(1) with POSIX compatible flags -k for kilobyte unit and +# -s for total over the arguments +du -ks -- "$@" | + +# Sort the first field (the sizes) numerically, in reverse +sort -k1,1nr | + +# Limit the output to the given number of lines +sed "$lines"q diff --git a/bin/edda b/bin/edda deleted file mode 100755 index 6af88a5f..00000000 --- a/bin/edda +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Run ed(1) over multiple files, duplicating stdin. -self=edda - -# Need at least one file -if [ "$#" -eq 0 ] ; then - printf >&2 'edda: Need at least one file\n' - exit 2 -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Duplicate stdin into a file -script=$td/script -cat >"$script" || exit - -# Run ed(1) over each file with the stdin given -for file ; do - ed -- "$file" <"$script" -done diff --git a/bin/edda.sh b/bin/edda.sh new file mode 100644 index 00000000..b1d7b27a --- /dev/null +++ b/bin/edda.sh @@ -0,0 +1,33 @@ +# Run ed(1) over multiple files, duplicating stdin. +self=edda + +# Need at least one file +if [ "$#" -eq 0 ] ; then + printf >&2 'edda: Need at least one file\n' + exit 2 +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Duplicate stdin into a file +script=$td/script +cat >"$script" || exit + +# Run ed(1) over each file with the stdin given +for file ; do + ed -- "$file" <"$script" +done diff --git a/bin/eds b/bin/eds deleted file mode 100755 index e39215d4..00000000 --- a/bin/eds +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Create and edit executable scripts in a directory EDSPATH (defaults to ~/.local/bin) - -# Need at least one script name -if [ "$#" -eq 0 ] ; then - printf >&2 'eds: Need at least one script name\n' - exit 2 -fi - -# Create the script directory if it doesn't exist yet -ep=${EDSPATH:-$HOME/.local/bin} -if ! [ -d "$ep" ] ; then - mkdir -p -- "$ep" || exit -fi - -# Warn if that's not in $PATH -case :$PATH: in - *:"$ep":*) ;; - *) - printf >&2 'eds: warning: %s not in PATH\n' "$ep" - ;; -esac - -# Prepend the path to each of the names given if they don't look like options -for arg ; do - [ -n "$reset" ] || set -- && reset=1 - case $arg in - --) - optend=1 - set -- "$@" "$arg" - continue - ;; - -*) - if [ -z "$optend" ] ; then - set -- "$@" "$arg" - continue - fi - ;; - esac - optend=1 - set -- "$@" "$ep"/"$arg" -done - -# Run the editor over the arguments -"${VISUAL:-"${EDITOR:-ed}"}" "$@" - -# Make any created scripts executable if they now appear to be files -for script ; do - [ -f "$script" ] || continue - chmod +x -- "$script" -done diff --git a/bin/eds.sh b/bin/eds.sh new file mode 100644 index 00000000..c85069c6 --- /dev/null +++ b/bin/eds.sh @@ -0,0 +1,50 @@ +# Create and edit executable scripts in a directory EDSPATH (defaults to ~/.local/bin) + +# Need at least one script name +if [ "$#" -eq 0 ] ; then + printf >&2 'eds: Need at least one script name\n' + exit 2 +fi + +# Create the script directory if it doesn't exist yet +ep=${EDSPATH:-$HOME/.local/bin} +if ! [ -d "$ep" ] ; then + mkdir -p -- "$ep" || exit +fi + +# Warn if that's not in $PATH +case :$PATH: in + *:"$ep":*) ;; + *) + printf >&2 'eds: warning: %s not in PATH\n' "$ep" + ;; +esac + +# Prepend the path to each of the names given if they don't look like options +for arg ; do + [ -n "$reset" ] || set -- && reset=1 + case $arg in + --) + optend=1 + set -- "$@" "$arg" + continue + ;; + -*) + if [ -z "$optend" ] ; then + set -- "$@" "$arg" + continue + fi + ;; + esac + optend=1 + set -- "$@" "$ep"/"$arg" +done + +# Run the editor over the arguments +"${VISUAL:-"${EDITOR:-ed}"}" "$@" + +# Make any created scripts executable if they now appear to be files +for script ; do + [ -f "$script" ] || continue + chmod +x -- "$script" +done diff --git a/bin/exm b/bin/exm deleted file mode 100755 index f1afa17a..00000000 --- a/bin/exm +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Prevent Vim's ex(1) implementation from clearing the screen -if [ -t 0 ] ; then - ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}') - case $ver in - # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" - # feature is invoked with a carriage return. - VIM) - cmd=$(printf 'set t_cm=\r|') - set -- -T dumb --cmd "${cmd%|}" "$@" ;; - esac -fi -exec ex "$@" diff --git a/bin/exm.sh b/bin/exm.sh new file mode 100644 index 00000000..25e3006f --- /dev/null +++ b/bin/exm.sh @@ -0,0 +1,12 @@ +# Prevent Vim's ex(1) implementation from clearing the screen +if [ -t 0 ] ; then + ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}') + case $ver in + # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" + # feature is invoked with a carriage return. + VIM) + cmd=$(printf 'set t_cm=\r|') + set -- -T dumb --cmd "${cmd%|}" "$@" ;; + esac +fi +exec ex "$@" diff --git a/bin/fgscr b/bin/fgscr deleted file mode 100755 index 7d5ff4c5..00000000 --- a/bin/fgscr +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Find all the Git repositories in a directory and scrub them all - -# Check we have gscr(1df) first -command -v gscr >/dev/null 2>&1 || exit - -# Look for any dir named .git in the given (default current) dir and run -# gscr(1df) on it -find "${@:-.}" -name '*.git' -type d -exec gscr {} \; diff --git a/bin/fgscr.sh b/bin/fgscr.sh new file mode 100644 index 00000000..137e0dd8 --- /dev/null +++ b/bin/fgscr.sh @@ -0,0 +1,8 @@ +# Find all the Git repositories in a directory and scrub them all + +# Check we have gscr(1df) first +command -v gscr >/dev/null 2>&1 || exit + +# Look for any dir named .git in the given (default current) dir and run +# gscr(1df) on it +find "${@:-.}" -name '*.git' -type d -exec gscr {} \; diff --git a/bin/finc b/bin/finc deleted file mode 100755 index 109f02b3..00000000 --- a/bin/finc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Count the number of entries from a find(1) condition -find "${@:-.}" -exec printf .%sx {} + | wc -c diff --git a/bin/finc.sh b/bin/finc.sh new file mode 100644 index 00000000..2bbb9ae8 --- /dev/null +++ b/bin/finc.sh @@ -0,0 +1,2 @@ +# Count the number of entries from a find(1) condition +find "${@:-.}" -exec printf .%sx {} + | wc -c diff --git a/bin/fnl b/bin/fnl deleted file mode 100755 index 6969665b..00000000 --- a/bin/fnl +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Run a command and save its output and error to temporary files - -# Check we have at least one argument -if [ "$#" -eq 0 ] ; then - printf >&2 'fnl: Command needed\n' - return 2 -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 -{ "$@" ; } >"$dir"/stdout 2>"$dir"/stderr -ret=$? - -# Run wc(1) on each of the files -wc -- "$dir"/* - -# Exit with the wrapped command's exit status -exit "$ret" diff --git a/bin/fnl.sh b/bin/fnl.sh new file mode 100644 index 00000000..8d771adb --- /dev/null +++ b/bin/fnl.sh @@ -0,0 +1,20 @@ +# Run a command and save its output and error to temporary files + +# Check we have at least one argument +if [ "$#" -eq 0 ] ; then + printf >&2 'fnl: Command needed\n' + return 2 +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 +{ "$@" ; } >"$dir"/stdout 2>"$dir"/stderr +ret=$? + +# Run wc(1) on each of the files +wc -- "$dir"/* + +# Exit with the wrapped command's exit status +exit "$ret" diff --git a/bin/gms b/bin/gms deleted file mode 100755 index 01cdaa2f..00000000 --- a/bin/gms +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Run getmail(1) over every getmailrc.* file in ~/.getmail - -# Trap to remove whatever's set in lockdir if we're killed -lockdir= -cleanup() { - [ -n "$lockdir" ] && rm -fr -- "$lockdir" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done - -# Don't trust the environment $UID, use id(1) instead -uid=$(id -u) || exit - -# Iterate through the getmailrc.* files in $GETMAIL if defined, or -# $HOME/.getmail if not -for rcfile in "${GETMAIL:-"$HOME"/.getmail}"/getmailrc.* ; do ( - lockdir=${TMPDIR:-/tmp}/getmail.$uid.${rcfile##*/}.lock - mkdir -m 0700 -- "$lockdir" 2>/dev/null || exit - try -n 3 -s 15 getmail --rcfile "$rcfile" "$@" - rm -fr -- "$lockdir" && lockdir= -) & done - -# Wait for all of the enqueued tasks to finish -wait diff --git a/bin/gms.sh b/bin/gms.sh new file mode 100644 index 00000000..b77da6fa --- /dev/null +++ b/bin/gms.sh @@ -0,0 +1,30 @@ +# Run getmail(1) over every getmailrc.* file in ~/.getmail + +# Trap to remove whatever's set in lockdir if we're killed +lockdir= +cleanup() { + [ -n "$lockdir" ] && rm -fr -- "$lockdir" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done + +# Don't trust the environment $UID, use id(1) instead +uid=$(id -u) || exit + +# Iterate through the getmailrc.* files in $GETMAIL if defined, or +# $HOME/.getmail if not +for rcfile in "${GETMAIL:-"$HOME"/.getmail}"/getmailrc.* ; do ( + lockdir=${TMPDIR:-/tmp}/getmail.$uid.${rcfile##*/}.lock + mkdir -m 0700 -- "$lockdir" 2>/dev/null || exit + try -n 3 -s 15 getmail --rcfile "$rcfile" "$@" + rm -fr -- "$lockdir" && lockdir= +) & done + +# Wait for all of the enqueued tasks to finish +wait diff --git a/bin/grc b/bin/grc deleted file mode 100755 index 0db91afa..00000000 --- a/bin/grc +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# Check whether a directory is a Git repository with uncommitted changes - -# Enter given directory or bail -cd -- "${1:-.}" || exit - -# If not a Git repository at all, warn explicitly -if ! isgr ; then - printf >&2 'grc: Not a Git repository\n' - exit 1 -fi - -# Exit 0 if the first command gives any output (added files) or the second one -# exits 1 (inverted; differences in tracked files) -[ -n "$(git ls-files --others --exclude-standard)" ] || -! git diff-index --quiet HEAD diff --git a/bin/grc.sh b/bin/grc.sh new file mode 100644 index 00000000..184baf8e --- /dev/null +++ b/bin/grc.sh @@ -0,0 +1,15 @@ +# Check whether a directory is a Git repository with uncommitted changes + +# Enter given directory or bail +cd -- "${1:-.}" || exit + +# If not a Git repository at all, warn explicitly +if ! isgr ; then + printf >&2 'grc: Not a Git repository\n' + exit 1 +fi + +# Exit 0 if the first command gives any output (added files) or the second one +# exits 1 (inverted; differences in tracked files) +[ -n "$(git ls-files --others --exclude-standard)" ] || +! git diff-index --quiet HEAD diff --git a/bin/gscr b/bin/gscr deleted file mode 100755 index cac969fe..00000000 --- a/bin/gscr +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Scrub and pack Git repositories - -# Iterate through given directories; default to the current one -for arg in "${@:-.}" ; do ( - - # Note the "exit" calls here in lieu of "continue" are deliberate; we're in - # a subshell, so leaving it will continue the loop. - - # Enter either bare repository or .git subdir - case $arg in - *.git) - cd -- "$arg" || exit - ;; - *) - cd -- "$arg"/.git || exit - ;; - esac - - # Check for bad references or other integrity/sanity problems - git fsck || exit - - # Expire dangling references - git reflog expire --expire=now || exit - - # Remove dangling references - git gc --prune=now --aggressive || exit - -) done diff --git a/bin/gscr.sh b/bin/gscr.sh new file mode 100644 index 00000000..2fbee05a --- /dev/null +++ b/bin/gscr.sh @@ -0,0 +1,28 @@ +# Scrub and pack Git repositories + +# Iterate through given directories; default to the current one +for arg in "${@:-.}" ; do ( + + # Note the "exit" calls here in lieu of "continue" are deliberate; we're in + # a subshell, so leaving it will continue the loop. + + # Enter either bare repository or .git subdir + case $arg in + *.git) + cd -- "$arg" || exit + ;; + *) + cd -- "$arg"/.git || exit + ;; + esac + + # Check for bad references or other integrity/sanity problems + git fsck || exit + + # Expire dangling references + git reflog expire --expire=now || exit + + # Remove dangling references + git gc --prune=now --aggressive || exit + +) done diff --git a/bin/hurl b/bin/hurl deleted file mode 100755 index 16ea48f8..00000000 --- a/bin/hurl +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Extract URLs from an HTML document or documents - -# Input is either stdin or the given arguments concatenated -cat -- "${@:--}" | - -# Pipe through pup to get all the href links -pup -p 'a attr{href}' | - -# Sort them uniquely -sort | uniq diff --git a/bin/hurl.sh b/bin/hurl.sh new file mode 100644 index 00000000..0680c5ce --- /dev/null +++ b/bin/hurl.sh @@ -0,0 +1,10 @@ +# Extract URLs from an HTML document or documents + +# Input is either stdin or the given arguments concatenated +cat -- "${@:--}" | + +# Pipe through pup to get all the href links +pup -p 'a attr{href}' | + +# Sort them uniquely +sort | uniq diff --git a/bin/igex b/bin/igex deleted file mode 100755 index c514006d..00000000 --- a/bin/igex +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Run a command and ignore specified exit values - -# There should be at least two arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'igs: Need an ignore list x,y,z and a command\n'; -fi - -# The list of values to ignore is the first argument; add a trailing comma for -# ease of parsing; shift it off -igs=$1, -shift - -# Run the command in the remaining arguments and grab its exit value -"$@" -ex=$? - -# Iterate through the ignored exit values by chopping its variable and checking -# each value until it's empty -while [ -n "$igs" ] ; do - - # Get the first exit value in the remaining list - ig=${igs%%,*} - - # If it matches the command's exit value, exit with 0 - [ "$((ig == ex))" -eq 1 ] && exit 0 - - # Chop it off the list for the next iteration - igs=${igs#*,} -done - -# If we got right through the list, we exit with the same value as the command; -# i.e. we are not ignoring the value -exit "$ex" diff --git a/bin/igex.sh b/bin/igex.sh new file mode 100644 index 00000000..09f1206f --- /dev/null +++ b/bin/igex.sh @@ -0,0 +1,33 @@ +# Run a command and ignore specified exit values + +# There should be at least two arguments +if [ "$#" -eq 0 ] ; then + printf >&2 'igs: Need an ignore list x,y,z and a command\n'; +fi + +# The list of values to ignore is the first argument; add a trailing comma for +# ease of parsing; shift it off +igs=$1, +shift + +# Run the command in the remaining arguments and grab its exit value +"$@" +ex=$? + +# Iterate through the ignored exit values by chopping its variable and checking +# each value until it's empty +while [ -n "$igs" ] ; do + + # Get the first exit value in the remaining list + ig=${igs%%,*} + + # If it matches the command's exit value, exit with 0 + [ "$((ig == ex))" -eq 1 ] && exit 0 + + # Chop it off the list for the next iteration + igs=${igs#*,} +done + +# If we got right through the list, we exit with the same value as the command; +# i.e. we are not ignoring the value +exit "$ex" diff --git a/bin/isgr b/bin/isgr deleted file mode 100755 index 029b5352..00000000 --- a/bin/isgr +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Return an exit status for whether the current directory appears to be in a -# Git working copy - -# No output, at all, ever; this is intended for use in scripting -exec >/dev/null 2>&1 - -# Enter the given directory (default to current directory) -cd -- "${1:-.}" || exit - -# If neither of these commands work, this isn't a Git repository -git symbolic-ref --quiet HEAD || -git rev-parse --short HEAD diff --git a/bin/isgr.sh b/bin/isgr.sh new file mode 100644 index 00000000..9d3e97a8 --- /dev/null +++ b/bin/isgr.sh @@ -0,0 +1,12 @@ +# Return an exit status for whether the current directory appears to be in a +# Git working copy + +# No output, at all, ever; this is intended for use in scripting +exec >/dev/null 2>&1 + +# Enter the given directory (default to current directory) +cd -- "${1:-.}" || exit + +# If neither of these commands work, this isn't a Git repository +git symbolic-ref --quiet HEAD || +git rev-parse --short HEAD diff --git a/bin/ix b/bin/ix deleted file mode 100755 index 45c1f860..00000000 --- a/bin/ix +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Convenience script for posting to ix.io pastebin -cat -- "${@:--}" | -curl -F 'f:1=<-' http://ix.io/ diff --git a/bin/ix.sh b/bin/ix.sh new file mode 100644 index 00000000..cffc186c --- /dev/null +++ b/bin/ix.sh @@ -0,0 +1,3 @@ +# Convenience script for posting to ix.io pastebin +cat -- "${@:--}" | +curl -F 'f:1=<-' http://ix.io/ diff --git a/bin/jfc b/bin/jfc deleted file mode 100755 index 33d0fe5d..00000000 --- a/bin/jfc +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Commit all changes to a Git repository with a stock message message - -# Enter the given directory, default to the current one -cd -- "${1:-.}" || exit - -# Check if there are any changes; if not, don't proceed (but it's not an error) -grc || exit 0 - -# Add all changes -git add --all || exit - -# Quietly commit with a stock message and use its exit value as ours -git commit --message 'Committed by jfc(1df)' --quiet diff --git a/bin/jfc.sh b/bin/jfc.sh new file mode 100644 index 00000000..3d155aca --- /dev/null +++ b/bin/jfc.sh @@ -0,0 +1,13 @@ +# Commit all changes to a Git repository with a stock message message + +# Enter the given directory, default to the current one +cd -- "${1:-.}" || exit + +# Check if there are any changes; if not, don't proceed (but it's not an error) +grc || exit 0 + +# Add all changes +git add --all || exit + +# Quietly commit with a stock message and use its exit value as ours +git commit --message 'Committed by jfc(1df)' --quiet diff --git a/bin/jfcd b/bin/jfcd deleted file mode 100755 index 8bd54e3b..00000000 --- a/bin/jfcd +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Watch a directory for changes and commit them with jfc(1d) if there are any; -# requires inotifywait(1) -self=jfcd - -# Function wrapper around inotifywait(1) -inw() { - inotifywait \ - @./.git \ - -e create -e delete -e modify -e move \ - --recursive \ - --syslog \ - . | - logger --tag "$self" -} - -# Directory to check is first and only argument; defaults to current directory -cd -- "${1:-.}" || exit - -# Run a while loop over inotifywait(1) calls, running jfc(1d) on the working -# directory -while inw ; do jfc ; done diff --git a/bin/jfcd.sh b/bin/jfcd.sh new file mode 100644 index 00000000..bf059883 --- /dev/null +++ b/bin/jfcd.sh @@ -0,0 +1,22 @@ + +# Watch a directory for changes and commit them with jfc(1d) if there are any; +# requires inotifywait(1) +self=jfcd + +# Function wrapper around inotifywait(1) +inw() { + inotifywait \ + @./.git \ + -e create -e delete -e modify -e move \ + --recursive \ + --syslog \ + . | + logger --tag "$self" +} + +# Directory to check is first and only argument; defaults to current directory +cd -- "${1:-.}" || exit + +# Run a while loop over inotifywait(1) calls, running jfc(1d) on the working +# directory +while inw ; do jfc ; done diff --git a/bin/loc b/bin/loc deleted file mode 100755 index d92dc886..00000000 --- a/bin/loc +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Convenience find(1) wrapper for path substrings - -# Require at least one search term -if [ "$#" -eq 0 ] ; then - printf >&2 'loc: Need a search term\n' - exit 2 -fi - -# Iterate through each search term and run an appropriate find(1) command -for pat ; do - - # Skip dotfiles, dotdirs, and symbolic links; print anything that matches - # the term as a substring (and stop iterating through it) - find . \ - -name .\* ! -name . -prune -o \ - -type l -prune -o \ - -name \*"$pat"\* -prune -print -done diff --git a/bin/loc.sh b/bin/loc.sh new file mode 100644 index 00000000..995c6932 --- /dev/null +++ b/bin/loc.sh @@ -0,0 +1,18 @@ +# Convenience find(1) wrapper for path substrings + +# Require at least one search term +if [ "$#" -eq 0 ] ; then + printf >&2 'loc: Need a search term\n' + exit 2 +fi + +# Iterate through each search term and run an appropriate find(1) command +for pat ; do + + # Skip dotfiles, dotdirs, and symbolic links; print anything that matches + # the term as a substring (and stop iterating through it) + find . \ + -name .\* ! -name . -prune -o \ + -type l -prune -o \ + -name \*"$pat"\* -prune -print +done diff --git a/bin/maybe b/bin/maybe deleted file mode 100755 index a2de17dd..00000000 --- a/bin/maybe +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Exit with success or failure with a given probability -self=maybe - -# Figure out numerator and denominator from arguments -case $# in - 0) num=1 den=2 ;; - 1) num=1 den=$1 ;; - 2) num=$1 den=$2 ;; - *) - printf >&2 '%s: Unexpected arguments\n' "$self" - exit 2 - ;; -esac - -# Numerator must be zero or greater, denominator must be 1 or greater -if [ "$((num >= 0 || den >= 1))" -ne 1 ] ; then - printf >&2 '%s: Illegal numerator/denominator %s\n' "$self" "$num" - exit 2 -fi - -# Perform the test; that's our exit value -seed=$(rnds) -test "$(rndi 1 "$den" "$seed")" -le "$num" diff --git a/bin/maybe.sh b/bin/maybe.sh new file mode 100644 index 00000000..6e5c8658 --- /dev/null +++ b/bin/maybe.sh @@ -0,0 +1,23 @@ +# Exit with success or failure with a given probability +self=maybe + +# Figure out numerator and denominator from arguments +case $# in + 0) num=1 den=2 ;; + 1) num=1 den=$1 ;; + 2) num=$1 den=$2 ;; + *) + printf >&2 '%s: Unexpected arguments\n' "$self" + exit 2 + ;; +esac + +# Numerator must be zero or greater, denominator must be 1 or greater +if [ "$((num >= 0 || den >= 1))" -ne 1 ] ; then + printf >&2 '%s: Illegal numerator/denominator %s\n' "$self" "$num" + exit 2 +fi + +# Perform the test; that's our exit value +seed=$(rnds) +test "$(rndi 1 "$den" "$seed")" -le "$num" diff --git a/bin/mex b/bin/mex deleted file mode 100755 index 005149d8..00000000 --- a/bin/mex +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Make the first non-executable instance of files with the given names in $PATH -# executable -self=mex - -# Check we have at least one argument -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: At least one name required\n' "$self" - exit 2 -fi - -# Iterate through the given names -for name ; do - - # Clear the found variable - found= - - # Start iterating through $PATH, with colon prefix/suffix to correctly - # handle the fenceposts - path=:$PATH: - while [ -n "$path" ] ; do - - # Pop the first directory off $path into $dir - dir=${path%%:*} - path=${path#*:} - - # Check $dir is non-null - [ -n "$dir" ] || continue - - # If a file with the needed name exists in the directory and isn't - # executable, we've found our candidate and can stop iterating - if [ -f "$dir"/"$name" ] && ! [ -x "$dir"/"$name" ] ; then - found=$dir/$name - break - fi - done - - # If the "found" variable was defined to something, we'll try to change its - # permissions - if [ -n "$found" ] ; then - chmod +x -- "$found" || ex=1 - - # If not, we'll report that we couldn't find it, and flag an error for the - # exit status - else - printf >&2 '%s: No non-executable name "%s" in PATH\n' "$self" "$name" - ex=1 - fi -done - -# We exit 1 if any of the names weren't found or if changing their permissions -# failed -exit "${ex:-0}" diff --git a/bin/mex.sh b/bin/mex.sh new file mode 100644 index 00000000..0b3d6c7e --- /dev/null +++ b/bin/mex.sh @@ -0,0 +1,52 @@ +# Make the first non-executable instance of files with the given names in $PATH +# executable +self=mex + +# Check we have at least one argument +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: At least one name required\n' "$self" + exit 2 +fi + +# Iterate through the given names +for name ; do + + # Clear the found variable + found= + + # Start iterating through $PATH, with colon prefix/suffix to correctly + # handle the fenceposts + path=:$PATH: + while [ -n "$path" ] ; do + + # Pop the first directory off $path into $dir + dir=${path%%:*} + path=${path#*:} + + # Check $dir is non-null + [ -n "$dir" ] || continue + + # If a file with the needed name exists in the directory and isn't + # executable, we've found our candidate and can stop iterating + if [ -f "$dir"/"$name" ] && ! [ -x "$dir"/"$name" ] ; then + found=$dir/$name + break + fi + done + + # If the "found" variable was defined to something, we'll try to change its + # permissions + if [ -n "$found" ] ; then + chmod +x -- "$found" || ex=1 + + # If not, we'll report that we couldn't find it, and flag an error for the + # exit status + else + printf >&2 '%s: No non-executable name "%s" in PATH\n' "$self" "$name" + ex=1 + fi +done + +# We exit 1 if any of the names weren't found or if changing their permissions +# failed +exit "${ex:-0}" diff --git a/bin/mkcp b/bin/mkcp deleted file mode 100755 index 37bc87c0..00000000 --- a/bin/mkcp +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Copy files into created directory in one call - -# Check we have at least two arguments -if [ "$#" -lt 2 ] ; then - printf >&2 'mkcp: Need at least one source and destination\n' - exit 2 -fi - -# Get the last argument (the directory to create) -for dir ; do : ; done - -# Create it, or bail -mkdir -p -- "$dir" || exit - -# Copy all the remaining arguments into the directory (which will be the last -# argument) -cp -R -- "$@" diff --git a/bin/mkcp.sh b/bin/mkcp.sh new file mode 100644 index 00000000..10308263 --- /dev/null +++ b/bin/mkcp.sh @@ -0,0 +1,17 @@ +# Copy files into created directory in one call + +# Check we have at least two arguments +if [ "$#" -lt 2 ] ; then + printf >&2 'mkcp: Need at least one source and destination\n' + exit 2 +fi + +# Get the last argument (the directory to create) +for dir ; do : ; done + +# Create it, or bail +mkdir -p -- "$dir" || exit + +# Copy all the remaining arguments into the directory (which will be the last +# argument) +cp -R -- "$@" diff --git a/bin/mkmv b/bin/mkmv deleted file mode 100755 index 803ef05c..00000000 --- a/bin/mkmv +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Move files into created directory in one call - -# Check we have at least two arguments -if [ "$#" -lt 2 ] ; then - printf >&2 'mkmv: Need at least one source and destination\n' - exit 2 -fi - -# Get the last argument (the directory to create) -for dir ; do : ; done - -# Create it, or bail -mkdir -p -- "$dir" || exit - -# Move all the remaining arguments into the directory (which will be the last -# argument) -mv -- "$@" diff --git a/bin/mkmv.sh b/bin/mkmv.sh new file mode 100644 index 00000000..53b5aa8f --- /dev/null +++ b/bin/mkmv.sh @@ -0,0 +1,17 @@ +# Move files into created directory in one call + +# Check we have at least two arguments +if [ "$#" -lt 2 ] ; then + printf >&2 'mkmv: Need at least one source and destination\n' + exit 2 +fi + +# Get the last argument (the directory to create) +for dir ; do : ; done + +# Create it, or bail +mkdir -p -- "$dir" || exit + +# Move all the remaining arguments into the directory (which will be the last +# argument) +mv -- "$@" diff --git a/bin/mktd b/bin/mktd deleted file mode 100755 index 75bbb4b3..00000000 --- a/bin/mktd +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Try to make a random temp directory - -# Get a random seed from rnds(1df); if it's empty, that's still workable -seed=$(rnds) - -# Build the intended directory name, with the last element a random integer -# from 1..2^31 -dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648 "$seed") - -# Create the directory and print its name if successful -mkdir -m 700 -- "$dn" && printf '%s\n' "$dn" diff --git a/bin/mktd.sh b/bin/mktd.sh new file mode 100644 index 00000000..62b10396 --- /dev/null +++ b/bin/mktd.sh @@ -0,0 +1,11 @@ +# Try to make a random temp directory + +# Get a random seed from rnds(1df); if it's empty, that's still workable +seed=$(rnds) + +# Build the intended directory name, with the last element a random integer +# from 1..2^31 +dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648 "$seed") + +# Create the directory and print its name if successful +mkdir -m 700 -- "$dn" && printf '%s\n' "$dn" diff --git a/bin/motd b/bin/motd deleted file mode 100755 index ee60ad03..00000000 --- a/bin/motd +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Show the system MOTD -motd=${MOTD:-/etc/motd} -[ -f "$motd" ] || exit -cat -- "$motd" diff --git a/bin/motd.sh b/bin/motd.sh new file mode 100644 index 00000000..4ac88081 --- /dev/null +++ b/bin/motd.sh @@ -0,0 +1,4 @@ +# Show the system MOTD +motd=${MOTD:-/etc/motd} +[ -f "$motd" ] || exit +cat -- "$motd" diff --git a/bin/murl b/bin/murl deleted file mode 100755 index 95db92c9..00000000 --- a/bin/murl +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Format markdown and pass it to hurl to extract URLs from it. - -# Pipe the output of pandoc(1) on our args into hurl(1df) -pandoc -f markdown -t html -- "${@:-/dev/stdin}" | -hurl diff --git a/bin/murl.sh b/bin/murl.sh new file mode 100644 index 00000000..91304aa1 --- /dev/null +++ b/bin/murl.sh @@ -0,0 +1,5 @@ +# Format markdown and pass it to hurl to extract URLs from it. + +# Pipe the output of pandoc(1) on our args into hurl(1df) +pandoc -f markdown -t html -- "${@:-/dev/stdin}" | +hurl diff --git a/bin/osc b/bin/osc deleted file mode 100755 index 87f79365..00000000 --- a/bin/osc +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# Sane and safe OpenSSL s_client(1ssl) connection -self=osc - -# Check we have openssl(1); we need to fail early lest we go setting up FIFOs -# needlessly -if ! command -v openssl >/dev/null 2>&1 ; then - printf >&2 '%s: openssl(1) not found\n' "$self" - exit 1 -fi - -# Hostname is first argument; assume localhost if empty/unset -host=${1:-localhost} -# Service name or port is second argument; assume HTTPS if empty/unset -serv=${2:-https} - -# Start building the command-line string -set -- -## If we have rlwrap, use it, but don't complain if we don't -if command -v rlwrap >/dev/null 2>&1 ; then - set -- "$@" rlwrap -fi -## The actual openssl(1ssl) and subcommand call -set -- "$@" openssl s_client -## No insecure SSL methods -set -- "$@" -no_ssl2 -no_ssl3 -## Don't dump nonsense to terminal, and don't renegotiate on R or quit on Q -set -- "$@" -quiet -## But do cut the connection if I issue ^D, even though I just set -quiet -set -- "$@" -no_ign_eof -## Do verify the certificate chain and don't connect if we can't -set -- "$@" -verify 5 -verify_return_error -## We might add STARTTLS for the supported services: -case $serv in - ftp|21) - set -- "$@" -starttls ftp - ;; - smtp|25) - set -- "$@" -starttls smtp - ;; - pop3|110) - set -- "$@" -starttls pop3 - ;; - imap|143) - set -- "$@" -starttls imap - ;; - xmpp-client|5222) - set -- "$@" -starttls xmpp - ;; -esac -## Send the host parameter as the server name (SNI) -set -- "$@" -servername "$host" -## Finally, add the host and service to connect to -set -- "$@" -connect "$host":"$serv" - -# Do the POSIX dance to kill child processes and clean up temp files even if -# killed by a signal -td='' fil='' -cleanup() { - trap - EXIT "$1" - [ -n "$fil" ] && kill -TERM "$fil" - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - kill -"$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done - -# Create a temporary directory and a FIFO in it -td=$(mktd "$self") || exit -mkfifo -- "$td"/verify-filter || exit - -# Open a read-write file descriptor onto the FIFO -exec 3<>"$td"/verify-filter || exit - -# Start a background filter process on the FIFO to get rid of the leading -# verification output set to stderr; as soon as we find a single line that -# doesn't look like that routine output, print all future lines to stderr as -# normal -awk ' -body{print;next} -/^verify depth is [0-9]+$/{next} -/^depth=[0-9]+ /{next} -/^verify return:[0-9]+$/{next} -{body=1;print} -' <&3 >&2 & fil=$! - -# Start the process with the options we stacked up -"$@" 2>&3 diff --git a/bin/osc.sh b/bin/osc.sh new file mode 100644 index 00000000..ba35d9b7 --- /dev/null +++ b/bin/osc.sh @@ -0,0 +1,91 @@ +# Sane and safe OpenSSL s_client(1ssl) connection +self=osc + +# Check we have openssl(1); we need to fail early lest we go setting up FIFOs +# needlessly +if ! command -v openssl >/dev/null 2>&1 ; then + printf >&2 '%s: openssl(1) not found\n' "$self" + exit 1 +fi + +# Hostname is first argument; assume localhost if empty/unset +host=${1:-localhost} +# Service name or port is second argument; assume HTTPS if empty/unset +serv=${2:-https} + +# Start building the command-line string +set -- +## If we have rlwrap, use it, but don't complain if we don't +if command -v rlwrap >/dev/null 2>&1 ; then + set -- "$@" rlwrap +fi +## The actual openssl(1ssl) and subcommand call +set -- "$@" openssl s_client +## No insecure SSL methods +set -- "$@" -no_ssl2 -no_ssl3 +## Don't dump nonsense to terminal, and don't renegotiate on R or quit on Q +set -- "$@" -quiet +## But do cut the connection if I issue ^D, even though I just set -quiet +set -- "$@" -no_ign_eof +## Do verify the certificate chain and don't connect if we can't +set -- "$@" -verify 5 -verify_return_error +## We might add STARTTLS for the supported services: +case $serv in + ftp|21) + set -- "$@" -starttls ftp + ;; + smtp|25) + set -- "$@" -starttls smtp + ;; + pop3|110) + set -- "$@" -starttls pop3 + ;; + imap|143) + set -- "$@" -starttls imap + ;; + xmpp-client|5222) + set -- "$@" -starttls xmpp + ;; +esac +## Send the host parameter as the server name (SNI) +set -- "$@" -servername "$host" +## Finally, add the host and service to connect to +set -- "$@" -connect "$host":"$serv" + +# Do the POSIX dance to kill child processes and clean up temp files even if +# killed by a signal +td='' fil='' +cleanup() { + trap - EXIT "$1" + [ -n "$fil" ] && kill -TERM "$fil" + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + kill -"$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done + +# Create a temporary directory and a FIFO in it +td=$(mktd "$self") || exit +mkfifo -- "$td"/verify-filter || exit + +# Open a read-write file descriptor onto the FIFO +exec 3<>"$td"/verify-filter || exit + +# Start a background filter process on the FIFO to get rid of the leading +# verification output set to stderr; as soon as we find a single line that +# doesn't look like that routine output, print all future lines to stderr as +# normal +awk ' +body{print;next} +/^verify depth is [0-9]+$/{next} +/^depth=[0-9]+ /{next} +/^verify return:[0-9]+$/{next} +{body=1;print} +' <&3 >&2 & fil=$! + +# Start the process with the options we stacked up +"$@" 2>&3 diff --git a/bin/pa b/bin/pa deleted file mode 100755 index e03e1bb0..00000000 --- a/bin/pa +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Print arguments, one per line. Compare paz(1df). -[ "$#" -gt 0 ] || exit 0 -printf '%s\n' "$@" diff --git a/bin/pa.sh b/bin/pa.sh new file mode 100644 index 00000000..4cfa9dce --- /dev/null +++ b/bin/pa.sh @@ -0,0 +1,3 @@ +# Print arguments, one per line. Compare paz(1df). +[ "$#" -gt 0 ] || exit 0 +printf '%s\n' "$@" diff --git a/bin/paz b/bin/paz deleted file mode 100755 index b1f09ca9..00000000 --- a/bin/paz +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Print arguments, terminated by null chars. Compare pa(1df). -[ "$#" -gt 0 ] || exit 0 -printf '%s\0' "$@" diff --git a/bin/paz.sh b/bin/paz.sh new file mode 100644 index 00000000..e9b81bd7 --- /dev/null +++ b/bin/paz.sh @@ -0,0 +1,3 @@ +# Print arguments, terminated by null chars. Compare pa(1df). +[ "$#" -gt 0 ] || exit 0 +printf '%s\0' "$@" diff --git a/bin/pit b/bin/pit deleted file mode 100755 index d3068e76..00000000 --- a/bin/pit +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# If no arguments, we'll use stdin -if [ "$#" -eq 0 ] ; then - set -- - -fi - -# If output seems to be to a terminal, try to run input through a pager of some -# sort; we'll fall back on more(1) to be POSIX-ish -if [ -t 1 ] ; then - "${PAGER:-more}" -- "$@" - -# Otherwise, just run it through with cat(1); a good pager does this anyway, -# provided it actually exists -else - cat -- "$@" -fi diff --git a/bin/pit.sh b/bin/pit.sh new file mode 100644 index 00000000..377c1927 --- /dev/null +++ b/bin/pit.sh @@ -0,0 +1,16 @@ + +# If no arguments, we'll use stdin +if [ "$#" -eq 0 ] ; then + set -- - +fi + +# If output seems to be to a terminal, try to run input through a pager of some +# sort; we'll fall back on more(1) to be POSIX-ish +if [ -t 1 ] ; then + "${PAGER:-more}" -- "$@" + +# Otherwise, just run it through with cat(1); a good pager does this anyway, +# provided it actually exists +else + cat -- "$@" +fi diff --git a/bin/plmu b/bin/plmu deleted file mode 100755 index cf9b7eae..00000000 --- a/bin/plmu +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Set up exceptions file if it exists -ef=$HOME/.plenv/non-cpanm-modules -[ -e "$ef" ] || ef=/dev/null - -# Check that exceptions file is sorted -if ! sort -c -- "$ef" ; then - printf >&2 '%s not sorted\n' "$ef" - exit 1 -fi - -# Get the list of modules; sort them in case our current locale disagrees on -# the existing sorting -plenv list-modules | sort | - -# 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 -while read -r module ; do - cpanm --notest --quiet -- "$module" -done diff --git a/bin/plmu.sh b/bin/plmu.sh new file mode 100644 index 00000000..d6f163e6 --- /dev/null +++ b/bin/plmu.sh @@ -0,0 +1,22 @@ + +# Set up exceptions file if it exists +ef=$HOME/.plenv/non-cpanm-modules +[ -e "$ef" ] || ef=/dev/null + +# Check that exceptions file is sorted +if ! sort -c -- "$ef" ; then + printf >&2 '%s not sorted\n' "$ef" + exit 1 +fi + +# Get the list of modules; sort them in case our current locale disagrees on +# the existing sorting +plenv list-modules | sort | + +# 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 +while read -r module ; do + cpanm --notest --quiet -- "$module" +done diff --git a/bin/pp b/bin/pp deleted file mode 100755 index d9fe6488..00000000 --- a/bin/pp +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Print the full path to each argument; path need not exist -for arg ; do - case $arg in - /*) path=$arg ;; - *) path=$PWD/$arg ;; - esac - printf '%s\n' "$path" -done diff --git a/bin/pp.sh b/bin/pp.sh new file mode 100644 index 00000000..b472a012 --- /dev/null +++ b/bin/pp.sh @@ -0,0 +1,8 @@ +# Print the full path to each argument; path need not exist +for arg ; do + case $arg in + /*) path=$arg ;; + *) path=$PWD/$arg ;; + esac + printf '%s\n' "$path" +done diff --git a/bin/pph b/bin/pph deleted file mode 100755 index 7987382f..00000000 --- a/bin/pph +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Run pp(1df) on args, prefix with machine hostname -hn=$(hostname -s) || exit -pp "$@" | -awk -v hn="$hn" '{ print hn ":" $0 }' diff --git a/bin/pph.sh b/bin/pph.sh new file mode 100644 index 00000000..268b6ad7 --- /dev/null +++ b/bin/pph.sh @@ -0,0 +1,4 @@ +# Run pp(1df) on args, prefix with machine hostname +hn=$(hostname -s) || exit +pp "$@" | +awk -v hn="$hn" '{ print hn ":" $0 }' diff --git a/bin/pwg b/bin/pwg deleted file mode 100755 index 97af3df4..00000000 --- a/bin/pwg +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Shortcut to generate just one strong password with pwgen(1) -# If any arguments are provided, those are used instead -if [ "$#" -eq 0 ] ; then - set -- --secure -- "${PWGEN_LENGTH:-16}" "${PWGEN_COUNT:-1}" -fi -pwgen "$@" diff --git a/bin/pwg.sh b/bin/pwg.sh new file mode 100644 index 00000000..e73ae97a --- /dev/null +++ b/bin/pwg.sh @@ -0,0 +1,6 @@ +# Shortcut to generate just one strong password with pwgen(1) +# If any arguments are provided, those are used instead +if [ "$#" -eq 0 ] ; then + set -- --secure -- "${PWGEN_LENGTH:-16}" "${PWGEN_COUNT:-1}" +fi +pwgen "$@" diff --git a/bin/rfcf b/bin/rfcf deleted file mode 100755 index 6f257415..00000000 --- a/bin/rfcf +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Check arguments -if [ "$#" -ne 1 ] ; then - printf >&2 'rfcf: Need one RFC number\n' - exit 2 -fi - -# Argument is RFC number -rn=$1 - -# Retrieve the RFC with curl(1) -curl -fsSL https://tools.ietf.org/rfc/rfc"$rn".txt diff --git a/bin/rfcf.sh b/bin/rfcf.sh new file mode 100644 index 00000000..36b1a4c4 --- /dev/null +++ b/bin/rfcf.sh @@ -0,0 +1,12 @@ + +# Check arguments +if [ "$#" -ne 1 ] ; then + printf >&2 'rfcf: Need one RFC number\n' + exit 2 +fi + +# Argument is RFC number +rn=$1 + +# Retrieve the RFC with curl(1) +curl -fsSL https://tools.ietf.org/rfc/rfc"$rn".txt diff --git a/bin/rfcr b/bin/rfcr deleted file mode 100755 index 75d9abb0..00000000 --- a/bin/rfcr +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Check arguments -if [ "$#" -ne 1 ] ; then - printf >&2 'rfcf: Need one RFC number\n' - exit 2 -fi - -# Argument is RFC number -rn=$1 - -# Retrieve the RFC with rfcf(1df) -rfcf "$rn" | - -# Pipe it through rfct(1df) to format it as text -rfct | - -# Either spit it directly or through a pager -pit diff --git a/bin/rfcr.sh b/bin/rfcr.sh new file mode 100644 index 00000000..860ae53d --- /dev/null +++ b/bin/rfcr.sh @@ -0,0 +1,18 @@ + +# Check arguments +if [ "$#" -ne 1 ] ; then + printf >&2 'rfcf: Need one RFC number\n' + exit 2 +fi + +# Argument is RFC number +rn=$1 + +# Retrieve the RFC with rfcf(1df) +rfcf "$rn" | + +# Pipe it through rfct(1df) to format it as text +rfct | + +# Either spit it directly or through a pager +pit diff --git a/bin/rgl b/bin/rgl deleted file mode 100755 index a06ecd0a..00000000 --- a/bin/rgl +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Read grep(1) patterns from input and search for them in the given files -self=rgl - -# Check the arguments -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need at least one filename\n' "$self" - exit 2 -fi - -# Iterate over the patterns and search for each one -while { - - # If the input is a terminal, print a slash prompt for the next pattern; - # try to print it in bold red, too, but discard stderr if we can't - if [ -t 0 ] ; then - tput setaf 1 || tput setaf 1 0 0 || tput AF 1 || tput AF 1 0 0 - tput bold || tput md - printf '%s/' "$self" - tput sgr0 || tput me - fi 2>/dev/null - - # Read the pattern - IFS= read -r pat - -} ; do - - # Run grep(1) with the read pattern over the arguments - grep -- "$pat" "$@" -done - -# Print a newline if this was a terminal to clear the prompt -if [ -t 0 ] ; then - printf '\n' -fi diff --git a/bin/rgl.sh b/bin/rgl.sh new file mode 100644 index 00000000..630d38b6 --- /dev/null +++ b/bin/rgl.sh @@ -0,0 +1,34 @@ +# Read grep(1) patterns from input and search for them in the given files +self=rgl + +# Check the arguments +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need at least one filename\n' "$self" + exit 2 +fi + +# Iterate over the patterns and search for each one +while { + + # If the input is a terminal, print a slash prompt for the next pattern; + # try to print it in bold red, too, but discard stderr if we can't + if [ -t 0 ] ; then + tput setaf 1 || tput setaf 1 0 0 || tput AF 1 || tput AF 1 0 0 + tput bold || tput md + printf '%s/' "$self" + tput sgr0 || tput me + fi 2>/dev/null + + # Read the pattern + IFS= read -r pat + +} ; do + + # Run grep(1) with the read pattern over the arguments + grep -- "$pat" "$@" +done + +# Print a newline if this was a terminal to clear the prompt +if [ -t 0 ] ; then + printf '\n' +fi diff --git a/bin/rnda b/bin/rnda deleted file mode 100755 index 5af4a3bd..00000000 --- a/bin/rnda +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# Choose a random argument using rndi(1df) - -# Check we have at least one argument -if [ "$#" -eq 0 ] ; then - printf >&2 'rnda: No args given\n' - exit 2 -fi - -# Get a random seed from rnds(1df); if it's empty, that's still workable -seed=$(rnds) - -# Get a random integet from 1 to the number of arguments -argi=$(rndi 1 "$#" "$seed") || exit - -# Shift until that argument is the first argument -shift "$((argi-1))" - -# Print it -printf '%s\n' "$1" diff --git a/bin/rnda.sh b/bin/rnda.sh new file mode 100644 index 00000000..b09a8b6f --- /dev/null +++ b/bin/rnda.sh @@ -0,0 +1,19 @@ +# Choose a random argument using rndi(1df) + +# Check we have at least one argument +if [ "$#" -eq 0 ] ; then + printf >&2 'rnda: No args given\n' + exit 2 +fi + +# Get a random seed from rnds(1df); if it's empty, that's still workable +seed=$(rnds) + +# Get a random integet from 1 to the number of arguments +argi=$(rndi 1 "$#" "$seed") || exit + +# Shift until that argument is the first argument +shift "$((argi-1))" + +# Print it +printf '%s\n' "$1" diff --git a/bin/rndf b/bin/rndf deleted file mode 100755 index 67f9d997..00000000 --- a/bin/rndf +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Choose a random file from a given directory using rnda(1df); ignores dot -# files - -# Directory is first argument; defaults to current directory -dir=${1:-.} - -# Set the positional parameters to all the non-dotfiles in that directory -set -- "$dir"/* - -# Check for an unexpanded glob (empty directory) -if ! [ -e "$1" ] ; then - printf >&2 'rndf: No files found in %s\n' "$dir" - exit 1 -fi - -# Print a random argument from the current positional parameters -rnda "$@" diff --git a/bin/rndf.sh b/bin/rndf.sh new file mode 100644 index 00000000..21aa76a6 --- /dev/null +++ b/bin/rndf.sh @@ -0,0 +1,17 @@ +# Choose a random file from a given directory using rnda(1df); ignores dot +# files + +# Directory is first argument; defaults to current directory +dir=${1:-.} + +# Set the positional parameters to all the non-dotfiles in that directory +set -- "$dir"/* + +# Check for an unexpanded glob (empty directory) +if ! [ -e "$1" ] ; then + printf >&2 'rndf: No files found in %s\n' "$dir" + exit 1 +fi + +# Print a random argument from the current positional parameters +rnda "$@" diff --git a/bin/rndl b/bin/rndl deleted file mode 100755 index c09c2c78..00000000 --- a/bin/rndl +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Print a random line from input -self=rndl - -# If there are no arguments, we're checking stdin; this is more complicated -# than checking file arguments because we have to count the lines in order to -# correctly choose a random one, and two passes means we require a temporary -# file if we don't want to read all of the input into memory (!) -if [ "$#" -eq 0 ] ; then - - # Create a temporary directory with name in $td, and handle POSIX-ish traps to - # remove it when the script exits. - td= - cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi - } - for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" - done - td=$(mktd "$self") || exit - - # We'll operate on stdin in the temp directory; write the script's stdin to - # it with cat(1) - set -- "$td"/stdin - cat >"$td"/stdin -fi - -# Count the number of lines in the input -lc=$(sed -- '$=;d' "$@") || exit - -# If there were none, bail -case $lc in - ''|0) - printf >&2 'rndl: No lines found on input\n' - exit 2 - ;; -esac - -# Try to get a random seed from rnds(1df) for rndi(1df) -seed=$(rnds) - -# Get a random line number from rndi(1df) -ri=$(rndi 1 "$lc" "$seed") || exit - -# Print the line using sed(1) -sed -- "$ri"'!d' "$@" diff --git a/bin/rndl.sh b/bin/rndl.sh new file mode 100644 index 00000000..18bcec07 --- /dev/null +++ b/bin/rndl.sh @@ -0,0 +1,50 @@ +# Print a random line from input +self=rndl + +# If there are no arguments, we're checking stdin; this is more complicated +# than checking file arguments because we have to count the lines in order to +# correctly choose a random one, and two passes means we require a temporary +# file if we don't want to read all of the input into memory (!) +if [ "$#" -eq 0 ] ; then + + # Create a temporary directory with name in $td, and handle POSIX-ish traps to + # remove it when the script exits. + td= + cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi + } + for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" + done + td=$(mktd "$self") || exit + + # We'll operate on stdin in the temp directory; write the script's stdin to + # it with cat(1) + set -- "$td"/stdin + cat >"$td"/stdin +fi + +# Count the number of lines in the input +lc=$(sed -- '$=;d' "$@") || exit + +# If there were none, bail +case $lc in + ''|0) + printf >&2 'rndl: No lines found on input\n' + exit 2 + ;; +esac + +# Try to get a random seed from rnds(1df) for rndi(1df) +seed=$(rnds) + +# Get a random line number from rndi(1df) +ri=$(rndi 1 "$lc" "$seed") || exit + +# Print the line using sed(1) +sed -- "$ri"'!d' "$@" diff --git a/bin/rnds b/bin/rnds deleted file mode 100755 index c5ffabe4..00000000 --- a/bin/rnds +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Try to get a low-quality random seed from a random device if possible - -# Sole optional argument is the bytes to read; 32 is the default -count=${1:-32} - -# Try and find a random device to use; none of these are specified by POSIX -for dev in /dev/urandom /dev/arandom /dev/random '' ; do - [ -e "$dev" ] && break -done - -# Bail if we couldn't find a random device -[ -n "$dev" ] || exit 1 - -# Read the bytes from the device -dd if="$dev" bs=1 count="$count" 2>/dev/null | - -# Run cksum(1) over the read random bytes -cksum | - -# cut(1) the cksum(1) output to only the first field, and print that to stdout -cut -d' ' -f1 diff --git a/bin/rnds.sh b/bin/rnds.sh new file mode 100644 index 00000000..6b3ac904 --- /dev/null +++ b/bin/rnds.sh @@ -0,0 +1,21 @@ +# Try to get a low-quality random seed from a random device if possible + +# Sole optional argument is the bytes to read; 32 is the default +count=${1:-32} + +# Try and find a random device to use; none of these are specified by POSIX +for dev in /dev/urandom /dev/arandom /dev/random '' ; do + [ -e "$dev" ] && break +done + +# Bail if we couldn't find a random device +[ -n "$dev" ] || exit 1 + +# Read the bytes from the device +dd if="$dev" bs=1 count="$count" 2>/dev/null | + +# Run cksum(1) over the read random bytes +cksum | + +# cut(1) the cksum(1) output to only the first field, and print that to stdout +cut -d' ' -f1 diff --git a/bin/shb b/bin/shb deleted file mode 100755 index 72ac818b..00000000 --- a/bin/shb +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Use PATH to build a shebang for a script given on stdin -self=shb - -# Need at least two arguments -if [ "$#" -lt 1 ] ; then - printf >&2 '%s: Need interpreter command\n' "$self" - exit 1 -fi - -# First argument is the name of the interpreter -intn=$1 -shift - -# Try and find the path to the interpreter command, bail out if we can't -if ! intp=$(command -v "$intn" 2>/dev/null) ; then - printf >&2 '%s: %s: command not found\n' "$self" "$intn" - exit 1 -fi - -# Set the positional parameters to the path and any remaining arguments, and -# squash them together for the shebang line -set -- "$intp" "$@" -printf '#!%s\n' "$*" - -# Emit the rest of the input -cat diff --git a/bin/shb.sh b/bin/shb.sh new file mode 100644 index 00000000..7d31876d --- /dev/null +++ b/bin/shb.sh @@ -0,0 +1,26 @@ +# Use PATH to build a shebang for a script given on stdin +self=shb + +# Need at least two arguments +if [ "$#" -lt 1 ] ; then + printf >&2 '%s: Need interpreter command\n' "$self" + exit 1 +fi + +# First argument is the name of the interpreter +intn=$1 +shift + +# Try and find the path to the interpreter command, bail out if we can't +if ! intp=$(command -v "$intn" 2>/dev/null) ; then + printf >&2 '%s: %s: command not found\n' "$self" "$intn" + exit 1 +fi + +# Set the positional parameters to the path and any remaining arguments, and +# squash them together for the shebang line +set -- "$intp" "$@" +printf '#!%s\n' "$*" + +# Emit the rest of the input +cat diff --git a/bin/slow b/bin/slow deleted file mode 100755 index a7bdae76..00000000 --- a/bin/slow +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Convert uppercase letters in a stream to lowercase -cat "${@:--}" | -tr '[:upper:]' '[:lower:]' diff --git a/bin/slow.sh b/bin/slow.sh new file mode 100644 index 00000000..b0047829 --- /dev/null +++ b/bin/slow.sh @@ -0,0 +1,3 @@ +# Convert uppercase letters in a stream to lowercase +cat "${@:--}" | +tr '[:upper:]' '[:lower:]' diff --git a/bin/sls b/bin/sls deleted file mode 100755 index 770b8ec0..00000000 --- a/bin/sls +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# Print hostnames from ssh_config(5) files, defaulting to the usual paths - -# If we weren't given a file explicitly, we'll try to read both /etc/ssh_config -# and ~/.ssh_config in that order if they exist -if [ "$#" -eq 0 ] ; then - for cfg in /etc/ssh_config "$HOME"/.ssh/config ; do - [ -e "$cfg" ] || continue - set -- "$@" "$cfg" - done -fi - -# If we still have no files to read, bail out and warn the user -if [ "$#" -eq 0 ] ; then - printf >&2 'sls: ssh_config(5) paths not found, need argument\n' - exit 1 -fi - -# Otherwise, we can run slsf(1df) over the ones we did collect -slsf -- "$@" diff --git a/bin/sls.sh b/bin/sls.sh new file mode 100644 index 00000000..55c1dfc7 --- /dev/null +++ b/bin/sls.sh @@ -0,0 +1,19 @@ +# Print hostnames from ssh_config(5) files, defaulting to the usual paths + +# If we weren't given a file explicitly, we'll try to read both /etc/ssh_config +# and ~/.ssh_config in that order if they exist +if [ "$#" -eq 0 ] ; then + for cfg in /etc/ssh_config "$HOME"/.ssh/config ; do + [ -e "$cfg" ] || continue + set -- "$@" "$cfg" + done +fi + +# If we still have no files to read, bail out and warn the user +if [ "$#" -eq 0 ] ; then + printf >&2 'sls: ssh_config(5) paths not found, need argument\n' + exit 1 +fi + +# Otherwise, we can run slsf(1df) over the ones we did collect +slsf -- "$@" diff --git a/bin/sqs b/bin/sqs deleted file mode 100755 index d0b3023f..00000000 --- a/bin/sqs +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Chop a trailing query string off filenames -self=sqs - -# Check args -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need a filename\n' "$self" - exit 2 -fi - -# Iterate through the given files -for sn ; do - - # Strip trailing slash if any and then query string - sn=${sn%/} - dn=${sn%%\?*} - - # Ignore this file if its name wouldn't change - [ "$sn" != "$dn" ] || continue - - # Ignore this file if its name already exists (don't overwrite) - if [ -e "$dn" ] ; then - printf >&2 '%s: File named %s already exists\n' \ - "$self" "$dn" - ex=1 - continue - fi - - # Attempt a rename, flag an error if there was one - mv -- "$sn" "$dn" || ex=1 -done - -# Exit with 1 if there was any failed mv(1) run -exit "${ex:-0}" diff --git a/bin/sqs.sh b/bin/sqs.sh new file mode 100644 index 00000000..e00797e3 --- /dev/null +++ b/bin/sqs.sh @@ -0,0 +1,33 @@ +# Chop a trailing query string off filenames +self=sqs + +# Check args +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a filename\n' "$self" + exit 2 +fi + +# Iterate through the given files +for sn ; do + + # Strip trailing slash if any and then query string + sn=${sn%/} + dn=${sn%%\?*} + + # Ignore this file if its name wouldn't change + [ "$sn" != "$dn" ] || continue + + # Ignore this file if its name already exists (don't overwrite) + if [ -e "$dn" ] ; then + printf >&2 '%s: File named %s already exists\n' \ + "$self" "$dn" + ex=1 + continue + fi + + # Attempt a rename, flag an error if there was one + mv -- "$sn" "$dn" || ex=1 +done + +# Exit with 1 if there was any failed mv(1) run +exit "${ex:-0}" diff --git a/bin/sra b/bin/sra deleted file mode 100755 index 7f072dfb..00000000 --- a/bin/sra +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Run ssh(1) with an optional command on every host in sls(1df) output -# Use FD3 to keep a reference to the script's stdin for the ssh(1) calls -exec 3<&0 -sls | while read -r hostname ; do - printf 'sra: %s\n' "$hostname" - ssh -qt -- "$hostname" "$@" <&3 # shellcheck disable=SC2029 -done diff --git a/bin/sra.sh b/bin/sra.sh new file mode 100644 index 00000000..f3ed6f71 --- /dev/null +++ b/bin/sra.sh @@ -0,0 +1,7 @@ +# Run ssh(1) with an optional command on every host in sls(1df) output +# Use FD3 to keep a reference to the script's stdin for the ssh(1) calls +exec 3<&0 +sls | while read -r hostname ; do + printf 'sra: %s\n' "$hostname" + ssh -qt -- "$hostname" "$@" <&3 # shellcheck disable=SC2029 +done diff --git a/bin/sshi b/bin/sshi deleted file mode 100755 index 80e00a10..00000000 --- a/bin/sshi +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Print some human-readable information from SSH_CONNECTION - -# Check we have an SSH_CONNECTION variable -if [ -z "$SSH_CONNECTION" ] ; then - printf >&2 'sshi: SSH_CONNECTION appears empty\n' - exit 1 -fi - -# Print the two variables into a compound command so we can `read` them -printf '%s\n' "$SSH_CONNECTION" "${SSH_TTY:-unknown}" | -{ - # Read connection details from first line - read -r ci cp si sp - - # Read TTY from second line - read -r tty - - # Try to resolve the client and server IPs - ch=$(dig -x "$ci" +short 2>/dev/null | sed 's/\.$//;1q') - sh=$(dig -x "$si" +short 2>/dev/null | sed 's/\.$//;1q') - - # Print the results in a human-readable format - printf "%s:%u -> %s:%u (%s)\n" \ - "${ch:-"$ci"}" "$cp" \ - "${sh:-"$si"}" "$sp" \ - "$tty" -} diff --git a/bin/sshi.sh b/bin/sshi.sh new file mode 100644 index 00000000..0d1591f1 --- /dev/null +++ b/bin/sshi.sh @@ -0,0 +1,27 @@ +# Print some human-readable information from SSH_CONNECTION + +# Check we have an SSH_CONNECTION variable +if [ -z "$SSH_CONNECTION" ] ; then + printf >&2 'sshi: SSH_CONNECTION appears empty\n' + exit 1 +fi + +# Print the two variables into a compound command so we can `read` them +printf '%s\n' "$SSH_CONNECTION" "${SSH_TTY:-unknown}" | +{ + # Read connection details from first line + read -r ci cp si sp + + # Read TTY from second line + read -r tty + + # Try to resolve the client and server IPs + ch=$(dig -x "$ci" +short 2>/dev/null | sed 's/\.$//;1q') + sh=$(dig -x "$si" +short 2>/dev/null | sed 's/\.$//;1q') + + # Print the results in a human-readable format + printf "%s:%u -> %s:%u (%s)\n" \ + "${ch:-"$ci"}" "$cp" \ + "${sh:-"$si"}" "$sp" \ + "$tty" +} diff --git a/bin/sta b/bin/sta deleted file mode 100755 index 848d9740..00000000 --- a/bin/sta +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Print list of sls(1df) hostnames that exit 0 when a connection is attempted -# and the optional given command is run. Discard stdout, but preserve stderr. -sls | while read -r hostname ; do - # shellcheck disable=SC2029 - ssh -nq -- "$hostname" "$@" >/dev/null || continue - printf '%s\n' "$hostname" -done diff --git a/bin/sta.sh b/bin/sta.sh new file mode 100644 index 00000000..5736842a --- /dev/null +++ b/bin/sta.sh @@ -0,0 +1,7 @@ +# Print list of sls(1df) hostnames that exit 0 when a connection is attempted +# and the optional given command is run. Discard stdout, but preserve stderr. +sls | while read -r hostname ; do + # shellcheck disable=SC2029 + ssh -nq -- "$hostname" "$@" >/dev/null || continue + printf '%s\n' "$hostname" +done diff --git a/bin/stbl b/bin/stbl deleted file mode 100755 index 34a06251..00000000 --- a/bin/stbl +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Strip a trailing blank line from the given files with ed(1) - -# Check arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'stbl: Need a filename\n' - exit 2 -fi - -# Iterate over arguments and apply the same ed(1) script to each of them -for fn ; do - ed -s -- "$fn" <<'EOF' || ex=1 -$g/^ *$/d -w -EOF -done - -# If any of the ed(1) commands failed, we should exit with 1 -exit "${ex:-0}" diff --git a/bin/stbl.sh b/bin/stbl.sh new file mode 100644 index 00000000..23d77703 --- /dev/null +++ b/bin/stbl.sh @@ -0,0 +1,18 @@ +# Strip a trailing blank line from the given files with ed(1) + +# Check arguments +if [ "$#" -eq 0 ] ; then + printf >&2 'stbl: Need a filename\n' + exit 2 +fi + +# Iterate over arguments and apply the same ed(1) script to each of them +for fn ; do + ed -s -- "$fn" <<'EOF' || ex=1 +$g/^ *$/d +w +EOF +done + +# If any of the ed(1) commands failed, we should exit with 1 +exit "${ex:-0}" diff --git a/bin/stex b/bin/stex deleted file mode 100755 index f1f9c029..00000000 --- a/bin/stex +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Strip an extension from the given filenames -self=stex - -# Check args -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need an extension .ext and a filename\n' \ - "$self" - exit 2 -fi - -# Extension is first arg, shift it off -ext=$1 -shift - -# Iterate through the given files (remaining args) -for sn ; do - - # Strip trailing slash if any and then extension - sn=${sn%/} - dn=${sn%"$ext"} - - # Ignore this file if its name wouldn't change - [ "$sn" != "$dn" ] || continue - - # Ignore this file if its name already exists (don't overwrite) - if [ -e "$dn" ] ; then - printf >&2 '%s: File named %s already exists\n' \ - "$self" "$dn" - ex=1 - continue - fi - - # Attempt a rename, flag an error if there was one - mv -- "$sn" "$dn" || ex=1 -done - -# Exit with 1 if there was any failed mv(1) run -exit "${ex:-0}" diff --git a/bin/stex.sh b/bin/stex.sh new file mode 100644 index 00000000..14d2cabf --- /dev/null +++ b/bin/stex.sh @@ -0,0 +1,38 @@ +# Strip an extension from the given filenames +self=stex + +# Check args +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need an extension .ext and a filename\n' \ + "$self" + exit 2 +fi + +# Extension is first arg, shift it off +ext=$1 +shift + +# Iterate through the given files (remaining args) +for sn ; do + + # Strip trailing slash if any and then extension + sn=${sn%/} + dn=${sn%"$ext"} + + # Ignore this file if its name wouldn't change + [ "$sn" != "$dn" ] || continue + + # Ignore this file if its name already exists (don't overwrite) + if [ -e "$dn" ] ; then + printf >&2 '%s: File named %s already exists\n' \ + "$self" "$dn" + ex=1 + continue + fi + + # Attempt a rename, flag an error if there was one + mv -- "$sn" "$dn" || ex=1 +done + +# Exit with 1 if there was any failed mv(1) run +exit "${ex:-0}" diff --git a/bin/stws b/bin/stws deleted file mode 100755 index 2ceae935..00000000 --- a/bin/stws +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Strip trailing spaces on one or more files - -# Check arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'stws: Need a filename\n' - exit 2 -fi - -# Iterate over arguments and apply the same ed(1) script to each of them -for fn ; do - ed -s -- "$fn" <<'EOF' || ex=1 -g/ *$/ s/ *$// -w -EOF -done - -# If any of the ed(1) commands failed, we should exit with 1 -exit "${ex:-0}" diff --git a/bin/stws.sh b/bin/stws.sh new file mode 100644 index 00000000..ce2c14d0 --- /dev/null +++ b/bin/stws.sh @@ -0,0 +1,18 @@ +# Strip trailing spaces on one or more files + +# Check arguments +if [ "$#" -eq 0 ] ; then + printf >&2 'stws: Need a filename\n' + exit 2 +fi + +# Iterate over arguments and apply the same ed(1) script to each of them +for fn ; do + ed -s -- "$fn" <<'EOF' || ex=1 +g/ *$/ s/ *$// +w +EOF +done + +# If any of the ed(1) commands failed, we should exit with 1 +exit "${ex:-0}" diff --git a/bin/sue b/bin/sue deleted file mode 100755 index 64d566f7..00000000 --- a/bin/sue +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Run sudoedit(8) with an appropriate user on a set of files - -# Blank out the user variable -user= - -# Iterate over the given files -for file ; do - - # Get the file's owner, or bail - file_owner=$(stat -c %U -- "$file") || exit - - # Check that this file has the same owner as all previously checked files, - # if any - case $user in - "$file_owner"|'') - user=$file_owner - ;; - *) - printf >&2 'sue: Files do not share a common owner\n' - exit 1 - ;; - esac -done - -# Run sudoedit(8) as the user that owns all the files -sudoedit -u "$user" -- "$@" diff --git a/bin/sue.sh b/bin/sue.sh new file mode 100644 index 00000000..654c041f --- /dev/null +++ b/bin/sue.sh @@ -0,0 +1,26 @@ +# Run sudoedit(8) with an appropriate user on a set of files + +# Blank out the user variable +user= + +# Iterate over the given files +for file ; do + + # Get the file's owner, or bail + file_owner=$(stat -c %U -- "$file") || exit + + # Check that this file has the same owner as all previously checked files, + # if any + case $user in + "$file_owner"|'') + user=$file_owner + ;; + *) + printf >&2 'sue: Files do not share a common owner\n' + exit 1 + ;; + esac +done + +# Run sudoedit(8) as the user that owns all the files +sudoedit -u "$user" -- "$@" diff --git a/bin/supp b/bin/supp deleted file mode 100755 index 1ba6c850..00000000 --- a/bin/supp +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Convert lowercase letters in a stream to uppercase -cat "${@:--}" | -tr '[:lower:]' '[:upper:]' diff --git a/bin/supp.sh b/bin/supp.sh new file mode 100644 index 00000000..5ddbadc3 --- /dev/null +++ b/bin/supp.sh @@ -0,0 +1,3 @@ +# Convert lowercase letters in a stream to uppercase +cat "${@:--}" | +tr '[:lower:]' '[:upper:]' diff --git a/bin/swr b/bin/swr deleted file mode 100755 index 56ab5919..00000000 --- a/bin/swr +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Transparently wrap scp(1) targets on the command line -self=swr - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Set a flag to manage resetting the positional parameters at the start of the -# loop -n=1 -for arg ; do - - # If this is our first iteration, reset the shell parameters - case $n in - 1) set -- ;; - esac - - # Test whether this argument looks like a remote file - if ( - - # Test it contains a colon - case $arg in - *:*) ;; - *) exit 1 ;; - esac - - # Test the part before the first colon has at least one character and - # only hostname characters - case ${arg%%:*} in - '') exit 1 ;; - *[!a-zA-Z0-9-.]*) exit 1 ;; - esac - - ) ; then - - # Looks like a remote file request; try to copy it into the temporary - # directory, bail out completely if we can't - dst=$td/$n - scp -q -- "$arg" "$dst" || exit - set -- "$@" "$dst" - - else - # Just a plain old argument; stack it up - set -- "$@" "$arg" - fi - - # Bump n - n=$((n+1)) -done - -# Run the command with the processed arguments -exec "$@" diff --git a/bin/swr.sh b/bin/swr.sh new file mode 100644 index 00000000..47c84b86 --- /dev/null +++ b/bin/swr.sh @@ -0,0 +1,64 @@ +# Transparently wrap scp(1) targets on the command line +self=swr + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Set a flag to manage resetting the positional parameters at the start of the +# loop +n=1 +for arg ; do + + # If this is our first iteration, reset the shell parameters + case $n in + 1) set -- ;; + esac + + # Test whether this argument looks like a remote file + if ( + + # Test it contains a colon + case $arg in + *:*) ;; + *) exit 1 ;; + esac + + # Test the part before the first colon has at least one character and + # only hostname characters + case ${arg%%:*} in + '') exit 1 ;; + *[!a-zA-Z0-9-.]*) exit 1 ;; + esac + + ) ; then + + # Looks like a remote file request; try to copy it into the temporary + # directory, bail out completely if we can't + dst=$td/$n + scp -q -- "$arg" "$dst" || exit + set -- "$@" "$dst" + + else + # Just a plain old argument; stack it up + set -- "$@" "$arg" + fi + + # Bump n + n=$((n+1)) +done + +# Run the command with the processed arguments +exec "$@" diff --git a/bin/td b/bin/td deleted file mode 100755 index 69077a8d..00000000 --- a/bin/td +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Manage to-do files with just $EDITOR and git(1) - -# Specify the path and file -dir=${TODO_DIR:-"$HOME"/Todo} -file=${1:-"${TODO_NAME:-todo}"} - -# If the directory doesn't exist, create it -[ -d "$dir" ] || mkdir -p -- "$dir" || exit - -# Change into the directory -cd -- "$dir" || exit - -# If the current directory isn't a Git repository, try to create one -if ! command -v isgr >/dev/null 2>&1 ; then - printf >&2 'isgr: command not found\n' - exit 1 -fi -isgr || git init || exit - -# If the to-do file doesn't exist yet, create it -[ -e "$file" ] || touch -- "$file" || exit - -# Launch an appropriate editor to edit that file -"${VISUAL:-"${EDITOR:-ed}"}" "$file" - -# Add the file to the changeset -git add -- "$file" - -# If there are changes to commit, commit them -git diff-index --quiet HEAD || -git commit --message 'Changed by td(1df)' --quiet diff --git a/bin/td.sh b/bin/td.sh new file mode 100644 index 00000000..eaae1fd6 --- /dev/null +++ b/bin/td.sh @@ -0,0 +1,31 @@ +# Manage to-do files with just $EDITOR and git(1) + +# Specify the path and file +dir=${TODO_DIR:-"$HOME"/Todo} +file=${1:-"${TODO_NAME:-todo}"} + +# If the directory doesn't exist, create it +[ -d "$dir" ] || mkdir -p -- "$dir" || exit + +# Change into the directory +cd -- "$dir" || exit + +# If the current directory isn't a Git repository, try to create one +if ! command -v isgr >/dev/null 2>&1 ; then + printf >&2 'isgr: command not found\n' + exit 1 +fi +isgr || git init || exit + +# If the to-do file doesn't exist yet, create it +[ -e "$file" ] || touch -- "$file" || exit + +# Launch an appropriate editor to edit that file +"${VISUAL:-"${EDITOR:-ed}"}" "$file" + +# Add the file to the changeset +git add -- "$file" + +# If there are changes to commit, commit them +git diff-index --quiet HEAD || +git commit --message 'Changed by td(1df)' --quiet diff --git a/bin/tl b/bin/tl deleted file mode 100755 index baa6fb2b..00000000 --- a/bin/tl +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Tag lines from files or stdin with a string prefix or suffix -self=tl - -# Parse options out -while getopts 'p:s:' opt ; do - case $opt in - - # Prefix - p) pref=$OPTARG ;; - - # Suffix - s) suff=$OPTARG ;; - - # Unknown option - \?) - printf >&2 '%s: Unknown option %s\n' \ - "$self" "$opt" - exit 2 - ;; - esac -done -shift "$((OPTIND-1))" - -# Print each line as we read it, adding the tags -cat -- "${@:--}" | -while IFS= read -r line ; do - printf '%s%s%s\n' "$pref" "$line" "$suff" -done diff --git a/bin/tl.sh b/bin/tl.sh new file mode 100644 index 00000000..86bca469 --- /dev/null +++ b/bin/tl.sh @@ -0,0 +1,28 @@ +# Tag lines from files or stdin with a string prefix or suffix +self=tl + +# Parse options out +while getopts 'p:s:' opt ; do + case $opt in + + # Prefix + p) pref=$OPTARG ;; + + # Suffix + s) suff=$OPTARG ;; + + # Unknown option + \?) + printf >&2 '%s: Unknown option %s\n' \ + "$self" "$opt" + exit 2 + ;; + esac +done +shift "$((OPTIND-1))" + +# Print each line as we read it, adding the tags +cat -- "${@:--}" | +while IFS= read -r line ; do + printf '%s%s%s\n' "$pref" "$line" "$suff" +done diff --git a/bin/tlcs b/bin/tlcs deleted file mode 100755 index aa0d2f25..00000000 --- a/bin/tlcs +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# Execute a command and tag the output of the stdout and stderr streams. -self=tlcs - -# Set the default prefixes and suffixes for stdout/err -out_pref='stdout: ' -err_pref='stderr: ' -out_suff= -err_suff= - -# Parse options out, give help if necessary -while getopts 'co:e:' opt ; do - case $opt in - c) - color=1 - ;; - o) - out_pref=$OPTARG - ;; - e) - err_pref=$OPTARG - ;; - \?) - printf >&2 'Unknown option %s\n' "$opt" - exit 2 - ;; - esac -done -shift "$((OPTIND-1))" - -# We need at least one more argument -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need a command to run\n' "$self" - exit 2 -fi - -# If color was requested for the output, try and get a count of available -# colors; otherwise default to zero -[ -n "$color" ] && color_count=$( { - tput colors || tput Co -} 2>/dev/null ) -: "${color_count:=0}" - -# If the color count is 8 or greater, we'll color the output -if [ "$((color_count >= 8))" -eq 1 ] ; then - - # Color code for resetting - color_reset=$( { - tput me || tput sgr0 - } 2>/dev/null ) - - # If stdout is a terminal, color it - if [ -t 1 ] ; then - color_stdout=$( { - tput AF 2 || tput setaf 2 - } 2>/dev/null ) - out_pref=${color_stdout}${out_pref} - out_suff=${out_suff}${color_reset} - fi - - # If stderr is a terminal, color it - if [ -t 2 ] ; then - color_stderr=$( { - tput AF 1 || tput setaf 1 - } 2>/dev/null ) - err_pref=${color_stderr}${err_pref} - out_suff=${err_suff}${color_reset} - fi -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Execute the command, passing stdout and stderr to tl(1df) calls as appropriate -# via named pipes -out=$td/out err=$td/err -mkfifo -- "$out" "$err" || exit -tl -p "$out_pref" -s "$out_suff" < "$out" & -tl -p "$err_pref" -s "$err_suff" < "$err" & -"$@" >"$out" 2>"$err" -ex=$? ; wait ; exit "$ex" diff --git a/bin/tlcs.sh b/bin/tlcs.sh new file mode 100644 index 00000000..f20b160e --- /dev/null +++ b/bin/tlcs.sh @@ -0,0 +1,93 @@ +# Execute a command and tag the output of the stdout and stderr streams. +self=tlcs + +# Set the default prefixes and suffixes for stdout/err +out_pref='stdout: ' +err_pref='stderr: ' +out_suff= +err_suff= + +# Parse options out, give help if necessary +while getopts 'co:e:' opt ; do + case $opt in + c) + color=1 + ;; + o) + out_pref=$OPTARG + ;; + e) + err_pref=$OPTARG + ;; + \?) + printf >&2 'Unknown option %s\n' "$opt" + exit 2 + ;; + esac +done +shift "$((OPTIND-1))" + +# We need at least one more argument +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a command to run\n' "$self" + exit 2 +fi + +# If color was requested for the output, try and get a count of available +# colors; otherwise default to zero +[ -n "$color" ] && color_count=$( { + tput colors || tput Co +} 2>/dev/null ) +: "${color_count:=0}" + +# If the color count is 8 or greater, we'll color the output +if [ "$((color_count >= 8))" -eq 1 ] ; then + + # Color code for resetting + color_reset=$( { + tput me || tput sgr0 + } 2>/dev/null ) + + # If stdout is a terminal, color it + if [ -t 1 ] ; then + color_stdout=$( { + tput AF 2 || tput setaf 2 + } 2>/dev/null ) + out_pref=${color_stdout}${out_pref} + out_suff=${out_suff}${color_reset} + fi + + # If stderr is a terminal, color it + if [ -t 2 ] ; then + color_stderr=$( { + tput AF 1 || tput setaf 1 + } 2>/dev/null ) + err_pref=${color_stderr}${err_pref} + out_suff=${err_suff}${color_reset} + fi +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Execute the command, passing stdout and stderr to tl(1df) calls as appropriate +# via named pipes +out=$td/out err=$td/err +mkfifo -- "$out" "$err" || exit +tl -p "$out_pref" -s "$out_suff" < "$out" & +tl -p "$err_pref" -s "$err_suff" < "$err" & +"$@" >"$out" 2>"$err" +ex=$? ; wait ; exit "$ex" diff --git a/bin/tm b/bin/tm deleted file mode 100755 index f2b51c63..00000000 --- a/bin/tm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Attach to existing tmux session rather than create a new one if possible - -# If given any arguments, just use them as they are -if [ "$#" -gt 0 ] ; then - : - -# If a session exists, just attach to it -elif command tmux has-session 2>/dev/null ; then - set -- attach-session -d - -# Create a new session with an appropriate name -else - set -- new-session -s "${TMUX_SESSION:-default}" -fi - -# Execute with concluded arguments -tmux "$@" diff --git a/bin/tm.sh b/bin/tm.sh new file mode 100644 index 00000000..774dccb1 --- /dev/null +++ b/bin/tm.sh @@ -0,0 +1,17 @@ +# Attach to existing tmux session rather than create a new one if possible + +# If given any arguments, just use them as they are +if [ "$#" -gt 0 ] ; then + : + +# If a session exists, just attach to it +elif command tmux has-session 2>/dev/null ; then + set -- attach-session -d + +# Create a new session with an appropriate name +else + set -- new-session -s "${TMUX_SESSION:-default}" +fi + +# Execute with concluded arguments +tmux "$@" diff --git a/bin/try b/bin/try deleted file mode 100755 index 7d6d57a8..00000000 --- a/bin/try +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh -# Attempt a certain number of times to perform a task, buffer stderr unless and -# until all command attempts fail -self=try - -# Parse options -while getopts 's:n:' opt ; do - case $opt in - n) - attn=$OPTARG - ;; - s) - sleep=$OPTARG - ;; - \?) - printf >&2 '%s: Unknown option\n' "$self" - exit 2 - ;; - esac -done -shift "$((OPTIND-1))" - -# Check we have at least one argument left (the command to run) -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need a command to run\n' "$self" - exit 2 -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Open a filehandle to the error buffer, just to save on file operations -errbuff=$td/errbuff -exec 3>"$errbuff" - -# Keep trying the command, writing error output to the buffer file, and exit -# if we succeed on any of them -attc=1 -: "${attn:=3}" "${sleep:=0}" -while [ "$attc" -le "$attn" ] ; do - - # Try running the command; if it succeeds, we're done, and any previous - # failures get their errors discarded - if "$@" 2>&3 ; then - exit - - # If the command failed, record the exit value - else - ex=$? - fi - - # If this isn't the last run, have a sleep - if [ "$attc" -lt "$attn" ] ; then - sleep "${sleep:=0}" - fi - - # Increment the attempt count - attc=$((attc + 1)) -done - -# Attempts were exhausted, and all failed; print the error output from all of -# the failures and exit with the non-zero exit value of the most recent one -exec 3>&- -cat -- "$td"/errbuff >&2 -exit "$ex" diff --git a/bin/try.sh b/bin/try.sh new file mode 100644 index 00000000..20ccbe5f --- /dev/null +++ b/bin/try.sh @@ -0,0 +1,77 @@ +# Attempt a certain number of times to perform a task, buffer stderr unless and +# until all command attempts fail +self=try + +# Parse options +while getopts 's:n:' opt ; do + case $opt in + n) + attn=$OPTARG + ;; + s) + sleep=$OPTARG + ;; + \?) + printf >&2 '%s: Unknown option\n' "$self" + exit 2 + ;; + esac +done +shift "$((OPTIND-1))" + +# Check we have at least one argument left (the command to run) +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a command to run\n' "$self" + exit 2 +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Open a filehandle to the error buffer, just to save on file operations +errbuff=$td/errbuff +exec 3>"$errbuff" + +# Keep trying the command, writing error output to the buffer file, and exit +# if we succeed on any of them +attc=1 +: "${attn:=3}" "${sleep:=0}" +while [ "$attc" -le "$attn" ] ; do + + # Try running the command; if it succeeds, we're done, and any previous + # failures get their errors discarded + if "$@" 2>&3 ; then + exit + + # If the command failed, record the exit value + else + ex=$? + fi + + # If this isn't the last run, have a sleep + if [ "$attc" -lt "$attn" ] ; then + sleep "${sleep:=0}" + fi + + # Increment the attempt count + attc=$((attc + 1)) +done + +# Attempts were exhausted, and all failed; print the error output from all of +# the failures and exit with the non-zero exit value of the most recent one +exec 3>&- +cat -- "$td"/errbuff >&2 +exit "$ex" diff --git a/bin/u2d b/bin/u2d deleted file mode 100755 index 505b3d04..00000000 --- a/bin/u2d +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Convert UNIX line endings to DOS ones - -# Check arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'u2d: Need a filename\n' - exit 2 -fi - -# Put a carriage return into a variable for convenience -r=$(printf '\r') - -# Iterate over arguments and apply the same ed(1) script to each of them -for fn ; do - - # Note the heredoc WORD is intentionally unquoted because we want to expand - # $r within it to get a literal carriage return; the escape characters - # prescribed for ed(1) by POSIX are very limited - ed -s -- "$fn" <&2 'u2d: Need a filename\n' + exit 2 +fi + +# Put a carriage return into a variable for convenience +r=$(printf '\r') + +# Iterate over arguments and apply the same ed(1) script to each of them +for fn ; do + + # Note the heredoc WORD is intentionally unquoted because we want to expand + # $r within it to get a literal carriage return; the escape characters + # prescribed for ed(1) by POSIX are very limited + ed -s -- "$fn" <&2 'umake: No makefile found in ancestors\n' -exit 1 diff --git a/bin/umake.sh b/bin/umake.sh new file mode 100644 index 00000000..21073328 --- /dev/null +++ b/bin/umake.sh @@ -0,0 +1,10 @@ +# Keep going up the tree until we find a Makefile, and then run make(1) with +# any given args +while [ "$PWD" != / ] ; do + for mf in makefile Makefile ; do + [ -f "$mf" ] && exec make "$@" + done + cd .. || exit +done +printf >&2 'umake: No makefile found in ancestors\n' +exit 1 diff --git a/bin/urlc b/bin/urlc deleted file mode 100755 index a949f50d..00000000 --- a/bin/urlc +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# Try to find erroneous or insecure URLs -self=urlc - -# cURL request timeout -tm=${URLCHECK_TIMEOUT:-8} - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Create buffer files for the headers and body content, to be cleaned up on -# exit -list=$td/list head=$td/head body=$td/body - -# Iterate through input; ignore leading/trailing whitespace -cat -- "${@:--}" >"$list" -while read -r url ; do - - # Skip anything that doesn't start with HTTP - case $url in - http*) ;; - *) continue ;; - esac - - # Make initial request, log head and body to files, cry and skip on error - if ! curl -A Mozilla -fHLsS -D "$head" -m "$tm" -o "$body" -- \ - "$url" ; then - printf >&2 '%s: %s raises error\n' \ - "$self" "$url" - ex=1 - continue - fi - - # Iterate through header file, cry about the first redirect we find - while IFS=': ' read -r header value ; do - [ "$header" = 'Location' ] || continue - printf >&2 '%s: %s redirects to %s\n' \ - "$self" "$url" "$value" >&2 - ex=1 - break - done < "$head" - - # Skip anything that's already secure - case $url in - https*) continue ;; - *) ;; - esac - - # Form a naïve attempt at a possible secure URL and try to request it, - # point it out if it actually works - surl=https://${url#http://} - if curl -A Mozilla -fLsS -D "$head" -m "$tm" -o "$body" -- \ - "$surl" 2>/dev/null ; then - printf >&2 '%s: %s has a working secure version at %s\n' \ - "$self" "$url" "$surl" - ex=1 - fi -done <"$list" - -# Wait for the input process to finish -wait - -# Exit if any errors -exit "${ex:-0}" diff --git a/bin/urlc.sh b/bin/urlc.sh new file mode 100644 index 00000000..0e6530fa --- /dev/null +++ b/bin/urlc.sh @@ -0,0 +1,76 @@ +# Try to find erroneous or insecure URLs +self=urlc + +# cURL request timeout +tm=${URLCHECK_TIMEOUT:-8} + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Create buffer files for the headers and body content, to be cleaned up on +# exit +list=$td/list head=$td/head body=$td/body + +# Iterate through input; ignore leading/trailing whitespace +cat -- "${@:--}" >"$list" +while read -r url ; do + + # Skip anything that doesn't start with HTTP + case $url in + http*) ;; + *) continue ;; + esac + + # Make initial request, log head and body to files, cry and skip on error + if ! curl -A Mozilla -fHLsS -D "$head" -m "$tm" -o "$body" -- \ + "$url" ; then + printf >&2 '%s: %s raises error\n' \ + "$self" "$url" + ex=1 + continue + fi + + # Iterate through header file, cry about the first redirect we find + while IFS=': ' read -r header value ; do + [ "$header" = 'Location' ] || continue + printf >&2 '%s: %s redirects to %s\n' \ + "$self" "$url" "$value" >&2 + ex=1 + break + done < "$head" + + # Skip anything that's already secure + case $url in + https*) continue ;; + *) ;; + esac + + # Form a naïve attempt at a possible secure URL and try to request it, + # point it out if it actually works + surl=https://${url#http://} + if curl -A Mozilla -fLsS -D "$head" -m "$tm" -o "$body" -- \ + "$surl" 2>/dev/null ; then + printf >&2 '%s: %s has a working secure version at %s\n' \ + "$self" "$url" "$surl" + ex=1 + fi +done <"$list" + +# Wait for the input process to finish +wait + +# Exit if any errors +exit "${ex:-0}" diff --git a/bin/urlh b/bin/urlh deleted file mode 100755 index 8e9463e7..00000000 --- a/bin/urlh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Get values for HTTP headers for the given URL - -# Check arguments -if [ "$#" -ne 2 ] ; then - printf 'urlt: Need an URL and a header name\n' - exit 2 -fi -url=$1 header=$2 - -# Run cURL header request -curl -fIsSL -- "$url" | - -# Unfold the headers -unf | - -# Change the line endings to UNIX format -sd2u | - -# Use awk to find any values for the header case-insensitively -awk -v header="$header" ' -BEGIN { - FS=": *" - header = tolower(header) -} -tolower($1) == header { - sub(/^[^ ]*: */, "") - print -} -' diff --git a/bin/urlh.sh b/bin/urlh.sh new file mode 100644 index 00000000..5b5cab74 --- /dev/null +++ b/bin/urlh.sh @@ -0,0 +1,29 @@ +# Get values for HTTP headers for the given URL + +# Check arguments +if [ "$#" -ne 2 ] ; then + printf 'urlt: Need an URL and a header name\n' + exit 2 +fi +url=$1 header=$2 + +# Run cURL header request +curl -fIsSL -- "$url" | + +# Unfold the headers +unf | + +# Change the line endings to UNIX format +sd2u | + +# Use awk to find any values for the header case-insensitively +awk -v header="$header" ' +BEGIN { + FS=": *" + header = tolower(header) +} +tolower($1) == header { + sub(/^[^ ]*: */, "") + print +} +' diff --git a/bin/urlmt b/bin/urlmt deleted file mode 100755 index b209f26a..00000000 --- a/bin/urlmt +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Get the MIME type for a given URL -urlh "$1" Content-Type | - -# Use last line only, remove any charset suffix -sed ' -$!d -s/;.*// -' diff --git a/bin/urlmt.sh b/bin/urlmt.sh new file mode 100644 index 00000000..cd71b0fd --- /dev/null +++ b/bin/urlmt.sh @@ -0,0 +1,8 @@ +# Get the MIME type for a given URL +urlh "$1" Content-Type | + +# Use last line only, remove any charset suffix +sed ' +$!d +s/;.*// +' diff --git a/bin/vest b/bin/vest deleted file mode 100755 index f857d8c1..00000000 --- a/bin/vest +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Run a test(1) command and print a string to stdout showing pass/fail -if [ "$#" -eq 0 ] ; then - printf >&2 'vest: Need test(1) arguments\n' - exit 2 -fi -vex test "$@" diff --git a/bin/vest.sh b/bin/vest.sh new file mode 100644 index 00000000..7dd65f0b --- /dev/null +++ b/bin/vest.sh @@ -0,0 +1,6 @@ +# Run a test(1) command and print a string to stdout showing pass/fail +if [ "$#" -eq 0 ] ; then + printf >&2 'vest: Need test(1) arguments\n' + exit 2 +fi +vex test "$@" diff --git a/bin/vex b/bin/vex deleted file mode 100755 index 908288ba..00000000 --- a/bin/vex +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Run a command and print a string to stdout showing pass/fail -if [ "$#" -eq 0 ] ; then - printf >&2 'vex: Need a command\n' - exit 2 -fi -"$@" -ex=$? -case $ex in - 0) op='true' ;; - *) op='false' ;; -esac -printf '%s\n' "$op" -exit "$ex" diff --git a/bin/vex.sh b/bin/vex.sh new file mode 100644 index 00000000..8a696577 --- /dev/null +++ b/bin/vex.sh @@ -0,0 +1,13 @@ +# Run a command and print a string to stdout showing pass/fail +if [ "$#" -eq 0 ] ; then + printf >&2 'vex: Need a command\n' + exit 2 +fi +"$@" +ex=$? +case $ex in + 0) op='true' ;; + *) op='false' ;; +esac +printf '%s\n' "$op" +exit "$ex" diff --git a/bin/wro b/bin/wro deleted file mode 100755 index 4c465adb..00000000 --- a/bin/wro +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Add an email-style quote header to input -self=wro - -# Check arguments -if [ "$#" -gt 2 ] ; then - printf >&2 '%s: Too many arguments\n' "$self" - exit 2 -fi - -# Check first argument for the person to quote; if blank, try to form a -# reasonable-looking name from the system -if [ -n "$1" ] ; then - from=$1 -else - un=$(id -nu) - if [ -f /etc/mailname ] ; then - read -r hn < /etc/mailname - else - hn=$(uname -n) - fi - from="$un"@"$hn" -fi - -# Check second argument for the date; if blank, get the system date in whatever -# format it cares to give us -date=${2:-"$(date)"} - -# Print the header and then the input -printf 'On %s, %s wrote:\n' "$date" "$from" -cat diff --git a/bin/wro.sh b/bin/wro.sh new file mode 100644 index 00000000..3888c526 --- /dev/null +++ b/bin/wro.sh @@ -0,0 +1,30 @@ +# Add an email-style quote header to input +self=wro + +# Check arguments +if [ "$#" -gt 2 ] ; then + printf >&2 '%s: Too many arguments\n' "$self" + exit 2 +fi + +# Check first argument for the person to quote; if blank, try to form a +# reasonable-looking name from the system +if [ -n "$1" ] ; then + from=$1 +else + un=$(id -nu) + if [ -f /etc/mailname ] ; then + read -r hn < /etc/mailname + else + hn=$(uname -n) + fi + from="$un"@"$hn" +fi + +# Check second argument for the date; if blank, get the system date in whatever +# format it cares to give us +date=${2:-"$(date)"} + +# Print the header and then the input +printf 'On %s, %s wrote:\n' "$date" "$from" +cat diff --git a/bin/xgo b/bin/xgo deleted file mode 100755 index 652d5a14..00000000 --- a/bin/xgo +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -# Test and open a clipboard URL with an apt program - -# Check arguments -if [ "$#" -eq 0 ] ; then - printf >&2 'xgo: At least one URL required\n' -fi - -# Iterate over the URL arguments -for url ; do ( - - # Look for patterns in the URL that suggest transformations - case $url in - - # If this is a GitHub or GitLab link, swap "blob" for "raw" to get the actual file - (*://github.com/*/blob/*|*://gitlab.com/*/blob/*) - url=$(printf '%s\n' "$url" | sed 's_/blob/_/raw/_') - ;; - - # Dig out the plain text for pastebin.com links - (*://pastebin.com/*) - # shellcheck disable=SC2016 - url=$(printf '%s\n' "$url" | sed 's_/[A-Za-z0-9][A-Za-z0-9]*$_/raw&_') - ;; - - # If this is a not-direct imgur link and not to an album, swap URL - # elements to get to the actual file (it may not actually be a JPEG; - # the MIME type will tell us) - (*://imgur.com/a/*) ;; - (*://imgur.com/*) - url=$(printf '%s\n' "$url" | sed 's_imgur\.com_i.imgur.com_;s/$/.jpg/') - ;; - - # If this is a YouTube video without a given start time, load it in mpv(1) - (*[/.]youtube.com/watch*[?\&]t=) ;; - (*[/.]youtube.com/watch*) - mpv -- "$url" && exit - ;; - esac - - # Get the MIME type data - mt=$(urlmt "$url") - - # Switch on media type - case $mt in - - # Open PDFs in xpdf(1); download them first as xpdf(1) does not seem to - # have a way to handle stdin files - (application/pdf) - ( - cd -- "$HOME"/Downloads || exit - curl -O -- "$url" || exit - xpdf -- "${url##*/}" - ) && exit - ;; - - # Open audio and video in mpv(1); force a window even for audio so I - # can control it - (audio/*|video/*) - mpv --force-window -- "$url" && exit - ;; - - # If the MIME type is an image that is not a GIF, load it in feh(1) - (image/gif) ;; - (image/*) - curl -- "$url" | feh - && exit - ;; - - # Open plain text in a terminal view(1) - (text/plain) - # shellcheck disable=SC2016 - urxvt -e sh -c 'curl -- "$1" | view -' _ "$url" && exit - ;; - esac - - # Otherwise, just pass it to br(1df) - br "$url" - -) & done diff --git a/bin/xgo.sh b/bin/xgo.sh new file mode 100644 index 00000000..4d7cf922 --- /dev/null +++ b/bin/xgo.sh @@ -0,0 +1,78 @@ +# Test and open a clipboard URL with an apt program + +# Check arguments +if [ "$#" -eq 0 ] ; then + printf >&2 'xgo: At least one URL required\n' +fi + +# Iterate over the URL arguments +for url ; do ( + + # Look for patterns in the URL that suggest transformations + case $url in + + # If this is a GitHub or GitLab link, swap "blob" for "raw" to get the actual file + (*://github.com/*/blob/*|*://gitlab.com/*/blob/*) + url=$(printf '%s\n' "$url" | sed 's_/blob/_/raw/_') + ;; + + # Dig out the plain text for pastebin.com links + (*://pastebin.com/*) + # shellcheck disable=SC2016 + url=$(printf '%s\n' "$url" | sed 's_/[A-Za-z0-9][A-Za-z0-9]*$_/raw&_') + ;; + + # If this is a not-direct imgur link and not to an album, swap URL + # elements to get to the actual file (it may not actually be a JPEG; + # the MIME type will tell us) + (*://imgur.com/a/*) ;; + (*://imgur.com/*) + url=$(printf '%s\n' "$url" | sed 's_imgur\.com_i.imgur.com_;s/$/.jpg/') + ;; + + # If this is a YouTube video without a given start time, load it in mpv(1) + (*[/.]youtube.com/watch*[?\&]t=) ;; + (*[/.]youtube.com/watch*) + mpv -- "$url" && exit + ;; + esac + + # Get the MIME type data + mt=$(urlmt "$url") + + # Switch on media type + case $mt in + + # Open PDFs in xpdf(1); download them first as xpdf(1) does not seem to + # have a way to handle stdin files + (application/pdf) + ( + cd -- "$HOME"/Downloads || exit + curl -O -- "$url" || exit + xpdf -- "${url##*/}" + ) && exit + ;; + + # Open audio and video in mpv(1); force a window even for audio so I + # can control it + (audio/*|video/*) + mpv --force-window -- "$url" && exit + ;; + + # If the MIME type is an image that is not a GIF, load it in feh(1) + (image/gif) ;; + (image/*) + curl -- "$url" | feh - && exit + ;; + + # Open plain text in a terminal view(1) + (text/plain) + # shellcheck disable=SC2016 + urxvt -e sh -c 'curl -- "$1" | view -' _ "$url" && exit + ;; + esac + + # Otherwise, just pass it to br(1df) + br "$url" + +) & done diff --git a/bin/xgoc b/bin/xgoc deleted file mode 100755 index 516f7028..00000000 --- a/bin/xgoc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Run xgo(1df) with the contents of the X clipboard -xgo "$(xsel)" diff --git a/bin/xgoc.sh b/bin/xgoc.sh new file mode 100644 index 00000000..42e04e2d --- /dev/null +++ b/bin/xgoc.sh @@ -0,0 +1,2 @@ +# Run xgo(1df) with the contents of the X clipboard +xgo "$(xsel)" diff --git a/bin/xrbg b/bin/xrbg deleted file mode 100755 index 801bf078..00000000 --- a/bin/xrbg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Apply a random background image. Requires rndf(1df) and feh(1). -bg=$(rndf "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}") || exit -feh --bg-scale --no-fehbg -- "$bg" diff --git a/bin/xrbg.sh b/bin/xrbg.sh new file mode 100644 index 00000000..617a9b43 --- /dev/null +++ b/bin/xrbg.sh @@ -0,0 +1,3 @@ +# Apply a random background image. Requires rndf(1df) and feh(1). +bg=$(rndf "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}") || exit +feh --bg-scale --no-fehbg -- "$bg" diff --git a/games/aaf b/games/aaf deleted file mode 100755 index 4f1825c6..00000000 --- a/games/aaf +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -curl http://www.asciiartfarts.com/random.cgi | -pup -p 'table[cellpadding]' pre text{} diff --git a/games/aaf.sh b/games/aaf.sh new file mode 100644 index 00000000..4f1825c6 --- /dev/null +++ b/games/aaf.sh @@ -0,0 +1,3 @@ +#!/bin/sh +curl http://www.asciiartfarts.com/random.cgi | +pup -p 'table[cellpadding]' pre text{} diff --git a/games/dr b/games/dr deleted file mode 100755 index e1db163d..00000000 --- a/games/dr +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Roll D&D-style dice in a ndn+n formula, e.g. 10d6+2 - -# Need exactly one argument -[ "$#" -eq 1 ] || exit 2 - -# Arcane string chopping -n=1 a=0 -nd=${1%+*} -d=${nd#*d} -[ "${nd%d*}" != "" ] && n=${nd%d*} -[ "${1#*+}" = "$1" ] || a=${1#*+} - -# Check number of roles and addendum make sense -[ "$((n > 0 && a >= 0))" -eq 1 ] || exit 2 - -# Check this is a real die you can actually roll -case $d in - 4|6|8|10|12|20) : ;; - *) exit 2 ;; -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") - t=$((t + r)) - i=$((i + 1)) -done - -# Add the addendum -t=$((t + a)) - -# Print it -printf '%u\n' "$t" diff --git a/games/dr.sh b/games/dr.sh new file mode 100644 index 00000000..e1db163d --- /dev/null +++ b/games/dr.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Roll D&D-style dice in a ndn+n formula, e.g. 10d6+2 + +# Need exactly one argument +[ "$#" -eq 1 ] || exit 2 + +# Arcane string chopping +n=1 a=0 +nd=${1%+*} +d=${nd#*d} +[ "${nd%d*}" != "" ] && n=${nd%d*} +[ "${1#*+}" = "$1" ] || a=${1#*+} + +# Check number of roles and addendum make sense +[ "$((n > 0 && a >= 0))" -eq 1 ] || exit 2 + +# Check this is a real die you can actually roll +case $d in + 4|6|8|10|12|20) : ;; + *) exit 2 ;; +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") + t=$((t + r)) + i=$((i + 1)) +done + +# Add the addendum +t=$((t + a)) + +# Print it +printf '%u\n' "$t" diff --git a/games/rndn b/games/rndn deleted file mode 100755 index 18c34218..00000000 --- a/games/rndn +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Esoteric random number generator - -# Single optional argument is a random seed, otherwise use rnds(1df) -s=${1:-"$(rnds)"} - -# Validate s -case $s in - *[!0-9]*) - printf >&2 'rndn: Seed must be non-negative integer\n' - exit 2 - ;; -esac - -# Helper functions -t() { - printf %u "$1" | cut -c -"$2" -} -l() { - printf %u "$1" | wc -c -} -c() { - printf %u "$1" | cut -c "$2" -} - -# Apply algorithm; you are not expected to understand this -s=$(t "$((s + 10))" 32) i=1 t=0 -while [ "$i" -le "$(l "$s")" ] ; do - d=$(c "$s" "$i") - t=$((t + d)) i=$((i + 1)) -done -p=$((s - t)) -while [ "$(l "$p")" -gt 1 ] ; do - j=1 q=0 - while [ "$j" -le "$(l "$p")" ] ; do - d=$(c "$p" "$j") - q=$((q + d)) j=$((j + 1)) - done - p=$q -done - -# Print result -printf '%u\n' "$p" diff --git a/games/rndn.sh b/games/rndn.sh new file mode 100644 index 00000000..18c34218 --- /dev/null +++ b/games/rndn.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Esoteric random number generator + +# Single optional argument is a random seed, otherwise use rnds(1df) +s=${1:-"$(rnds)"} + +# Validate s +case $s in + *[!0-9]*) + printf >&2 'rndn: Seed must be non-negative integer\n' + exit 2 + ;; +esac + +# Helper functions +t() { + printf %u "$1" | cut -c -"$2" +} +l() { + printf %u "$1" | wc -c +} +c() { + printf %u "$1" | cut -c "$2" +} + +# Apply algorithm; you are not expected to understand this +s=$(t "$((s + 10))" 32) i=1 t=0 +while [ "$i" -le "$(l "$s")" ] ; do + d=$(c "$s" "$i") + t=$((t + d)) i=$((i + 1)) +done +p=$((s - t)) +while [ "$(l "$p")" -gt 1 ] ; do + j=1 q=0 + while [ "$j" -le "$(l "$p")" ] ; do + d=$(c "$p" "$j") + q=$((q + d)) j=$((j + 1)) + done + p=$q +done + +# Print result +printf '%u\n' "$p" diff --git a/games/xyzzy b/games/xyzzy deleted file mode 100755 index d262c0e6..00000000 --- a/games/xyzzy +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -if [ -e "$HOME"/.xyzzy ] ; then - printf >&2 '%s\n' 'Nothing happens.' - exit 1 -fi -printf '%s\n' 'I see no cave here.' > "$HOME"/.xyzzy diff --git a/games/xyzzy.sh b/games/xyzzy.sh new file mode 100644 index 00000000..d262c0e6 --- /dev/null +++ b/games/xyzzy.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -e "$HOME"/.xyzzy ] ; then + printf >&2 '%s\n' 'Nothing happens.' + exit 1 +fi +printf '%s\n' 'I see no cave here.' > "$HOME"/.xyzzy diff --git a/lint/bin b/lint/bin index 1130e432..ff7de0b7 100755 --- a/lint/bin +++ b/lint/bin @@ -1,11 +1,2 @@ #!/bin/sh -for bin in bin/* ; do - [ -f "$bin" ] || continue - hb=$(sed 1q "$bin") || exit - case $hb in - *sh) - printf '%s\n' "$bin" - shellcheck -- "$bin" - ;; - esac -done +find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/games b/lint/games index ef451f4e..38299a7f 100755 --- a/lint/games +++ b/lint/games @@ -1,11 +1,2 @@ #!/bin/sh -for game in games/* ; do - [ -f "$game" ] || continue - hb=$(sed 1q "$game") || exit - case $hb in - *sh) - printf '%s\n' "$game" - shellcheck -- "$game" - ;; - esac -done +find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 From 1d9b03a88f23b0a1dd784354c35bfca1c93f79a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 20:50:24 +1200 Subject: Remove mail/mailrc from ignored files --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca6f199b..58865a24 100644 --- a/.gitignore +++ b/.gitignore @@ -123,7 +123,6 @@ games/strik games/zs git/gitconfig gnupg/gpg.conf -mail/mailrc man/man7/dotfiles.7df tmux/tmux.conf urxvt/ext/select -- cgit v1.2.3 From 165c35c70b43349e882bd44be31c0837ab19729b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 21:08:39 +1200 Subject: More sh flexibility (check/lint scripts) --- Makefile | 32 ++++++++++++++++---------------- check/bash | 6 ------ check/bash.sh | 5 +++++ check/bin | 14 -------------- check/bin.sh | 4 ++++ check/games | 14 -------------- check/games.sh | 4 ++++ check/ksh | 6 ------ check/ksh.sh | 5 +++++ check/man | 48 ------------------------------------------------ check/man.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ check/sh | 6 ------ check/sh.sh | 5 +++++ check/urxvt | 9 --------- check/urxvt.sh | 4 ++++ check/yash | 6 ------ check/yash.sh | 5 +++++ check/zsh | 6 ------ check/zsh.sh | 5 +++++ lint/bash | 2 -- lint/bash.sh | 1 + lint/bin | 2 -- lint/bin.sh | 1 + lint/games | 2 -- lint/games.sh | 1 + lint/ksh | 4 ---- lint/ksh.sh | 3 +++ lint/sh | 2 -- lint/sh.sh | 1 + lint/urxvt | 2 -- lint/urxvt.sh | 1 + lint/yash | 2 -- lint/yash.sh | 1 + 33 files changed, 109 insertions(+), 147 deletions(-) delete mode 100755 check/bash create mode 100644 check/bash.sh delete mode 100755 check/bin create mode 100644 check/bin.sh delete mode 100755 check/games create mode 100644 check/games.sh delete mode 100755 check/ksh create mode 100644 check/ksh.sh delete mode 100755 check/man create mode 100644 check/man.sh delete mode 100755 check/sh create mode 100644 check/sh.sh delete mode 100755 check/urxvt create mode 100644 check/urxvt.sh delete mode 100755 check/yash create mode 100644 check/yash.sh delete mode 100755 check/zsh create mode 100644 check/zsh.sh delete mode 100755 lint/bash create mode 100644 lint/bash.sh delete mode 100755 lint/bin create mode 100644 lint/bin.sh delete mode 100755 lint/games create mode 100644 lint/games.sh delete mode 100755 lint/ksh create mode 100644 lint/ksh.sh delete mode 100755 lint/sh create mode 100644 lint/sh.sh delete mode 100755 lint/urxvt create mode 100644 lint/urxvt.sh delete mode 100755 lint/yash create mode 100644 lint/yash.sh diff --git a/Makefile b/Makefile index 7dc69c2e..86d44810 100644 --- a/Makefile +++ b/Makefile @@ -459,31 +459,31 @@ check: check-bash \ check-urxvt check-bash: - check/bash + sh check/bash.sh check-bin: $(BINS) - check/bin + sh check/bin.sh check-games: $(GAMES) - check/games + sh check/games.sh check-man: - check/man + sh check/man.sh check-ksh: - check/ksh + sh check/ksh.sh check-sh: - check/sh + sh check/sh.sh check-urxvt: - check/urxvt + sh check/urxvt.sh check-yash: - check/yash + sh check/yash.sh check-zsh: - check/zsh + sh check/zsh.sh lint: check \ lint-bash \ @@ -495,22 +495,22 @@ lint: check \ lint-yash lint-bash: - lint/bash + sh lint/bash.sh lint-bin: - lint/bin + sh lint/bin.sh lint-games: - lint/games + sh lint/games.sh lint-ksh: - lint/ksh + sh lint/ksh.sh lint-sh: - lint/sh + sh lint/sh.sh lint-urxvt: - lint/urxvt + sh lint/urxvt.sh lint-yash: - lint/yash + sh lint/yash.sh diff --git a/check/bash b/check/bash deleted file mode 100755 index 525bec34..00000000 --- a/check/bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for bash in bash/* bash/bashrc.d/* ; do - [ -f "$bash" ] || continue - bash -n "$bash" || exit -done -printf 'All bash(1) scripts parsed successfully.\n' diff --git a/check/bash.sh b/check/bash.sh new file mode 100644 index 00000000..a3efccb1 --- /dev/null +++ b/check/bash.sh @@ -0,0 +1,5 @@ +for bash in bash/* bash/bashrc.d/* ; do + [ -f "$bash" ] || continue + bash -n "$bash" || exit +done +printf 'All bash(1) scripts parsed successfully.\n' diff --git a/check/bin b/check/bin deleted file mode 100755 index 2fc4e767..00000000 --- a/check/bin +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for bin in bin/* ; do - [ -x "$bin" ] || continue - hb=$(sed 1q "$bin") || exit - case $hb in - *bash) - bash -n "$bin" || exit - ;; - *sh) - sh -n "$bin" || exit - ;; - esac -done -printf 'All shell scripts in bin parsed successfully.\n' diff --git a/check/bin.sh b/check/bin.sh new file mode 100644 index 00000000..04b0da6b --- /dev/null +++ b/check/bin.sh @@ -0,0 +1,4 @@ +for bin in bin/*.sh ; do + sh -n "$bin" || exit +done +printf 'All shell scripts in bin parsed successfully.\n' diff --git a/check/games b/check/games deleted file mode 100755 index d3b5feac..00000000 --- a/check/games +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for game in games/* ; do - [ -x "$game" ] || continue - hb=$(sed 1q "$game") || exit - case $hb in - *bash) - bash -n "$game" || exit - ;; - *sh) - sh -n "$game" || exit - ;; - esac -done -printf 'All shell scripts in games parsed successfully.\n' diff --git a/check/games.sh b/check/games.sh new file mode 100644 index 00000000..79d53ed5 --- /dev/null +++ b/check/games.sh @@ -0,0 +1,4 @@ +for game in games/*.sh ; do + sh -n "$game" || exit +done +printf 'All shell scripts in games parsed successfully.\n' diff --git a/check/ksh b/check/ksh deleted file mode 100755 index 3136c413..00000000 --- a/check/ksh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for ksh in ksh/* ksh/kshrc.d/* ; do - [ -f "$ksh" ] || continue - ksh -n "$ksh" || exit -done -printf 'All ksh scripts parsed successfully.\n' diff --git a/check/ksh.sh b/check/ksh.sh new file mode 100644 index 00000000..51e71e19 --- /dev/null +++ b/check/ksh.sh @@ -0,0 +1,5 @@ +for ksh in ksh/* ksh/kshrc.d/* ; do + [ -f "$ksh" ] || continue + ksh -n "$ksh" || exit +done +printf 'All ksh scripts parsed successfully.\n' diff --git a/check/man b/check/man deleted file mode 100755 index ca1c248c..00000000 --- a/check/man +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# Check that manual pages and logical binaries match up - -# Need some scripts from the source directory -PATH=bin:$PATH - -# Create temporary directory and implement cleanup function for it -td= -cleanup() { - rm -fr -- "$td" -} -for sig in EXIT HUP INT TERM ; do - trap cleanup "$sig" -done -td=$(mktd test-man) || exit - -# Get lists of logical binaries and manual pages -# shellcheck disable=SC2016 -find bin games -type f -print | - sed 's_.*/__;s_\..*$__' | - sort | uniq > "$td"/bin -# shellcheck disable=SC2016 -find man/man[168] -type f -name '*.[168]df' -print | - sed 's_.*/__;s_\..*$__' | - sort | uniq > "$td"/man - -# Get lists of noman scripts and nobin manual pages -comm -23 "$td"/bin "$td"/man > "$td"/noman -comm -13 "$td"/bin "$td"/man > "$td"/nobin - -# Emit the content of both, if any -ex=0 -if [ -s "$td"/noman ] ; then - printf >&2 'No manual pages found for:\n' - cat >&2 -- "$td"/noman - ex=1 -fi -if [ -s "$td"/nobin ] ; then - printf >&2 'Stray manual page for:\n' - cat >&2 -- "$td"/nobin - ex=1 -fi - -# Exit appropriately -if [ "$ex" -eq 0 ] ; then - printf 'All scripts have manual pages.\n' -fi -exit "$ex" diff --git a/check/man.sh b/check/man.sh new file mode 100644 index 00000000..89c03890 --- /dev/null +++ b/check/man.sh @@ -0,0 +1,47 @@ +# Check that manual pages and logical binaries match up + +# Need some scripts from the source directory +PATH=bin:$PATH + +# Create temporary directory and implement cleanup function for it +td= +cleanup() { + rm -fr -- "$td" +} +for sig in EXIT HUP INT TERM ; do + trap cleanup "$sig" +done +td=$(mktd test-man) || exit + +# Get lists of logical binaries and manual pages +# shellcheck disable=SC2016 +find bin games -type f -print | + sed 's_.*/__;s_\..*$__' | + sort | uniq > "$td"/bin +# shellcheck disable=SC2016 +find man/man[168] -type f -name '*.[168]df' -print | + sed 's_.*/__;s_\..*$__' | + sort | uniq > "$td"/man + +# Get lists of noman scripts and nobin manual pages +comm -23 "$td"/bin "$td"/man > "$td"/noman +comm -13 "$td"/bin "$td"/man > "$td"/nobin + +# Emit the content of both, if any +ex=0 +if [ -s "$td"/noman ] ; then + printf >&2 'No manual pages found for:\n' + cat >&2 -- "$td"/noman + ex=1 +fi +if [ -s "$td"/nobin ] ; then + printf >&2 'Stray manual page for:\n' + cat >&2 -- "$td"/nobin + ex=1 +fi + +# Exit appropriately +if [ "$ex" -eq 0 ] ; then + printf 'All scripts have manual pages.\n' +fi +exit "$ex" diff --git a/check/sh b/check/sh deleted file mode 100755 index ec3ba339..00000000 --- a/check/sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for sh in sh/* sh/profile.d/* sh/shrc.d/* ; do - [ -f "$sh" ] || continue - sh -n "$sh" || exit -done -printf 'All sh(1) scripts parsed successfully.\n' diff --git a/check/sh.sh b/check/sh.sh new file mode 100644 index 00000000..53d8c4b6 --- /dev/null +++ b/check/sh.sh @@ -0,0 +1,5 @@ +for sh in sh/* sh/profile.d/* sh/shrc.d/* ; do + [ -f "$sh" ] || continue + sh -n "$sh" || exit +done +printf 'All sh(1) scripts parsed successfully.\n' diff --git a/check/urxvt b/check/urxvt deleted file mode 100755 index a40f8559..00000000 --- a/check/urxvt +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -for perl in urxvt/ext/* ; do - [ -f "$perl" ] || continue - case $perl in - *.pl) ;; - *) perl -c "$perl" >/dev/null || exit ;; - esac -done -printf 'All Perl scripts in urxvt/ext parsed successfully.\n' diff --git a/check/urxvt.sh b/check/urxvt.sh new file mode 100644 index 00000000..ee39e6c9 --- /dev/null +++ b/check/urxvt.sh @@ -0,0 +1,4 @@ +for perl in urxvt/ext/*.pl ; do + perl -c "$perl" || exit +done +printf 'All Perl scripts in urxvt/ext parsed successfully.\n' diff --git a/check/yash b/check/yash deleted file mode 100755 index fb737596..00000000 --- a/check/yash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for yash in yash/* ; do - [ -f "$yash" ] || continue - yash -n "$yash" || exit -done -printf 'All yash scripts parsed successfully.\n' diff --git a/check/yash.sh b/check/yash.sh new file mode 100644 index 00000000..c8722f3d --- /dev/null +++ b/check/yash.sh @@ -0,0 +1,5 @@ +for yash in yash/* ; do + [ -f "$yash" ] || continue + yash -n "$yash" || exit +done +printf 'All yash scripts parsed successfully.\n' diff --git a/check/zsh b/check/zsh deleted file mode 100755 index 39a6c1e9..00000000 --- a/check/zsh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for zsh in zsh/* zsh/zshrc.d/* ; do - [ -f "$zsh" ] || continue - zsh -n "$zsh" || exit -done -printf 'All zsh(1) scripts parsed successfully.\n' diff --git a/check/zsh.sh b/check/zsh.sh new file mode 100644 index 00000000..50335d56 --- /dev/null +++ b/check/zsh.sh @@ -0,0 +1,5 @@ +for zsh in zsh/* zsh/zshrc.d/* ; do + [ -f "$zsh" ] || continue + zsh -n "$zsh" || exit +done +printf 'All zsh(1) scripts parsed successfully.\n' diff --git a/lint/bash b/lint/bash deleted file mode 100755 index 771f2a89..00000000 --- a/lint/bash +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + diff --git a/lint/bash.sh b/lint/bash.sh new file mode 100644 index 00000000..2fe1ba13 --- /dev/null +++ b/lint/bash.sh @@ -0,0 +1 @@ +find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + diff --git a/lint/bin b/lint/bin deleted file mode 100755 index ff7de0b7..00000000 --- a/lint/bin +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/bin.sh b/lint/bin.sh new file mode 100644 index 00000000..0fe82d7a --- /dev/null +++ b/lint/bin.sh @@ -0,0 +1 @@ +find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/games b/lint/games deleted file mode 100755 index 38299a7f..00000000 --- a/lint/games +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/games.sh b/lint/games.sh new file mode 100644 index 00000000..6e3e3024 --- /dev/null +++ b/lint/games.sh @@ -0,0 +1 @@ +find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/ksh b/lint/ksh deleted file mode 100755 index ee49d178..00000000 --- a/lint/ksh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -find ksh \ - -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ - -type f -exec shellcheck -e SC1090 -s ksh -- {} + diff --git a/lint/ksh.sh b/lint/ksh.sh new file mode 100644 index 00000000..4cedc6f7 --- /dev/null +++ b/lint/ksh.sh @@ -0,0 +1,3 @@ +find ksh \ + -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ + -type f -exec shellcheck -e SC1090 -s ksh -- {} + diff --git a/lint/sh b/lint/sh deleted file mode 100755 index 18f2f551..00000000 --- a/lint/sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find sh -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/sh.sh b/lint/sh.sh new file mode 100644 index 00000000..632585bf --- /dev/null +++ b/lint/sh.sh @@ -0,0 +1 @@ +find sh -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/urxvt b/lint/urxvt deleted file mode 100755 index 9fd6193d..00000000 --- a/lint/urxvt +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; diff --git a/lint/urxvt.sh b/lint/urxvt.sh new file mode 100644 index 00000000..507034be --- /dev/null +++ b/lint/urxvt.sh @@ -0,0 +1 @@ +find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; diff --git a/lint/yash b/lint/yash deleted file mode 100755 index 1397f9f1..00000000 --- a/lint/yash +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find yash -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/yash.sh b/lint/yash.sh new file mode 100644 index 00000000..d783e077 --- /dev/null +++ b/lint/yash.sh @@ -0,0 +1 @@ +find yash -type f -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 From a3062010c59b6422f3cc106ebcba54670ebd2a6d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 21:12:38 +1200 Subject: Don't require checks for installing --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 86d44810..397ef8ff 100644 --- a/Makefile +++ b/Makefile @@ -359,7 +359,7 @@ install-newsbeuter: install-mysql: cp -p -- mysql/my.cnf $(HOME)/.my.cnf -install-ksh: check-ksh install-sh +install-ksh: install-sh mkdir -p -- $(HOME)/.shrc.d $(HOME)/.kshrc.d cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d cp -p -- ksh/kshrc $(HOME)/.kshrc @@ -377,7 +377,7 @@ install-psql: install-readline: cp -p -- readline/inputrc $(HOME)/.inputrc -install-sh: check-sh +install-sh: mkdir -p -- $(HOME)/.profile.d $(HOME)/.shrc.d cp -p -- sh/profile $(HOME)/.profile cp -p -- sh/profile.d/* $(HOME)/.profile.d @@ -396,7 +396,7 @@ install-terminfo: install-tmux: tmux/tmux.conf install-terminfo cp -p -- tmux/tmux.conf $(HOME)/.tmux.conf -install-urxvt: urxvt/ext/select check-urxvt +install-urxvt: urxvt/ext/select mkdir -p -- $(HOME)/.urxvt/ext find urxvt/ext -type f ! -name '*.pl' \ -exec cp -p -- {} $(HOME)/.urxvt/ext \; @@ -438,13 +438,13 @@ install-x: cp -p -- X/Xresources $(HOME)/.Xresources cp -p -- X/Xresources.d/* $(HOME)/.Xresources.d -install-yash: check-yash install-sh +install-yash: install-sh mkdir -p -- $(HOME)/.yashrc.d cp -p -- yash/yash_profile $(HOME)/.yash_profile cp -p -- yash/yashrc $(HOME)/.yashrc cp -p -- yash/yashrc.d/* $(HOME)/.yashrc.d -install-zsh: check-zsh install-sh +install-zsh: install-sh mkdir -p -- $(HOME)/.profile.d $(HOME)/.zshrc.d cp -p -- zsh/profile.d/* $(HOME)/.profile.d cp -p -- zsh/zprofile $(HOME)/.zprofile @@ -461,10 +461,10 @@ check: check-bash \ check-bash: sh check/bash.sh -check-bin: $(BINS) +check-bin: sh check/bin.sh -check-games: $(GAMES) +check-games: sh check/games.sh check-man: -- cgit v1.2.3 From 3b8433dff704cb87fca6f56dcbc8a6b7ca40e962 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 21:13:14 +1200 Subject: Add some missing .gitignores --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 58865a24..660e0ddb 100644 --- a/.gitignore +++ b/.gitignore @@ -113,13 +113,17 @@ bin/xgo bin/xgoc bin/xrbg bin/xrq +games/aaf games/acq games/aesth games/chkl +games/dr games/drakon games/kvlt +games/rndn games/rot13 games/strik +games/xyzzy games/zs git/gitconfig gnupg/gpg.conf -- cgit v1.2.3 From 6f94554afa6a5858a5fbdef0f3b756f9fbf3c471 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 22:08:53 +1200 Subject: Remove superfluous lesskey(1) existence check --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 397ef8ff..91b38c50 100644 --- a/Makefile +++ b/Makefile @@ -341,7 +341,7 @@ install-i3: install-x install-less: cp -p -- less/lesskey $(HOME)/.lesskey - command -v lesskey && lesskey + lesskey install-mutt: mkdir -p -- $(HOME)/.muttrc.d $(HOME)/.cache/mutt -- cgit v1.2.3 From c59fea14add8a19ba7b79abad1952c78b8530fbf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 6 Apr 2017 07:54:32 +1200 Subject: Fix a README error --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 8fd19dff..bb071a27 100644 --- a/README.markdown +++ b/README.markdown @@ -46,7 +46,7 @@ dependencies: * `install-vim` The remaining dotfiles can be installed with the other `install-*` targets. Try -`bin/mftl Makefile` in the project's root directory to see a list. +`sh bin/mftl.sh Makefile` in the project's root directory to see a list. Tools ----- -- cgit v1.2.3 From 80b9f391473843ec290c37a6468be1810c1b5076 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 6 Apr 2017 07:54:49 +1200 Subject: Fix a README error --- README.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/README.markdown b/README.markdown index bb071a27..99e486d1 100644 --- a/README.markdown +++ b/README.markdown @@ -73,7 +73,6 @@ Configuration is included for: elements * [i3](https://i3wm.org/) -- Tiling window manager * [less](https://www.gnu.org/software/less/) -- Terminal pager -* `mail(1)` -- classic mail program * [Mutt](http://www.mutt.org/) -- Terminal mail user agent * [`mysql(1)`](http://linux.die.net/man/1/mysql) -- Command-line MySQL client * [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client -- cgit v1.2.3 From a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 6 Apr 2017 18:28:15 +1200 Subject: Make -x in ls() conditional on terminal output Mimics behaviour of GNU ls(1) and probably other implementations too --- sh/shrc.d/ls.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 58263e96..18f50a8b 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -14,8 +14,10 @@ ls() { # -F to show trailing indicators of the filetype # -q to replace control chars with '?' - # -x to format entries across, not down - set -- -Fqx "$@" + set -- -Fq "$@" + + # If output is to a terminal, add -x to format entries across, not down + [ -t 1 ] && set -- -x "$@" # Add --block-size=K to always show the filesize in kibibytes [ -e "$HOME"/.cache/ls/block-size ] && -- cgit v1.2.3 From d73e5fb06699c25aced71420afd3f37e1d6ecc07 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:13:30 +1200 Subject: Remove dependency on check-bash --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 91b38c50..26747350 100644 --- a/Makefile +++ b/Makefile @@ -272,7 +272,7 @@ install-abook: mkdir -p -- $(HOME)/.abook cp -p -- abook/abookrc $(HOME)/.abook -install-bash: check-bash install-sh +install-bash: install-sh mkdir -p -- $(HOME)/.bashrc.d cp -p -- bash/bashrc $(HOME)/.bashrc cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d -- cgit v1.2.3 From 1b8e971491936104a19c007732ebe06453aab242 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:15:07 +1200 Subject: Combine unnecessary split line --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 26747350..1c614cc4 100644 --- a/Makefile +++ b/Makefile @@ -416,10 +416,8 @@ install-gvim-config: install-vim-plugins: install-vim-config find vim/after vim/bundle -name .git -prune -o \ - -type d -exec sh -c 'mkdir -p -- \ - $(HOME)/."$$1"' _ {} \; -o \ - -type f -exec sh -c 'cp -p -- \ - "$$1" $(HOME)/."$$1"' _ {} \; + -type d -exec sh -c 'mkdir -p -- $(HOME)/."$$1"' _ {} \; -o \ + -type f -exec sh -c 'cp -p -- "$$1" $(HOME)/."$$1"' _ {} \; install-vim-pathogen: install-vim-plugins mkdir -p -- $(HOME)/.vim/autoload -- cgit v1.2.3 From 8561f37448e00c795602f0e87dd71fc67a1d2676 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:27:30 +1200 Subject: Add some more comments to README --- README.markdown | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 99e486d1..8a85f048 100644 --- a/README.markdown +++ b/README.markdown @@ -16,8 +16,12 @@ Installation $ make install For the default `all` target, you'll need `make(1)`, `m4(1)`, and a -POSIX-fearing `sh(1)`. If you're on a system where `/bin/sh` is not a POSIX -shell, you may need to check you have e.g. `/usr/xpg4/bin` at the front of your +POSIX-fearing environment, including `sh(1)`. This should work on most +GNU/Linux and BSD systems, and possibly on other UNIX types, but those are not +as thoroughly or frequently tested. + +If you're on a system where `/bin/sh` is not a POSIX shell (e.g. OpenSolaris), +you may need to check you have e.g. `/usr/xpg4/bin` at the front of your `$PATH` at build time. The installation `Makefile` will overwrite things standing in the way of its @@ -31,7 +35,8 @@ directory so you can explore: $ env -i HOME="$tmpdir" TERM="$TERM" bash -l The default `install` target will install these targets and all their -dependencies: +dependencies. Note that you don't actually have to have any of this except `sh` +installed. * `install-bash` * `install-bin` @@ -149,8 +154,8 @@ A terminal session with my prompt looks something like this: tom@remote:~/.dotfiles(master+!){1}$ The username and hostname are elided if not connected via SSH. The working -directory is always shown. The rest of the prompt expands based on context to -include these elements in this order: +directory with tilde abbreviation for `$HOME` is always shown. The rest of the +prompt expands based on context to include these elements in this order: * Whether in a Git repository if applicable, and punctuation to show repository status including reference to upstreams at a glance. Subversion -- cgit v1.2.3 From fd705194e5b1eb2f5c07b196f4be83a74bfe8fa1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:37:32 +1200 Subject: Install shell types conditionally on $SHELL --- Makefile | 15 ++++++--------- README.markdown | 6 ++++-- dist/install-login-shell.sh | 12 ++++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 dist/install-login-shell.sh diff --git a/Makefile b/Makefile index 1c614cc4..2aade4ff 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ install \ install-abook \ install-bash \ - install-bash-completion \ install-bin \ install-bin-man \ install-curl \ @@ -256,16 +255,14 @@ tmux/tmux.conf: tmux/tmux.conf.m4 sh bin/shb.sh sh < $< > $@ chmod +x ./$@ -install: install-bash \ - install-bash-completion \ - install-bin \ +install: install-bin \ install-curl \ install-ex \ install-git \ install-gnupg \ install-less \ install-readline \ - install-sh \ + install-login-shell \ install-vim install-abook: @@ -273,14 +270,11 @@ install-abook: cp -p -- abook/abookrc $(HOME)/.abook install-bash: install-sh - mkdir -p -- $(HOME)/.bashrc.d + mkdir -p -- $(HOME)/.bashrc.d $(HOME)/.bash_completion.d $(HOME)/.config cp -p -- bash/bashrc $(HOME)/.bashrc cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d cp -p -- bash/bash_profile $(HOME)/.bash_profile cp -p -- bash/bash_logout $(HOME)/.bash_logout - -install-bash-completion: install-bash - mkdir -p -- $(HOME)/.bash_completion.d $(HOME)/.config cp -p -- bash/bash_completion $(HOME)/.config cp -p -- bash/bash_completion.d/* $(HOME)/.bash_completion.d @@ -365,6 +359,9 @@ install-ksh: install-sh cp -p -- ksh/kshrc $(HOME)/.kshrc cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d +install-login-shell: + sh dist/install-login-shell.sh + install-perlcritic: cp -p -- perlcritic/perlcriticrc $(HOME)/.perlcriticrc diff --git a/README.markdown b/README.markdown index 8a85f048..1b53ae58 100644 --- a/README.markdown +++ b/README.markdown @@ -38,7 +38,6 @@ The default `install` target will install these targets and all their dependencies. Note that you don't actually have to have any of this except `sh` installed. -* `install-bash` * `install-bin` * `install-bin-man` * `install-curl` @@ -46,10 +45,13 @@ installed. * `install-git` * `install-gnupg` * `install-less` +* `install-login-shell` * `install-readline` -* `install-sh` * `install-vim` +The `install-login-shell` looks at your `SHELL` environment variable and tries +to figure out which shell to install, falling back on just plain `install-sh`. + The remaining dotfiles can be installed with the other `install-*` targets. Try `sh bin/mftl.sh Makefile` in the project's root directory to see a list. diff --git a/dist/install-login-shell.sh b/dist/install-login-shell.sh new file mode 100644 index 00000000..b7292a77 --- /dev/null +++ b/dist/install-login-shell.sh @@ -0,0 +1,12 @@ +target=install-sh +case ${SHELL##*/} in + bash) + target=install-bash ;; + ksh|ksh88|ksh93|mksh|pdksh) + target=install-ksh ;; + yash) + target=install-yash ;; + zsh) + target=install-zsh ;; +esac +make "$target" -- cgit v1.2.3 From 721b3f4d6348738274a54759cdd1759bda00fa62 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:40:09 +1200 Subject: Dependency name sort --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2aade4ff..e8fdab62 100644 --- a/Makefile +++ b/Makefile @@ -261,8 +261,8 @@ install: install-bin \ install-git \ install-gnupg \ install-less \ - install-readline \ install-login-shell \ + install-readline \ install-vim install-abook: -- cgit v1.2.3 From 72462177caadc4ee909cebbcbcec8fd468335ed7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:41:39 +1200 Subject: Make instructions login shell agnostic --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 1b53ae58..a6720e9e 100644 --- a/README.markdown +++ b/README.markdown @@ -32,7 +32,7 @@ directory so you can explore: $ tmpdir=$(mktemp -d) $ make install HOME="$tmpdir" - $ env -i HOME="$tmpdir" TERM="$TERM" bash -l + $ env -i HOME="$tmpdir" TERM="$TERM" "$SHELL" -l The default `install` target will install these targets and all their dependencies. Note that you don't actually have to have any of this except `sh` -- cgit v1.2.3 From 35e5993969454d63f53526d26add29be7ac45466 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 12:44:54 +1200 Subject: Add FreeBSD foundation to suggested donations --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index a6720e9e..85aca3a2 100644 --- a/README.markdown +++ b/README.markdown @@ -611,4 +611,5 @@ advocacy group, and let me know you did it because of this project: * [Free Software Foundation](https://www.fsf.org/) * [Software in the Public Interest](http://www.spi-inc.org/) +* [FreeBSD Foundation](https://www.freebsdfoundation.org/) * [OpenBSD Foundation](http://www.openbsdfoundation.org/) -- cgit v1.2.3 From a9fce238c9d124b64c0baa0f412c9a02d48e80ae Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 7 Apr 2017 16:53:05 +1200 Subject: Clear .SUFFIXES first, add .sh --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8fdab62..adfec8d7 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,8 @@ lint-sh \ lint-urxvt -.SUFFIXES: .awk .bash .pl .sed +.SUFFIXES: +.SUFFIXES: .awk .bash .pl .sed .sh NAME = 'Tom Ryder' EMAIL = tom@sanctum.geek.nz -- cgit v1.2.3 From d48f40ec6e8bdfef99cbe8632244e83fe8e38553 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Apr 2017 14:02:28 +1200 Subject: Specify install-login-shell as .PHONY target --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index adfec8d7..e726a2be 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ install-gtk \ install-i3 \ install-less \ + install-login-shell \ install-mutt \ install-ncmcpp \ install-newsbeuter \ -- cgit v1.2.3 From 53e3630f8234eae75b219914f3f78054eb989584 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Apr 2017 14:28:44 +1200 Subject: Restructure shell install and check --- Makefile | 58 +++++++++++++++++++++++++++------------------------- check/login-shell.sh | 12 +++++++++++ 2 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 check/login-shell.sh diff --git a/Makefile b/Makefile index e726a2be..8a363e89 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,9 @@ install-tmux \ install-urxvt \ install-vim \ - install-gvim \ + install-vim-gui \ install-vim-config \ - install-gvim-config \ + install-vim-gui-config \ install-vim-plugins \ install-vim-pathogen \ install-x \ @@ -48,6 +48,7 @@ check-bin \ check-games \ check-ksh \ + check-login-shell \ check-sh \ check-urxvt \ check-yash \ @@ -57,9 +58,9 @@ lint-bin \ lint-games \ lint-ksh \ - lint-yash \ lint-sh \ - lint-urxvt + lint-urxvt \ + lint-yash .SUFFIXES: .SUFFIXES: .awk .bash .pl .sed .sh @@ -271,7 +272,7 @@ install-abook: mkdir -p -- $(HOME)/.abook cp -p -- abook/abookrc $(HOME)/.abook -install-bash: install-sh +install-bash: check-bash install-sh mkdir -p -- $(HOME)/.bashrc.d $(HOME)/.bash_completion.d $(HOME)/.config cp -p -- bash/bashrc $(HOME)/.bashrc cp -p -- bash/bashrc.d/* $(HOME)/.bashrc.d @@ -355,13 +356,13 @@ install-newsbeuter: install-mysql: cp -p -- mysql/my.cnf $(HOME)/.my.cnf -install-ksh: install-sh +install-ksh: check-ksh install-sh mkdir -p -- $(HOME)/.shrc.d $(HOME)/.kshrc.d cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d cp -p -- ksh/kshrc $(HOME)/.kshrc cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d -install-login-shell: +install-login-shell: check-login-shell sh dist/install-login-shell.sh install-perlcritic: @@ -376,7 +377,7 @@ install-psql: install-readline: cp -p -- readline/inputrc $(HOME)/.inputrc -install-sh: +install-sh: check-sh mkdir -p -- $(HOME)/.profile.d $(HOME)/.shrc.d cp -p -- sh/profile $(HOME)/.profile cp -p -- sh/profile.d/* $(HOME)/.profile.d @@ -404,13 +405,13 @@ install-vim: install-vim-config \ install-vim-plugins \ install-vim-pathogen -install-gvim: install-vim \ - install-gvim-config - install-vim-config: cp -p -- vim/vimrc $(HOME)/.vimrc -install-gvim-config: +install-vim-gui: install-vim \ + install-vim-gui-config + +install-vim-gui-config: cp -p -- vim/gvimrc $(HOME)/.gvimrc install-vim-plugins: install-vim-config @@ -435,25 +436,23 @@ install-x: cp -p -- X/Xresources $(HOME)/.Xresources cp -p -- X/Xresources.d/* $(HOME)/.Xresources.d -install-yash: install-sh +install-yash: install-yash install-sh mkdir -p -- $(HOME)/.yashrc.d cp -p -- yash/yash_profile $(HOME)/.yash_profile cp -p -- yash/yashrc $(HOME)/.yashrc cp -p -- yash/yashrc.d/* $(HOME)/.yashrc.d -install-zsh: install-sh +install-zsh: check-zsh install-sh mkdir -p -- $(HOME)/.profile.d $(HOME)/.zshrc.d cp -p -- zsh/profile.d/* $(HOME)/.profile.d cp -p -- zsh/zprofile $(HOME)/.zprofile cp -p -- zsh/zshrc $(HOME)/.zshrc cp -p -- zsh/zshrc.d/* $(HOME)/.zshrc.d -check: check-bash \ - check-bin \ - check-games \ +check: check-bin \ + check-login-shell \ check-man \ - check-sh \ - check-urxvt + check-sh check-bash: sh check/bash.sh @@ -470,6 +469,9 @@ check-man: check-ksh: sh check/ksh.sh +check-login-shell: + sh check/login-shell.sh + check-sh: sh check/sh.sh @@ -482,32 +484,32 @@ check-yash: check-zsh: sh check/zsh.sh -lint: check \ - lint-bash \ +lint: lint-bash \ lint-bin \ lint-games \ lint-ksh \ lint-sh \ lint-urxvt \ + lint-x \ lint-yash -lint-bash: +lint-bash: check-bash sh lint/bash.sh -lint-bin: +lint-bin: check-bin sh lint/bin.sh -lint-games: +lint-games: check-games sh lint/games.sh -lint-ksh: +lint-ksh: check-ksh sh lint/ksh.sh -lint-sh: +lint-sh: check-sh sh lint/sh.sh -lint-urxvt: +lint-urxvt: check-urxvt sh lint/urxvt.sh -lint-yash: +lint-yash: check-yash sh lint/yash.sh diff --git a/check/login-shell.sh b/check/login-shell.sh new file mode 100644 index 00000000..20327b94 --- /dev/null +++ b/check/login-shell.sh @@ -0,0 +1,12 @@ +target=check-sh +case ${SHELL##*/} in + bash) + target=check-bash ;; + ksh|ksh88|ksh93|mksh|pdksh) + target=check-ksh ;; + yash) + target=check-yash ;; + zsh) + target=check-zsh ;; +esac +make "$target" -- cgit v1.2.3 From cd6c4ff92b7e6da0f48abbd0e455f16cc681f80e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Apr 2017 14:29:03 +1200 Subject: Add xinitrc.d script checks --- Makefile | 12 ++++++++++-- check/xinit.sh | 4 ++++ lint/xinit.sh | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 check/xinit.sh create mode 100644 lint/xinit.sh diff --git a/Makefile b/Makefile index 8a363e89..cb814c22 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ check-login-shell \ check-sh \ check-urxvt \ + check-xinit \ check-yash \ check-zsh \ lint \ @@ -60,6 +61,7 @@ lint-ksh \ lint-sh \ lint-urxvt \ + lint-xinit \ lint-yash .SUFFIXES: @@ -423,7 +425,7 @@ install-vim-pathogen: install-vim-plugins mkdir -p -- $(HOME)/.vim/autoload ln -fs -- ../bundle/pathogen/autoload/pathogen.vim $(HOME)/.vim/autoload -install-x: +install-x: check-xinit mkdir -p -- \ $(HOME)/.config \ $(HOME)/.config/sxhkdrc \ @@ -478,6 +480,9 @@ check-sh: check-urxvt: sh check/urxvt.sh +check-xinit: + sh check/xinit.sh + check-yash: sh check/yash.sh @@ -490,7 +495,7 @@ lint: lint-bash \ lint-ksh \ lint-sh \ lint-urxvt \ - lint-x \ + lint-xinit \ lint-yash lint-bash: check-bash @@ -511,5 +516,8 @@ lint-sh: check-sh lint-urxvt: check-urxvt sh lint/urxvt.sh +lint-xinit: check-xinit + sh lint/xinit.sh + lint-yash: check-yash sh lint/yash.sh diff --git a/check/xinit.sh b/check/xinit.sh new file mode 100644 index 00000000..f8116908 --- /dev/null +++ b/check/xinit.sh @@ -0,0 +1,4 @@ +for xinit in X/xinitrc X/xinitrc.d/*.sh ; do + sh -n "$xinit" || exit +done +printf 'X/xinitrc and all shell scripts in X/xinitrc.d parsed successfully.\n' diff --git a/lint/xinit.sh b/lint/xinit.sh new file mode 100644 index 00000000..b5ff6937 --- /dev/null +++ b/lint/xinit.sh @@ -0,0 +1 @@ +find X -type f \( -name xinitrc -o -name '*.sh' \) -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 From e759edd25db3e831932baa5bd6fe4f79c556f91b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Apr 2017 14:45:48 +1200 Subject: Rename "dist" to "install" --- Makefile | 2 +- dist/install-login-shell.sh | 12 ------------ install/install-login-shell.sh | 12 ++++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 dist/install-login-shell.sh create mode 100644 install/install-login-shell.sh diff --git a/Makefile b/Makefile index cb814c22..3fef5221 100644 --- a/Makefile +++ b/Makefile @@ -365,7 +365,7 @@ install-ksh: check-ksh install-sh cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d install-login-shell: check-login-shell - sh dist/install-login-shell.sh + sh install/install-login-shell.sh install-perlcritic: cp -p -- perlcritic/perlcriticrc $(HOME)/.perlcriticrc diff --git a/dist/install-login-shell.sh b/dist/install-login-shell.sh deleted file mode 100644 index b7292a77..00000000 --- a/dist/install-login-shell.sh +++ /dev/null @@ -1,12 +0,0 @@ -target=install-sh -case ${SHELL##*/} in - bash) - target=install-bash ;; - ksh|ksh88|ksh93|mksh|pdksh) - target=install-ksh ;; - yash) - target=install-yash ;; - zsh) - target=install-zsh ;; -esac -make "$target" diff --git a/install/install-login-shell.sh b/install/install-login-shell.sh new file mode 100644 index 00000000..b7292a77 --- /dev/null +++ b/install/install-login-shell.sh @@ -0,0 +1,12 @@ +target=install-sh +case ${SHELL##*/} in + bash) + target=install-bash ;; + ksh|ksh88|ksh93|mksh|pdksh) + target=install-ksh ;; + yash) + target=install-yash ;; + zsh) + target=install-zsh ;; +esac +make "$target" -- cgit v1.2.3 From 6b80707af3f400c92290e49a689f15c510d01c9d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Apr 2017 15:01:11 +1200 Subject: Fix up .PHONY targets --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3fef5221..f7f90575 100644 --- a/Makefile +++ b/Makefile @@ -19,27 +19,28 @@ install-gnupg \ install-gtk \ install-i3 \ + install-ksh \ install-less \ install-login-shell \ install-mutt \ + install-mysql \ install-ncmcpp \ install-newsbeuter \ - install-mysql \ - install-ksh \ install-perlcritic \ install-perltidy \ install-psql \ install-readline \ install-sh \ install-subversion \ + install-terminfo \ install-tmux \ install-urxvt \ install-vim \ - install-vim-gui \ install-vim-config \ + install-vim-gui \ install-vim-gui-config \ - install-vim-plugins \ install-vim-pathogen \ + install-vim-plugins \ install-x \ install-yash \ install-zsh \ @@ -49,6 +50,7 @@ check-games \ check-ksh \ check-login-shell \ + check-man \ check-sh \ check-urxvt \ check-xinit \ -- cgit v1.2.3 From efd95c34c7db7686600571243ca00196276fa0ad Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 12 Apr 2017 09:51:27 +1200 Subject: Use more logical ~/.cache subpath --- sh/profile.d/options.sh | 2 +- sh/shrc.d/bc.sh | 4 ++-- sh/shrc.d/ed.sh | 2 +- sh/shrc.d/grep.sh | 14 +++++++------- sh/shrc.d/la.sh | 2 +- sh/shrc.d/ll.sh | 2 +- sh/shrc.d/ls.sh | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index 1a511d75..89b5d245 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -5,7 +5,7 @@ options() { # Check or create the directory to cache the options # Shift the program name off; remaining arguments are the options to check - dir=$HOME/.cache/$1 + dir=$HOME/.cache/sh/opt/$1 prog=$1 shift diff --git a/sh/shrc.d/bc.sh b/sh/shrc.d/bc.sh index 41331ff9..aee88e09 100644 --- a/sh/shrc.d/bc.sh +++ b/sh/shrc.d/bc.sh @@ -1,12 +1,12 @@ # Our ~/.profile should already have made a directory with the supported # options for us; if not, we won't be wrapping bc(1) with a function at all -[ -d "$HOME"/.cache/bc ] || return +[ -d "$HOME"/.cache/sh/opt/bc ] || return # Define function proper bc() { # Add --quiet to stop the annoying welcome banner - [ -e "$HOME"/.cache/bc/quiet ] && + [ -e "$HOME"/.cache/sh/opt/bc/quiet ] && set -- --quiet "$@" # Run bc(1) with the concluded arguments diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index d7d3fa2f..a2b7818e 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -8,7 +8,7 @@ ed() { fi # Add --verbose to explain errors - [ -e "$HOME"/.cache/ed/verbose ] && + [ -e "$HOME"/.cache/sh/opt/ed/verbose ] && set -- --verbose "$@" # Add an asterisk prompt (POSIX feature) diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index fc8f62c0..dd85a198 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -1,6 +1,6 @@ # Our ~/.profile should already have made a directory with the supported # options for us; if not, we won't be wrapping grep(1) with a function at all -[ -d "$HOME"/.cache/grep ] || return +[ -d "$HOME"/.cache/sh/opt/grep ] || return # Discard GNU grep(1) environment variables if the environment set them unset -v GREP_OPTIONS @@ -9,31 +9,31 @@ unset -v GREP_OPTIONS grep() { # Add --binary-files=without-match to gracefully skip binary files - [ -e "$HOME"/.cache/grep/binary-files ] && + [ -e "$HOME"/.cache/sh/opt/grep/binary-files ] && set -- --binary-files=without-match "$@" # Add --color=auto if the terminal has at least 8 colors - [ -e "$HOME"/.cache/grep/color ] && + [ -e "$HOME"/.cache/sh/opt/grep/color ] && [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" # Add --devices=skip to gracefully skip devices - [ -e "$HOME"/.cache/grep/devices ] && + [ -e "$HOME"/.cache/sh/opt/grep/devices ] && set -- --devices=skip "$@" # Add --directories=skip to gracefully skip directories - [ -e "$HOME"/.cache/grep/directories ] && + [ -e "$HOME"/.cache/sh/opt/grep/directories ] && set -- --directories=skip "$@" # Add --exclude to ignore .gitignore and .gitmodules files - [ -e "$HOME"/.cache/grep/exclude ] && + [ -e "$HOME"/.cache/sh/opt/grep/exclude ] && set -- \ --exclude=.gitignore \ --exclude=.gitmodules \ "$@" # Add --exclude-dir to ignore version control dot-directories - [ -e "$HOME"/.cache/grep/exclude-dir ] && + [ -e "$HOME"/.cache/sh/opt/grep/exclude-dir ] && set -- \ --exclude-dir=.cvs \ --exclude-dir=.git \ diff --git a/sh/shrc.d/la.sh b/sh/shrc.d/la.sh index e21ad8fb..1ac44b8e 100644 --- a/sh/shrc.d/la.sh +++ b/sh/shrc.d/la.sh @@ -1,7 +1,7 @@ # Run ls -A if we can (-A is not POSIX), ls -a otherwise la() { # Prefer --almost-all (exclude "." and "..") if available - if [ -e "$HOME"/.cache/ls/almost-all ] ; then + if [ -e "$HOME"/.cache/sh/opt/ls/almost-all ] ; then set -- -A "$@" else set -- -a "$@" diff --git a/sh/shrc.d/ll.sh b/sh/shrc.d/ll.sh index c8c95d3b..e9737c62 100644 --- a/sh/shrc.d/ll.sh +++ b/sh/shrc.d/ll.sh @@ -1,7 +1,7 @@ # Run ls -Al if we can (-A is not POSIX), ls -al otherwise ll() { # Prefer -A/--almost-all (exclude "." and "..") if available - if [ -e "$HOME"/.cache/ls/almost-all ] ; then + if [ -e "$HOME"/.cache/sh/opt/ls/almost-all ] ; then set -- -Al "$@" else set -- -al "$@" diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 18f50a8b..b5acfcf9 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -1,6 +1,6 @@ # Our ~/.profile should already have made a directory with the supported # options for us; if not, we won't be wrapping ls(1) with a function at all -[ -d "$HOME"/.cache/ls ] || return +[ -d "$HOME"/.cache/sh/opt/ls ] || return # If the system has already aliased ls(1) for us, like Slackware or OpenBSD # does, just get rid of it @@ -20,17 +20,17 @@ ls() { [ -t 1 ] && set -- -x "$@" # Add --block-size=K to always show the filesize in kibibytes - [ -e "$HOME"/.cache/ls/block-size ] && + [ -e "$HOME"/.cache/sh/opt/ls/block-size ] && set -- --block-size=1024 "$@" # Add --color if the terminal has at least 8 colors - [ -e "$HOME"/.cache/ls/color ] && + [ -e "$HOME"/.cache/sh/opt/ls/color ] && [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" # Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred # (fixed) format - [ -e "$HOME"/.cache/ls/time-style ] && + [ -e "$HOME"/.cache/sh/opt/ls/time-style ] && set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" # Run ls(1) with the concluded arguments -- cgit v1.2.3 From ea90dec931a43fc2619ca7749e0ce15d6eb374f0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Apr 2017 00:22:02 +1200 Subject: Mod4+v fires up vim --- X/sxhkdrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/X/sxhkdrc b/X/sxhkdrc index 5a75f1df..7816208f 100644 --- a/X/sxhkdrc +++ b/X/sxhkdrc @@ -28,6 +28,9 @@ super + m super + p dmp +super + v + urxvtcd -e "$VISUAL" + super + slash i3lock --color=#000000 --image ~/.i3/lock.png --nofork -- cgit v1.2.3 From 86d7ba02c2fa643ae72425ec829956c6eb84cee5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Apr 2017 00:24:37 +1200 Subject: Update ~/.cache path in bcq(1df) --- bin/bcq.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/bcq.sh b/bin/bcq.sh index 71a79666..a6c0fe60 100644 --- a/bin/bcq.sh +++ b/bin/bcq.sh @@ -1,3 +1,3 @@ # Fire up bc(1), hushing it if it looks like GNU -[ -e "$HOME"/.cache/bc/quiet ] && set -- --quiet "$@" +[ -e "$HOME"/.cache/sh/opt/bc/quiet ] && set -- --quiet "$@" exec bc "$@" -- cgit v1.2.3 From 5743fa9a7cf7734c77b89410c0a3591b1186c68f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 14 Apr 2017 02:22:34 +1200 Subject: Add an issue --- ISSUES.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 4c78a3f3..a69e07df 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -21,3 +21,5 @@ Known issues * Would be good to complete the Makefile variables for NAME, EMAIL etc with educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding my own stuff in there +* Completion for custom functions e.g. `sd` should ideally respect + `completion-ignore-case` setting -- cgit v1.2.3 From d647afdeae630ed4e8e692e9704632c37faad2db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 21 Apr 2017 16:49:29 +1200 Subject: Add brief comment to top of quo.sed --- bin/quo.sed | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/quo.sed b/bin/quo.sed index 26250e9e..87bdbfda 100644 --- a/bin/quo.sed +++ b/bin/quo.sed @@ -1,2 +1,3 @@ +# Quote or re-quote input in an email style /^[^>]/s/^/ / s/^/>/ -- cgit v1.2.3 From d06b05229616899e22f5bbfa2caca14ff60b704e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 21 Apr 2017 17:17:57 +1200 Subject: Add some missing leading comments --- bin/dmp.sh | 1 + bin/hms.awk | 1 + bin/jfcd.sh | 1 - bin/pit.sh | 1 + bin/plmu.sh | 1 + bin/rfcf.sh | 1 + bin/rfcr.sh | 1 + 7 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/dmp.sh b/bin/dmp.sh index ea79214f..ab09c20e 100644 --- a/bin/dmp.sh +++ b/bin/dmp.sh @@ -1,3 +1,4 @@ +# Pick a pass(1) password with dmenu(1) # Get the password store directory, bail if we can't pwsd=${PASSWORD_STORE_DIR:-"$HOME"/.password-store} diff --git a/bin/hms.awk b/bin/hms.awk index 3a9a1499..3054db44 100644 --- a/bin/hms.awk +++ b/bin/hms.awk @@ -1,3 +1,4 @@ +# Convert seconds to colon-delimited durations BEGIN { OFS = ":" } diff --git a/bin/jfcd.sh b/bin/jfcd.sh index bf059883..25bf03fd 100644 --- a/bin/jfcd.sh +++ b/bin/jfcd.sh @@ -1,4 +1,3 @@ - # Watch a directory for changes and commit them with jfc(1d) if there are any; # requires inotifywait(1) self=jfcd diff --git a/bin/pit.sh b/bin/pit.sh index 377c1927..418732d0 100644 --- a/bin/pit.sh +++ b/bin/pit.sh @@ -1,3 +1,4 @@ +# Show arguments or output in a pager if stdout looks like a terminal # If no arguments, we'll use stdin if [ "$#" -eq 0 ] ; then diff --git a/bin/plmu.sh b/bin/plmu.sh index d6f163e6..b6a500ac 100644 --- a/bin/plmu.sh +++ b/bin/plmu.sh @@ -1,3 +1,4 @@ +# Upgrade plenv modules with cpanm(1) # Set up exceptions file if it exists ef=$HOME/.plenv/non-cpanm-modules diff --git a/bin/rfcf.sh b/bin/rfcf.sh index 36b1a4c4..214f4e64 100644 --- a/bin/rfcf.sh +++ b/bin/rfcf.sh @@ -1,3 +1,4 @@ +# Fetch an RFC from the IETF site and write it to stdout # Check arguments if [ "$#" -ne 1 ] ; then diff --git a/bin/rfcr.sh b/bin/rfcr.sh index 860ae53d..30954154 100644 --- a/bin/rfcr.sh +++ b/bin/rfcr.sh @@ -1,3 +1,4 @@ +# Fetch and format an RFC from the IETF website and view it on a terminal # Check arguments if [ "$#" -ne 1 ] ; then -- cgit v1.2.3 From 53326f6e5fc657d18bf68714754d4d8562dda22b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 22 Apr 2017 17:14:30 +1200 Subject: Streamline csmw(1df) a bit --- bin/csmw.awk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/csmw.awk b/bin/csmw.awk index b1cd20cb..05481305 100644 --- a/bin/csmw.awk +++ b/bin/csmw.awk @@ -1,14 +1,14 @@ # Print an English comma-separated list of monospace-quoted words (backticks) { for (i = 1; i <= NF; i++) - ws[++wc] = $i + ws[++wc] = "`" $i "`" } END { if (wc > 2) - for (i = 1; i <= wc; i++) - printf (i < wc) ? "`%s`, " : "and `%s`\n", ws[i] + for (i in ws) + printf (i < wc) ? "%s, " : "and %s\n", ws[i] else if (wc == 2) - printf "`%s` and `%s`\n", ws[1], ws[2] + printf "%s and %s\n", ws[1], ws[2] else if (wc == 1) - printf "`%s`\n", ws[1] + printf "%s\n", ws[1] } -- cgit v1.2.3 From 1a5427174d4493ddfb3f700fdeba60d67b5fb944 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 22 Apr 2017 17:19:14 +1200 Subject: Restore explicit iteration to csmw(1df) Turns out the for...in construct doesn't specify an order in POSIX --- bin/csmw.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/csmw.awk b/bin/csmw.awk index 05481305..4479d8f8 100644 --- a/bin/csmw.awk +++ b/bin/csmw.awk @@ -5,7 +5,7 @@ } END { if (wc > 2) - for (i in ws) + for (i = 1; i <= wc; i++) printf (i < wc) ? "%s, " : "and %s\n", ws[i] else if (wc == 2) printf "%s and %s\n", ws[1], ws[2] -- cgit v1.2.3 From d1553fb72c34c60745949b2e19996b7ed74076b8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 23 Apr 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/repeat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/repeat b/vim/bundle/repeat index 7a6675f0..070ee903 160000 --- a/vim/bundle/repeat +++ b/vim/bundle/repeat @@ -1 +1 @@ -Subproject commit 7a6675f092842c8f81e71d5345bd7cdbf3759415 +Subproject commit 070ee903245999b2b79f7386631ffd29ce9b8e9f -- cgit v1.2.3 From 8f120e9b212a76ac63e9420d22a2c7e30149def1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 26 Apr 2017 17:51:47 +1200 Subject: Fix mex(1df) manual page --- man/man1/mex.1df | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/man/man1/mex.1df b/man/man1/mex.1df index 0fa584da..5c387594 100644 --- a/man/man1/mex.1df +++ b/man/man1/mex.1df @@ -10,12 +10,13 @@ name name1 name2 name3 .br PATH=/foo:/bar/baz +.B mex name .SH DESCRIPTION -Iterate through the contents of the PATH variable looking for files with any of +Iterate through the directories named in $PATH looking for files with any of the specified names that do not have the executable permissions bit set, and -try to set it if found. Exit nonzero if any of the names were not found, or if -any of the permissions changes failed. +attempt to set them if any such files are found. Exit nonzero if any of the +names were not found, or if any of the permissions changes failed. .SH SEE ALSO chmod(1), eds(1df) .SH AUTHOR -- cgit v1.2.3 From 3cc4fc30c0ab6fe5045718692a6fd64c08b42119 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 27 Apr 2017 16:33:31 +1200 Subject: Corrections to quo(1df) man page --- man/man1/quo.1df | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/man1/quo.1df b/man/man1/quo.1df index 0b651388..56cf685a 100644 --- a/man/man1/quo.1df +++ b/man/man1/quo.1df @@ -16,9 +16,9 @@ FILE1 [FILE2...] < FILE .SH DESCRIPTION .B quo -quotes its input by insert a right-angle bracket followed by a space at the +quotes its input by inserting a right-angle bracket followed by a space at the start of every unquoted line. If the line was already quoted, it adds another -level of right-angle bracket. +level of right-angle brackets. .SH SEE ALSO wro(1df) .SH AUTHOR -- cgit v1.2.3 From 99ce821b209b61d19240e4ef95efe2f626025f7e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 28 Apr 2017 12:42:51 +1200 Subject: Add grec(1df) and gred(1df) --- .gitignore | 2 ++ Makefile | 2 ++ README.markdown | 2 ++ bin/grec.sh | 2 ++ bin/gred.sh | 2 ++ man/man1/grec.1df | 13 +++++++++++++ man/man1/gred.1df | 13 +++++++++++++ 7 files changed, 36 insertions(+) create mode 100644 bin/grec.sh create mode 100755 bin/gred.sh create mode 100644 man/man1/grec.1df create mode 100644 man/man1/gred.1df diff --git a/.gitignore b/.gitignore index 660e0ddb..bb4e5163 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ bin/finc bin/fnl bin/gms bin/grc +bin/grec +bin/gred bin/gscr bin/gwp bin/han diff --git a/Makefile b/Makefile index f7f90575..1f06814c 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,8 @@ BINS = bin/ap \ bin/fnl \ bin/gms \ bin/grc \ + bin/grec \ + bin/gred \ bin/gscr \ bin/gwp \ bin/han \ diff --git a/README.markdown b/README.markdown index 85aca3a2..14b15ff5 100644 --- a/README.markdown +++ b/README.markdown @@ -488,6 +488,8 @@ Installed by the `install-bin` target: * `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the script `getmails` in the `getmail` suite, but runs the requests in parallel and does up to three silent retries using `try(1df)`. +* `grec(1df)` is a more logically-named `grep -c`. +* `gred(1df)` is a more logically-named `grep -v`. * `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. * `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will look for `help` topics. You could use it from the shell too. diff --git a/bin/grec.sh b/bin/grec.sh new file mode 100644 index 00000000..035b7cce --- /dev/null +++ b/bin/grec.sh @@ -0,0 +1,2 @@ +# g/re/c +grep -c "$@" diff --git a/bin/gred.sh b/bin/gred.sh new file mode 100755 index 00000000..46de5dce --- /dev/null +++ b/bin/gred.sh @@ -0,0 +1,2 @@ +# g/re/d +grep -v "$@" diff --git a/man/man1/grec.1df b/man/man1/grec.1df new file mode 100644 index 00000000..8759aa33 --- /dev/null +++ b/man/man1/grec.1df @@ -0,0 +1,13 @@ +.TH GREC 1df "April 2017" "Manual page for grec" +.SH NAME +.B grec +\- saner name for grep -c +.SH SYNOPSIS +.B grec PATTERN [FILE...] +.br +.SH DESCRIPTION +.B grec +is the same as grep(1) when run with a a -c option, because the name always +bugged me a bit--"g/re/p, except don't print it, count it"? +.SH AUTHOR +Tom Ryder diff --git a/man/man1/gred.1df b/man/man1/gred.1df new file mode 100644 index 00000000..8fcc4d74 --- /dev/null +++ b/man/man1/gred.1df @@ -0,0 +1,13 @@ +.TH GRED 1df "April 2017" "Manual page for gred" +.SH NAME +.B gred +\- saner name for grep -v +.SH SYNOPSIS +.B gred PATTERN [FILE...] +.br +.SH DESCRIPTION +.B gred +is the same as grep(1) when run with a a -v option, because the name always +bugged me a bit--"g/re/p, except don't print it, delete it"? +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 0e1de4da69d0b2e931a84b18fbe8149af18e809a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 28 Apr 2017 20:16:40 +1200 Subject: Update documentation URLs A few of them have gone HTTPS since the last check --- README.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 14b15ff5..94659faf 100644 --- a/README.markdown +++ b/README.markdown @@ -76,15 +76,15 @@ Configuration is included for: * [Git](https://git-scm.com/) -- Distributed version control system * [GnuPG](https://www.gnupg.org/) -- GNU Privacy Guard, for private communication and file encryption -* [GTK+](http://www.gtk.org/) -- GIMP Toolkit, for graphical user interface +* [GTK+](https://www.gtk.org/) -- GIMP Toolkit, for graphical user interface elements * [i3](https://i3wm.org/) -- Tiling window manager * [less](https://www.gnu.org/software/less/) -- Terminal pager * [Mutt](http://www.mutt.org/) -- Terminal mail user agent -* [`mysql(1)`](http://linux.die.net/man/1/mysql) -- Command-line MySQL client +* [`mysql(1)`](https://linux.die.net/man/1/mysql) -- Command-line MySQL client * [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client * [Newsbeuter](https://www.newsbeuter.org/) -- Terminal RSS/Atom feed reader -* [`psql(1)`](http://linux.die.net/man/1/psql) -- Command-line PostgreSQL +* [`psql(1)`](https://linux.die.net/man/1/psql) -- Command-line PostgreSQL client * [Perl::Critic](http://perlcritic.com/) -- static source code analysis engine for Perl @@ -301,7 +301,7 @@ neither tilde nor `$HOME` expansion works for this. My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where most unfiltered mail is sent. I use [Getmail](http://pyropus.ca/software/getmail/), -[maildrop](http://www.courier-mta.org/maildrop/), and +[maildrop](https://www.courier-mta.org/maildrop/), and [MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not included here. I sign whenever I have some indication that the recipient might be using a PGP implementation, and I encrypt whenever I have a public key @@ -327,7 +327,7 @@ Perl extensions. If you're missing functionality, try changing My choice of font is [Ubuntu Mono](http://font.ubuntu.com/), but the file should allow falling back to the more common [Deja Vu Sans -Mono](http://dejavu-fonts.org/wiki/Main_Page). I've found +Mono](https://dejavu-fonts.github.io/). I've found [Terminus](http://terminus-font.sourceforge.net/) works well too, but bitmap fonts are not really my cup of tea. The Lohit Kannada font bit is purely to make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box. @@ -612,6 +612,6 @@ If you're feeling generous, please join and/or donate to a free software advocacy group, and let me know you did it because of this project: * [Free Software Foundation](https://www.fsf.org/) -* [Software in the Public Interest](http://www.spi-inc.org/) +* [Software in the Public Interest](https://www.spi-inc.org/) * [FreeBSD Foundation](https://www.freebsdfoundation.org/) * [OpenBSD Foundation](http://www.openbsdfoundation.org/) -- cgit v1.2.3 From c31338baca39b5a545ce307327fea2fefb9ed99e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 1 May 2017 21:47:15 +1200 Subject: Add squ(6df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + games/squ.awk | 10 ++++++++++ man/man6/squ.6df | 28 ++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 games/squ.awk create mode 100644 man/man6/squ.6df diff --git a/.gitignore b/.gitignore index bb4e5163..ea3ec93a 100644 --- a/.gitignore +++ b/.gitignore @@ -124,6 +124,7 @@ games/drakon games/kvlt games/rndn games/rot13 +games/squ games/strik games/xyzzy games/zs diff --git a/Makefile b/Makefile index 1f06814c..9d987150 100644 --- a/Makefile +++ b/Makefile @@ -201,6 +201,7 @@ GAMES = games/aaf \ games/kvlt \ games/rndn \ games/rot13 \ + games/squ \ games/strik \ games/xyzzy \ games/zs diff --git a/README.markdown b/README.markdown index 94659faf..2d8003c6 100644 --- a/README.markdown +++ b/README.markdown @@ -555,6 +555,7 @@ There's some silly stuff in `install-games`: * `acq(6df)` allows you to interrogate AC, the interplanetary computer. * `aesth(6df)` converts English letters to their fullwidth CJK analogues, for AESTHETIC PURPOSES. +* `squ(6df)` makes a word square out of each line of input. * `kvlt(6df)` translates input to emulate a style of typing unique to black metal communities on the internet. * `rndn(6df)` implements an esoteric random number generation algorithm. diff --git a/games/squ.awk b/games/squ.awk new file mode 100644 index 00000000..0d8f9210 --- /dev/null +++ b/games/squ.awk @@ -0,0 +1,10 @@ +# Make a square out of each line of input +{ + str = toupper($0) + len = length(str) + for (i = 1; i <= len; i++) + let[i - 1] = substr(str, i, 1) + for (j in let) + for (k in let) + printf (k < len - 1) ? "%s " : "%s\n", let[(k + j) % len] +} diff --git a/man/man6/squ.6df b/man/man6/squ.6df new file mode 100644 index 00000000..c3ae177e --- /dev/null +++ b/man/man6/squ.6df @@ -0,0 +1,28 @@ +.TH SQU 6df "May 2017" "Manual page for squ" +.SH NAME +.B squ +\- print a word square out of each line of input +.SH USAGE +.B squ +.br +london +.br +^D +.br +L O N D O N +.br +O N D O N L +.br +N D O N L O +.br +D O N L O N +.br +O N L O N D +.br +N L O N D O +.SH DESCRIPTION +.B squ +makes a kind of letter square out of the characters on each line of input, +uppercasing them first. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 48e7e3469c587eee590e3ef351003b276373c526 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 1 May 2017 21:54:35 +1200 Subject: Correct type of square --- games/squ.awk | 2 +- man/man6/squ.6df | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/games/squ.awk b/games/squ.awk index 0d8f9210..3cf3f57a 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -1,4 +1,4 @@ -# Make a square out of each line of input +# Make a reduced Latin square out of each line of input { str = toupper($0) len = length(str) diff --git a/man/man6/squ.6df b/man/man6/squ.6df index c3ae177e..f836f2cd 100644 --- a/man/man6/squ.6df +++ b/man/man6/squ.6df @@ -1,7 +1,7 @@ .TH SQU 6df "May 2017" "Manual page for squ" .SH NAME .B squ -\- print a word square out of each line of input +\- print a reduced Latin square made out of each line of input .SH USAGE .B squ .br @@ -22,7 +22,9 @@ O N L O N D N L O N D O .SH DESCRIPTION .B squ -makes a kind of letter square out of the characters on each line of input, +makes a reduced Latin square [1] out of the characters on each line of input, uppercasing them first. +.SH SEE ALSO +[1]: https://en.wikipedia.org/wiki/Latin_square#Reduced_form .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 77607983bc14762e4730e38e68fc3b0a704f6c9b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 1 May 2017 21:57:18 +1200 Subject: Remove unneeded ':' command --- games/dr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/dr.sh b/games/dr.sh index e1db163d..9f08164d 100644 --- a/games/dr.sh +++ b/games/dr.sh @@ -16,7 +16,7 @@ d=${nd#*d} # Check this is a real die you can actually roll case $d in - 4|6|8|10|12|20) : ;; + 4|6|8|10|12|20) ;; *) exit 2 ;; esac -- cgit v1.2.3 From 13a18bff05769655d2bc5087bce6068063d6a76f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:06:25 +1200 Subject: Fix inaccurate comment in README --- README.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2d8003c6..b761c382 100644 --- a/README.markdown +++ b/README.markdown @@ -50,7 +50,8 @@ installed. * `install-vim` The `install-login-shell` looks at your `SHELL` environment variable and tries -to figure out which shell to install, falling back on just plain `install-sh`. +to figure out which shell’s configuration files to install, falling back on +`install-sh`. The remaining dotfiles can be installed with the other `install-*` targets. Try `sh bin/mftl.sh Makefile` in the project's root directory to see a list. -- cgit v1.2.3 From f1c114d3f7c90e329fe49a2f868e830b9460e192 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:07:37 +1200 Subject: Fix a misplaced line --- README.markdown | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index b761c382..5a17f0fe 100644 --- a/README.markdown +++ b/README.markdown @@ -61,14 +61,13 @@ Tools Configuration is included for: -* Bourne-style POSIX shells, sharing an `ENV` file and functions: +* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and + some helper functions: * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) * [Korn shell](http://www.kornshell.com/) (including `pdksh`, `mksh`) * [Yash](https://yash.osdn.jp/index.html.en) * [Z shell](https://www.zsh.org/) * [Abook](http://abook.sourceforge.net/) -- curses address book program - including a `~/.profile` configured to work with most Bourne-compatible - shells * [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data with URL syntax * [Dunst](http://knopwob.org/dunst/) -- A lightweight X11 notification daemon -- cgit v1.2.3 From b7e47b0941ebd056f75bbf2d4a2e09a672b24170 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:26:25 +1200 Subject: Clean up clog(1df) a bit --- bin/clog.sh | 9 +++++++++ 1 file changed, 9 insertions(+) mode change 100644 => 100755 bin/clog.sh diff --git a/bin/clog.sh b/bin/clog.sh old mode 100644 new mode 100755 index 0964ce90..b17ff1c5 --- a/bin/clog.sh +++ b/bin/clog.sh @@ -1,7 +1,16 @@ +#!/bin/sh # Record a timestamped message to a logfile, defaulting to ~/.clog self=clog + +# Ignore arguments +set -- + +# If we have rlwrap, quietly use it command -v rlwrap >/dev/null 2>&1 && set -- rlwrap -C "$self" "$@" + +# Write the date, the standard input (rlwrapped if applicable), and two dashes +# to $CLOG, defaulting to ~/.clog. { date "$@" cat - -- cgit v1.2.3 From bcd890264f757d5ce1bd256525fcccaad90878d3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:30:32 +1200 Subject: Update square type --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 5a17f0fe..57d533f7 100644 --- a/README.markdown +++ b/README.markdown @@ -555,7 +555,7 @@ There's some silly stuff in `install-games`: * `acq(6df)` allows you to interrogate AC, the interplanetary computer. * `aesth(6df)` converts English letters to their fullwidth CJK analogues, for AESTHETIC PURPOSES. -* `squ(6df)` makes a word square out of each line of input. +* `squ(6df)` makes a reduced Latin square out of each line of input. * `kvlt(6df)` translates input to emulate a style of typing unique to black metal communities on the internet. * `rndn(6df)` implements an esoteric random number generation algorithm. -- cgit v1.2.3 From 4e46fccb3356a6893a8540de507988f13f5811d9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:32:52 +1200 Subject: Remove apology note for breaking links It's been long enough now --- README.markdown | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.markdown b/README.markdown index 57d533f7..0d71ed12 100644 --- a/README.markdown +++ b/README.markdown @@ -595,15 +595,6 @@ Known issues See ISSUES.markdown. -Note for previous visitors --------------------------- - -Most of this repository's five-year history was rewritten shortly after I moved -it from GitHub to cgit, taking advantage of the upheaval to reduce its size and -remove useless binary blobs and third-party stuff that I never should have -versioned anyway. If you've checked this out before, you'll probably need to do -it again, and per-commit links are likely to be broken. Sorry about that. - License ------- -- cgit v1.2.3 From 8f69423b4f7d952a0722173d949e916b80760b3d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 May 2017 00:34:36 +1200 Subject: Add squ alias to irssi config --- irssi/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/irssi/aliases b/irssi/aliases index b22da923..65e80c13 100644 --- a/irssi/aliases +++ b/irssi/aliases @@ -10,5 +10,6 @@ alias aesth exec - -out printf %s "$*" | aesth alias drakon exec - -out printf %s "$*" | drakon alias kvlt exec - -out printf %s "$*" | kvlt alias rot13 exec - -out printf %s "$*" | rot13 +alias squ exec - -out printf %s "$*" | squ alias strik exec - -out printf %s "$*" | strik alias zs exec - -out printf %s "$*" | zs -- cgit v1.2.3 From 19cf4900dab53b31bfd85e56900e9e8572c440cf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 4 May 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/unimpaired | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired index e9397719..0f72c70b 160000 --- a/vim/bundle/unimpaired +++ b/vim/bundle/unimpaired @@ -1 +1 @@ -Subproject commit e939771979393c502e2331fc7d44a963efd7bb46 +Subproject commit 0f72c70b672aeadaaab94e430267b1435c1b2441 -- cgit v1.2.3 From 76a0e48bdbfbe53792a591c6567740cf7a3ce378 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 5 May 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 020ab25c..0f471006 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 020ab25c38f62627c1dab6c7a851176c6ad309f9 +Subproject commit 0f4710063ecc98d77dc03698c4a917a3215bdf09 -- cgit v1.2.3 From 13a4187ab7cf193d626c6a9ce6f4f87fe2ef837f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 10 May 2017 23:20:51 +1200 Subject: Add pst(1df), ped(1df), and pvi(1df) --- .gitignore | 3 +++ Makefile | 3 +++ README.markdown | 5 +++++ bin/clog.sh | 0 bin/gred.sh | 0 bin/ped.sh | 2 ++ bin/pst.sh | 32 ++++++++++++++++++++++++++++++++ bin/pvi.sh | 2 ++ man/man1/ped.1df | 19 +++++++++++++++++++ man/man1/pst.1df | 25 +++++++++++++++++++++++++ man/man1/pvi.1df | 19 +++++++++++++++++++ 11 files changed, 110 insertions(+) mode change 100755 => 100644 bin/clog.sh mode change 100755 => 100644 bin/gred.sh create mode 100644 bin/ped.sh create mode 100644 bin/pst.sh create mode 100644 bin/pvi.sh create mode 100644 man/man1/ped.1df create mode 100644 man/man1/pst.1df create mode 100644 man/man1/pvi.1df diff --git a/.gitignore b/.gitignore index ea3ec93a..bafd0f1e 100644 --- a/.gitignore +++ b/.gitignore @@ -63,10 +63,13 @@ bin/onl bin/osc bin/pa bin/paz +bin/ped bin/pit bin/plmu bin/pp bin/pph +bin/pst +bin/pvi bin/pwg bin/quo bin/rfcf diff --git a/Makefile b/Makefile index 9d987150..999b90ac 100644 --- a/Makefile +++ b/Makefile @@ -139,10 +139,13 @@ BINS = bin/ap \ bin/osc \ bin/pa \ bin/paz \ + bin/ped \ bin/pit \ bin/plmu \ bin/pp \ bin/pph \ + bin/pst \ + bin/pvi \ bin/pwg \ bin/quo \ bin/rfcf \ diff --git a/README.markdown b/README.markdown index 0d71ed12..3afc6900 100644 --- a/README.markdown +++ b/README.markdown @@ -448,6 +448,11 @@ Installed by the `install-bin` target: * Two time duration functions: * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. +* Three pipe interaction tools: + * `pst(1df)` runs an interactive program on data before passing it along + a pipeline. + * `ped(1df)` runs `pst(1df)` with `$EDITOR` or `ed(1)`. + * `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`. * `ap(1df)` reads arguments for a given command from the standard input, prompting if appropriate. * `apf(1df)` prepends arguments to a command with ones read from a file, diff --git a/bin/clog.sh b/bin/clog.sh old mode 100755 new mode 100644 diff --git a/bin/gred.sh b/bin/gred.sh old mode 100755 new mode 100644 diff --git a/bin/ped.sh b/bin/ped.sh new file mode 100644 index 00000000..ba2f7e66 --- /dev/null +++ b/bin/ped.sh @@ -0,0 +1,2 @@ +# Use pst(1df) to edit a pipe partway through, like vipe(1) +pst "${EDITOR:-ed}" diff --git a/bin/pst.sh b/bin/pst.sh new file mode 100644 index 00000000..fdea9884 --- /dev/null +++ b/bin/pst.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Interrupt a pipe with manual /dev/tty input to a program +self=pst + +# Don't accept terminal as stdin +if [ -t 0 ] ; then + printf >&2 '%s: stdin is a term\n' "$self" + exit 2 +fi + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# Run the interactive command on the temporary file forcing /dev/tty as +# input/output +tf=$td/data +cat - > "$tf" || exit +"${@:-"${PAGER:-more}"}" "$tf" /dev/tty +cat -- "$tf" || exit diff --git a/bin/pvi.sh b/bin/pvi.sh new file mode 100644 index 00000000..85fc5671 --- /dev/null +++ b/bin/pvi.sh @@ -0,0 +1,2 @@ +# Use pst(1df) to edit a pipe partway through, like vipe(1) +pst "${VISUAL:-vi}" diff --git a/man/man1/ped.1df b/man/man1/ped.1df new file mode 100644 index 00000000..fba85943 --- /dev/null +++ b/man/man1/ped.1df @@ -0,0 +1,19 @@ +.TH PED 1df "May 2017" "Manual page for ped" +.SH NAME +.B ped +\- stop a pipe for $EDITOR intervention +.SH SYNOPSIS +prog1 | +.B +ped +| prog2 +.SH DESCRIPTION +.B ped +saves all its standard input into a temporary file and runs $EDITOR, or ed(1) +if unset, on that file. Once the editor exits, it emits the contents of the +same file (changed or unchanged). This can be used as a way to edit data +manually as it goes through a pipe. +.SH SEE ALSO +pst(1df), pvi(1df) +.SH AUTHOR +Tom Ryder diff --git a/man/man1/pst.1df b/man/man1/pst.1df new file mode 100644 index 00000000..cf3ce281 --- /dev/null +++ b/man/man1/pst.1df @@ -0,0 +1,25 @@ +.TH PST 1df "May 2017" "Manual page for pst" +.SH NAME +.B pst +\- stop a pipe for manual viewing or intervention +.SH SYNOPSIS +prog1 | +.B +pst +| prog2 +.br +prog1 | +.B +pst ed +| prog2 +.SH DESCRIPTION +.B pst +saves all its standard input into a temporary file and runs the interactive +command given, defaulting to a suitable pager, and then emits the contents of +the same file (changed or unchanged) after the program exits. This can be used +as a way to watch the progress of data as it goes through the pipe, or to +manually edit it. +.SH SEE ALSO +ped(1df), pvi(1df) +.SH AUTHOR +Tom Ryder diff --git a/man/man1/pvi.1df b/man/man1/pvi.1df new file mode 100644 index 00000000..990ea589 --- /dev/null +++ b/man/man1/pvi.1df @@ -0,0 +1,19 @@ +.TH PED 1df "May 2017" "Manual page for pvi" +.SH NAME +.B pvi +\- stop a pipe for $EDITOR intervention +.SH SYNOPSIS +prog1 | +.B +pvi +| prog2 +.SH DESCRIPTION +.B pvi +saves all its standard input into a temporary file and runs $VISUAL, or vi(1) +if unset, on that file. Once the editor exits, it emits the contents of the +same file (changed or unchanged). This can be used as a way to edit data +manually as it goes through a pipe. +.SH SEE ALSO +pst(1df), ped(1df) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 630dd11a37d5ea70186b90657a9c239fcdff9261 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 12 May 2017 14:08:14 +1200 Subject: Add missing word to acq(6df) --- games/acq.sed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/acq.sed b/games/acq.sed index 650fdedb..3052cffd 100644 --- a/games/acq.sed +++ b/games/acq.sed @@ -1,2 +1,2 @@ # Interrogate the interplanetary computer. -s/.*/THERE IS INSUFFICIENT DATA FOR MEANINGFUL ANSWER./ +s/.*/THERE IS INSUFFICIENT DATA FOR A MEANINGFUL ANSWER./ -- cgit v1.2.3 From 00d01925da084bc7c5be00ed4e66e4aadacd2e26 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 12 May 2017 14:17:53 +1200 Subject: Adjust newline test in squ(6df) for correct type Moving the '+' operator to apply to "k" rather than to "len" correctly coerces an integer type for the '<' test rather than a lexical comparison. This was failing on words longer than 10 letters. --- games/squ.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/squ.awk b/games/squ.awk index 3cf3f57a..85b0bf09 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -6,5 +6,5 @@ let[i - 1] = substr(str, i, 1) for (j in let) for (k in let) - printf (k < len - 1) ? "%s " : "%s\n", let[(k + j) % len] + printf (k + 1 < len) ? "%s " : "%s\n", let[(k + j) % len] } -- cgit v1.2.3 From 145769f1d2f58645aaaf4dee453f17d627cbf68d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 02:36:38 +1200 Subject: Remove broken config from tmux Looks like 76d6d36 in tmux broke this. I'll figure out a replacement later. --- ISSUES.markdown | 1 + tmux/tmux.conf.m4 | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index a69e07df..4116adda 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -23,3 +23,4 @@ Known issues my own stuff in there * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting +* Copy-mode configuration for tmux needs to be reinstated. diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 index facb91ca..ffac0243 100644 --- a/tmux/tmux.conf.m4 +++ b/tmux/tmux.conf.m4 @@ -57,11 +57,6 @@ bind-key j select-pane -D bind-key k select-pane -U bind-key l select-pane -R -# Vim-like keys for visual mode and yanking therefrom -bind-key -t vi-copy 'v' begin-selection -bind-key -t vi-copy 'y' copy-selection -bind-key -t vi-copy Escape cancel - # Join and break panes bind-key J choose-window "join-pane -h -s '%%'" bind-key B break-pane -d -- cgit v1.2.3 From 3404b1fd0cb686bd2641eb63c851b063e0138991 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:20:02 +1200 Subject: Adopt cleaner approach for acq(6df) --- games/acq.sed | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/games/acq.sed b/games/acq.sed index 3052cffd..b6051c14 100644 --- a/games/acq.sed +++ b/games/acq.sed @@ -1,2 +1,3 @@ # Interrogate the interplanetary computer. -s/.*/THERE IS INSUFFICIENT DATA FOR A MEANINGFUL ANSWER./ +c\ +THERE IS INSUFFICIENT DATA FOR A MEANINGFUL ANSWER. -- cgit v1.2.3 From e49350f9630c76aacd10e3dee060561d3adfa4ea Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:26:41 +1200 Subject: Ignore blank lines --- games/squ.awk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/games/squ.awk b/games/squ.awk index 85b0bf09..7fdd1b96 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -1,7 +1,6 @@ # Make a reduced Latin square out of each line of input -{ +len = length { str = toupper($0) - len = length(str) for (i = 1; i <= len; i++) let[i - 1] = substr(str, i, 1) for (j in let) -- cgit v1.2.3 From 1b19e6036284b43e6ec08cd6b92500a8f785eda0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:26:50 +1200 Subject: Clear letters array before each line in squ(6df) --- games/squ.awk | 1 + 1 file changed, 1 insertion(+) diff --git a/games/squ.awk b/games/squ.awk index 7fdd1b96..b66b9b10 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -1,6 +1,7 @@ # Make a reduced Latin square out of each line of input len = length { str = toupper($0) + split("", let, ":") for (i = 1; i <= len; i++) let[i - 1] = substr(str, i, 1) for (j in let) -- cgit v1.2.3 From 05f797ab7280db393840d04d3f80fabefd0fe525 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:45:36 +1200 Subject: Array-less approach to squ(6df) --- games/squ.awk | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/games/squ.awk b/games/squ.awk index b66b9b10..abd16934 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -1,10 +1,7 @@ # Make a reduced Latin square out of each line of input -len = length { +l = length { str = toupper($0) - split("", let, ":") - for (i = 1; i <= len; i++) - let[i - 1] = substr(str, i, 1) - for (j in let) - for (k in let) - printf (k + 1 < len) ? "%s " : "%s\n", let[(k + j) % len] + for (j = 0; j < l; j++) + for (k = 0; k < l; k++) + printf (k < l - 1) ? "%s " : "%s\n", substr(str, (k + j) % l + 1, 1) } -- cgit v1.2.3 From 115f95904dddebec3b2442ddaf2fde466748d59e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:49:38 +1200 Subject: Avoid re-calcing length each loop in drakon(6df) --- games/drakon.awk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/games/drakon.awk b/games/drakon.awk index 4b8c35c5..1eddb4f2 100644 --- a/games/drakon.awk +++ b/games/drakon.awk @@ -1,9 +1,10 @@ # TyPe lIkE AnDoR DrAkOn fRoM AnCiEnT DoMaInS Of mYsTeRy # { + len = length line = "" toggle = 0 - for (i = 1; i <= length; i++) { + for (i = 1; i <= len; i++) { char = substr($0, i, 1) if (char ~ /[a-zA-Z]/) char = (toggle = !toggle) ? tolower(char) : toupper(char) -- cgit v1.2.3 From 7d17ac1fa99a129b7e9205ea5ab4a782eae47bce Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 21:55:46 +1200 Subject: Include all alpha chars in drakon(6df) toggle --- games/drakon.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/drakon.awk b/games/drakon.awk index 1eddb4f2..b8d72888 100644 --- a/games/drakon.awk +++ b/games/drakon.awk @@ -6,7 +6,7 @@ toggle = 0 for (i = 1; i <= len; i++) { char = substr($0, i, 1) - if (char ~ /[a-zA-Z]/) + if (char ~ /[[:alpha:]]/) char = (toggle = !toggle) ? tolower(char) : toupper(char) line = line char } -- cgit v1.2.3 From 57daf35a76506de41dfaf94af78376717943957b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 22:58:25 +1200 Subject: Move exm(1df) test into EDITOR selection Merely checking for vim(1) is a poor test; we specifically need to know if the ex(1) implementation is Vim, so test it while making the EDITOR decision. --- bin/exm.sh | 13 +++++-------- sh/profile.d/editor.sh | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bin/exm.sh b/bin/exm.sh index 25e3006f..378b5baf 100644 --- a/bin/exm.sh +++ b/bin/exm.sh @@ -1,12 +1,9 @@ # Prevent Vim's ex(1) implementation from clearing the screen if [ -t 0 ] ; then - ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}') - case $ver in - # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" - # feature is invoked with a carriage return. - VIM) - cmd=$(printf 'set t_cm=\r|') - set -- -T dumb --cmd "${cmd%|}" "$@" ;; - esac + + # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" + # feature is invoked with a carriage return. + cmd=$(printf 'set t_cm=\r|') + set -- -T dumb --cmd "${cmd%|}" "$@" fi exec ex "$@" diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh index 307879fe..debb93b6 100644 --- a/sh/profile.d/editor.sh +++ b/sh/profile.d/editor.sh @@ -3,12 +3,21 @@ if command -v ed >/dev/null 2>&1 ; then EDITOR=ed -# Failing that, if we have both vim(1) and exm(1df) in our $PATH, use the -# latter to work around Vim's ex mode screen-clearing -elif { command -v vim && command -v exm ; } >/dev/null 2>&1 ; then +# Failing that, if the system's implementation of ex(1) looks like Vim and we +# have exm(1df) in our $PATH, use the latter to work around Vim's ex mode +# screen-clearing +elif ( + command -v ex >/dev/null 2>&1 || exit 1 + command -v exm >/dev/null 2>&1 || exit 1 + ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}') + case $ver in + (VIM) exit 0 ;; + (*) exit 1 ;; + esac +) >/dev/null 2>&1 ; then EDITOR=exm -# Otherwise, just call ex(1) directly +# Otherwise, we can just call ex(1) directly else EDITOR=ex fi -- cgit v1.2.3 From 3e0a391732350157ab06bb14ac685160416573fa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 14 May 2017 22:59:13 +1200 Subject: Just use whichever vi(1) we need as VISUAL This avoids an unwanted situation on e.g. Debian minimal where the default Vi implementation is a stripped-down Vim that doesn't use vim(1) as a name, so stuff like sudoedit(8) breaks looking for it and falls back on EDITOR. --- sh/profile.d/visual.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh index d03da255..38ab9893 100644 --- a/sh/profile.d/visual.sh +++ b/sh/profile.d/visual.sh @@ -1,7 +1,3 @@ -# Set visual editor; vim if we've got it, but vi will do fine -if command -v vim >/dev/null 2>&1 ; then - VISUAL=vim -else - VISUAL=vi -fi +# Use first found implementation of vi(1) +VISUAL=vi export VISUAL -- cgit v1.2.3 From e2468cb0f96864259bfd4518a72b2291054e325e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 22 May 2017 11:02:12 +1200 Subject: Avoid awk(1) fork in pph(1df) --- bin/pph.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/pph.sh b/bin/pph.sh index 268b6ad7..ce516c16 100644 --- a/bin/pph.sh +++ b/bin/pph.sh @@ -1,4 +1,5 @@ # Run pp(1df) on args, prefix with machine hostname hn=$(hostname -s) || exit -pp "$@" | -awk -v hn="$hn" '{ print hn ":" $0 }' +pp "$@" | while IFS= read -r path ; do + printf '%s:%s\n' "$hn" "$path" +done -- cgit v1.2.3 From 45b5ac8b510400bcccbf893dee2229757533d7a7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 23 May 2017 13:21:15 +1200 Subject: Fix up completions for td(1df) Hung on null completion --- bash/bash_completion.d/td.bash | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bash/bash_completion.d/td.bash b/bash/bash_completion.d/td.bash index eb29992b..db232dd6 100644 --- a/bash/bash_completion.d/td.bash +++ b/bash/bash_completion.d/td.bash @@ -4,16 +4,23 @@ _td() { dir=${TODO_DIR:-"$HOME"/Todo} local fn while IFS= read -rd '' fn ; do + [[ -n $fn ]] || continue COMPREPLY[${#COMPREPLY[@]}]=$fn done < <( shopt -s extglob nullglob shopt -u dotglob - local -a fns + declare -a fns fns=("$dir"/"${COMP_WORDS[COMP_CWORD]}"*) fns=("${fns[@]#"$dir"/}") - ((${#fns[@]})) || exit 1 - printf '%s\0' "${fns[@]##"$dir"/}" + + # Print quoted entries, null-delimited, if there was at least one; + # otherwise, just print a null character to stop this hanging in Bash + # 4.4 + if ((${#fns[@]})) ; then + printf '%q\0' "${fns[@]}" + else + printf '\0' + fi ) - return } complete -F _td td -- cgit v1.2.3 From 6c4d2555443bd0dd62125fcb311a88b1db871548 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 23 May 2017 14:01:57 +1200 Subject: Restore functional copy-mode vi keys --- tmux/tmux.conf.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 index ffac0243..3a1d2425 100644 --- a/tmux/tmux.conf.m4 +++ b/tmux/tmux.conf.m4 @@ -41,6 +41,8 @@ bind-key Tab last-pane # Use the vi mode for tmux interaction behaviour in copy and choice modes set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send -X begin-selection +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel # Detach with Alt-M, no prefix required bind-key -n M-m detach -- cgit v1.2.3 From e37fe24c2505aba368fad31dea5c1c8e6df780cc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 23 May 2017 21:42:12 +1200 Subject: Correct mftl.awk invocation --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 3afc6900..0f4c85be 100644 --- a/README.markdown +++ b/README.markdown @@ -54,7 +54,7 @@ to figure out which shell’s configuration files to install, falling back on `install-sh`. The remaining dotfiles can be installed with the other `install-*` targets. Try -`sh bin/mftl.sh Makefile` in the project's root directory to see a list. +`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list. Tools ----- -- cgit v1.2.3 From 21654c68addf7b11d8e5918085c24001a170e8aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 23 May 2017 21:50:45 +1200 Subject: Explicitly mention ksh93 --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 0f4c85be..418e92fe 100644 --- a/README.markdown +++ b/README.markdown @@ -64,7 +64,7 @@ Configuration is included for: * Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and some helper functions: * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) - * [Korn shell](http://www.kornshell.com/) (including `pdksh`, `mksh`) + * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) * [Yash](https://yash.osdn.jp/index.html.en) * [Z shell](https://www.zsh.org/) * [Abook](http://abook.sourceforge.net/) -- curses address book program -- cgit v1.2.3 From 8547a2e1ea9135381e1538401ef4da60fb379d99 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 23 May 2017 21:53:10 +1200 Subject: Remove mysql() function Clumsy interaction too close to default behaviour anyway --- README.markdown | 3 --- sh/shrc.d/mysql.sh | 25 ------------------------- 2 files changed, 28 deletions(-) delete mode 100644 sh/shrc.d/mysql.sh diff --git a/README.markdown b/README.markdown index 418e92fe..8bfd8c51 100644 --- a/README.markdown +++ b/README.markdown @@ -220,8 +220,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: available. * `la()` runs `ls -A` if it can, or `ls -a` otherwise. * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. -* `mysql()` allows shortcuts to MySQL configuration files stored in - `~/.mysql`. * `path()` manages the contents of `PATH` conveniently. * `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. * `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never @@ -260,7 +258,6 @@ files, for things I really do get tired of typing repeatedly: * `gpg(1)` long options * `make(1)` targets read from a `Makefile` * `man(1)` page titles -* `mysql(1)` databases from `~/.mysql/*.cnf` * `pass(1)` entries * `ssh(1)` hostnames from `~/.ssh/config` diff --git a/sh/shrc.d/mysql.sh b/sh/shrc.d/mysql.sh deleted file mode 100644 index abb496d2..00000000 --- a/sh/shrc.d/mysql.sh +++ /dev/null @@ -1,25 +0,0 @@ -# If a file ~/.mysql/$1.cnf exists, call mysql(1) using that file, discarding -# the rest of the arguments. Otherwise just run MySQL with given args. Use -# restrictive permissions on these files. Doesn't allow filenames beginning -# with hyphens. -# -# Examples: -# -# [client] -# host=dbhost.example.com -# user=foo -# password=SsJ2pICe226jM -# -# [mysql] -# database=bar -# -mysql() { - case $1 in - -*) ;; - *) - [ -f "$HOME/.mysql/$1".cnf ] && - set -- --defaults-extra-file="$HOME/.mysql/$1".cnf - ;; - esac - command mysql "$@" -} -- cgit v1.2.3 From 38c80d1027afc4f06ec06a53047be5985f156bab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- vim/bundle/unimpaired | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 0f471006..379b8f70 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 0f4710063ecc98d77dc03698c4a917a3215bdf09 +Subproject commit 379b8f70822c4a89370575c3967f33cb116087ea diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired index 0f72c70b..7bbbca73 160000 --- a/vim/bundle/unimpaired +++ b/vim/bundle/unimpaired @@ -1 +1 @@ -Subproject commit 0f72c70b672aeadaaab94e430267b1435c1b2441 +Subproject commit 7bbbca73233b1492a8c3d16f91f34340eccc9b30 -- cgit v1.2.3 From 5a659f01a45e4c2cd1dafbc910c823415798dcea Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 13:32:52 +1200 Subject: Remove Yash support I never use it --- Makefile | 20 ++------------------ README.markdown | 7 +------ check/login-shell.sh | 2 -- check/yash.sh | 5 ----- install/install-login-shell.sh | 2 -- ksh/shrc.d/ksh.sh | 2 +- lint/yash.sh | 1 - yash/yash_profile | 2 -- yash/yashrc | 14 -------------- yash/yashrc.d/ver.yash | 4 ---- 10 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 check/yash.sh delete mode 100644 lint/yash.sh delete mode 100644 yash/yash_profile delete mode 100644 yash/yashrc delete mode 100644 yash/yashrc.d/ver.yash diff --git a/Makefile b/Makefile index 999b90ac..e5cb262b 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ install-vim-pathogen \ install-vim-plugins \ install-x \ - install-yash \ install-zsh \ check \ check-bash \ @@ -54,7 +53,6 @@ check-sh \ check-urxvt \ check-xinit \ - check-yash \ check-zsh \ lint \ lint-bash \ @@ -63,8 +61,7 @@ lint-ksh \ lint-sh \ lint-urxvt \ - lint-xinit \ - lint-yash + lint-xinit .SUFFIXES: .SUFFIXES: .awk .bash .pl .sed .sh @@ -446,12 +443,6 @@ install-x: check-xinit cp -p -- X/Xresources $(HOME)/.Xresources cp -p -- X/Xresources.d/* $(HOME)/.Xresources.d -install-yash: install-yash install-sh - mkdir -p -- $(HOME)/.yashrc.d - cp -p -- yash/yash_profile $(HOME)/.yash_profile - cp -p -- yash/yashrc $(HOME)/.yashrc - cp -p -- yash/yashrc.d/* $(HOME)/.yashrc.d - install-zsh: check-zsh install-sh mkdir -p -- $(HOME)/.profile.d $(HOME)/.zshrc.d cp -p -- zsh/profile.d/* $(HOME)/.profile.d @@ -491,9 +482,6 @@ check-urxvt: check-xinit: sh check/xinit.sh -check-yash: - sh check/yash.sh - check-zsh: sh check/zsh.sh @@ -503,8 +491,7 @@ lint: lint-bash \ lint-ksh \ lint-sh \ lint-urxvt \ - lint-xinit \ - lint-yash + lint-xinit lint-bash: check-bash sh lint/bash.sh @@ -526,6 +513,3 @@ lint-urxvt: check-urxvt lint-xinit: check-xinit sh lint/xinit.sh - -lint-yash: check-yash - sh lint/yash.sh diff --git a/README.markdown b/README.markdown index 8bfd8c51..06e585ef 100644 --- a/README.markdown +++ b/README.markdown @@ -65,7 +65,6 @@ Configuration is included for: some helper functions: * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) - * [Yash](https://yash.osdn.jp/index.html.en) * [Z shell](https://www.zsh.org/) * [Abook](http://abook.sourceforge.net/) -- curses address book program * [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data @@ -239,7 +238,7 @@ non-POSIX features, as compatibility allows: * `vared()` allows interactively editing a variable with Readline, emulating a Zsh function I like by the same name (Bash). * `ver()` prints the current shell's version information (Bash, Korn Shell, - Yash, Z shell). + Z shell). #### Completion @@ -276,10 +275,6 @@ These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T `ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow prompt if detected. -#### Yash - -Just enough configuration to coax it into reading `~/.profile` and `~/.shrc`. - #### Zsh These are experimental; I do not like Zsh much at the moment. The files started diff --git a/check/login-shell.sh b/check/login-shell.sh index 20327b94..2972d98d 100644 --- a/check/login-shell.sh +++ b/check/login-shell.sh @@ -4,8 +4,6 @@ case ${SHELL##*/} in target=check-bash ;; ksh|ksh88|ksh93|mksh|pdksh) target=check-ksh ;; - yash) - target=check-yash ;; zsh) target=check-zsh ;; esac diff --git a/check/yash.sh b/check/yash.sh deleted file mode 100644 index c8722f3d..00000000 --- a/check/yash.sh +++ /dev/null @@ -1,5 +0,0 @@ -for yash in yash/* ; do - [ -f "$yash" ] || continue - yash -n "$yash" || exit -done -printf 'All yash scripts parsed successfully.\n' diff --git a/install/install-login-shell.sh b/install/install-login-shell.sh index b7292a77..f38aa0c1 100644 --- a/install/install-login-shell.sh +++ b/install/install-login-shell.sh @@ -4,8 +4,6 @@ case ${SHELL##*/} in target=install-bash ;; ksh|ksh88|ksh93|mksh|pdksh) target=install-ksh ;; - yash) - target=install-yash ;; zsh) target=install-zsh ;; esac diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh index aa5c4cbc..b591f37c 100644 --- a/ksh/shrc.d/ksh.sh +++ b/ksh/shrc.d/ksh.sh @@ -9,7 +9,7 @@ # makes other shells throw tantrums. # Does the name of our shell have "ksh" in it at all? This is in no way -# guaranteed. It's just a heuristic that e.g. Bash and Yash shouldn't pass. +# guaranteed. It's just a heuristic that e.g. Bash shouldn't pass. case $0 in *ksh*) ;; *) return ;; diff --git a/lint/yash.sh b/lint/yash.sh deleted file mode 100644 index d783e077..00000000 --- a/lint/yash.sh +++ /dev/null @@ -1 +0,0 @@ -find yash -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/yash/yash_profile b/yash/yash_profile deleted file mode 100644 index d37f35a1..00000000 --- a/yash/yash_profile +++ /dev/null @@ -1,2 +0,0 @@ -# Load ~/.profile, because Yash won't by itself, no matter how you invoke it -[ -e "$HOME"/.profile ] && . "$HOME"/.profile diff --git a/yash/yashrc b/yash/yashrc deleted file mode 100644 index c2b2df26..00000000 --- a/yash/yashrc +++ /dev/null @@ -1,14 +0,0 @@ -# Clear away all aliases; we do this here rather than in $ENV because the ksh -# family of shells relies on aliases to implement certain POSIX utilities like -# fc(1) and type(1) -unalias -a - -# Load POSIX interactive shell startup files, because Yash won't do it if not -# invoked as sh(1) -[ -e "$ENV" ] && . "$ENV" - -# Load Bash-specific startup files -for sh in "$HOME"/.yashrc.d/*.yash ; do - [ -e "$sh" ] && . "$sh" -done -unset -v sh diff --git a/yash/yashrc.d/ver.yash b/yash/yashrc.d/ver.yash deleted file mode 100644 index 8bd06e4d..00000000 --- a/yash/yashrc.d/ver.yash +++ /dev/null @@ -1,4 +0,0 @@ -# Shortcut to show current shell version -ver() { - printf '%s\n' "${YASH_VERSION:-unknown}" -} -- cgit v1.2.3 From 7813bda9325299603d29fd2d1affafc29fc9e667 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 15:57:22 +1200 Subject: Correct title of pvi(1df) man page --- man/man1/pvi.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/pvi.1df b/man/man1/pvi.1df index 990ea589..6a21e6e8 100644 --- a/man/man1/pvi.1df +++ b/man/man1/pvi.1df @@ -1,4 +1,4 @@ -.TH PED 1df "May 2017" "Manual page for pvi" +.TH PVI 1df "May 2017" "Manual page for pvi" .SH NAME .B pvi \- stop a pipe for $EDITOR intervention -- cgit v1.2.3 From 1c7cf90afae80918b82d823af59484f84391814f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 15:57:34 +1200 Subject: Add dam(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + bin/dam.sh | 25 +++++++++++++++++++++++++ man/man1/dam.1df | 15 +++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 bin/dam.sh create mode 100644 man/man1/dam.1df diff --git a/.gitignore b/.gitignore index bafd0f1e..59f79713 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ bin/clog bin/clrd bin/clwr bin/csmw +bin/dam bin/d2u bin/ddup bin/dmp diff --git a/Makefile b/Makefile index e5cb262b..da41016b 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,7 @@ BINS = bin/ap \ bin/clrd \ bin/clwr \ bin/csmw \ + bin/dam \ bin/d2u \ bin/ddup \ bin/dmp \ diff --git a/README.markdown b/README.markdown index 06e585ef..1738af22 100644 --- a/README.markdown +++ b/README.markdown @@ -469,6 +469,7 @@ Installed by the `install-bin` target: line. * `csmw(1df)` prints an English list of monospace-quoted words read from the input. +* `dam(1df)` buffers all its input before emitting it as output. * `ddup(1df)` removes duplicate lines from unsorted input. * `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X CLIPBOARD. diff --git a/bin/dam.sh b/bin/dam.sh new file mode 100644 index 00000000..03424515 --- /dev/null +++ b/bin/dam.sh @@ -0,0 +1,25 @@ +# Store up all input before emitting it unchanged as output +self=dam + +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit + +# We'll operate on stdin in the temp directory; write the script's stdin to it +# with cat(1) +cat -- "${@:-}" >"$td"/stdin + +# Only when that write is finished do we finally spit it all back out again +cat -- "$td"/stdin diff --git a/man/man1/dam.1df b/man/man1/dam.1df new file mode 100644 index 00000000..b9821960 --- /dev/null +++ b/man/man1/dam.1df @@ -0,0 +1,15 @@ +.TH DAM 1df "May 2017" "Manual page for dam" +.SH NAME +.B dam +\- read all input before emitting as output +.SH SYNOPSIS +prog1 | +.B +dam +| prog2 +.SH DESCRIPTION +.B dam +stores all its input in a temporary file before emitting it as output, behaving +like a fully-buffered cat(1), and with some of the functionality of sponge(1). +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 49fc3b26cc4ddb419f0c6945a9faf4e307af0013 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 16:02:57 +1200 Subject: Add missing dash --- bin/dam.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dam.sh b/bin/dam.sh index 03424515..a80cae4a 100644 --- a/bin/dam.sh +++ b/bin/dam.sh @@ -19,7 +19,7 @@ td=$(mktd "$self") || exit # We'll operate on stdin in the temp directory; write the script's stdin to it # with cat(1) -cat -- "${@:-}" >"$td"/stdin +cat -- "${@:--}" >"$td"/stdin # Only when that write is finished do we finally spit it all back out again cat -- "$td"/stdin -- cgit v1.2.3 From 6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 16:12:35 +1200 Subject: Change dam(1df) to a sed script --- bin/dam.sed | 8 ++++++++ bin/dam.sh | 25 ------------------------- man/man1/dam.1df | 5 +++-- 3 files changed, 11 insertions(+), 27 deletions(-) create mode 100644 bin/dam.sed delete mode 100644 bin/dam.sh diff --git a/bin/dam.sed b/bin/dam.sed new file mode 100644 index 00000000..86fb03f9 --- /dev/null +++ b/bin/dam.sed @@ -0,0 +1,8 @@ +# Store up all input before emitting it unchanged as output +1h +1!H +$ { + g + p +} +d diff --git a/bin/dam.sh b/bin/dam.sh deleted file mode 100644 index a80cae4a..00000000 --- a/bin/dam.sh +++ /dev/null @@ -1,25 +0,0 @@ -# Store up all input before emitting it unchanged as output -self=dam - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# We'll operate on stdin in the temp directory; write the script's stdin to it -# with cat(1) -cat -- "${@:--}" >"$td"/stdin - -# Only when that write is finished do we finally spit it all back out again -cat -- "$td"/stdin diff --git a/man/man1/dam.1df b/man/man1/dam.1df index b9821960..78f5210c 100644 --- a/man/man1/dam.1df +++ b/man/man1/dam.1df @@ -9,7 +9,8 @@ dam | prog2 .SH DESCRIPTION .B dam -stores all its input in a temporary file before emitting it as output, behaving -like a fully-buffered cat(1), and with some of the functionality of sponge(1). +buffers all its input before emitting it as output. Useful if you don't +actually want a line-by-line flow between programs, such as pasting a complete +document into a sed(1) pipeline on the terminal. .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 3220403ff11e8d39ff5b0e8831de1d15969f51c2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 16:55:13 +1200 Subject: Exit 2 with usage errors from gwp(1df) --- bin/gwp.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/gwp.awk b/bin/gwp.awk index 976b5b84..f1e3b3bd 100644 --- a/bin/gwp.awk +++ b/bin/gwp.awk @@ -24,7 +24,7 @@ BEGIN { # Bailout function function fail(str) { printf "%s: %s\n", self, str | "cat >&2" - exit(1) + exit(2) } # If there's more than one filename, precede the print of the current line with -- cgit v1.2.3 From cadc05f5acb0b495b93b15981a404077e0d2dee3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 16:56:00 +1200 Subject: Add trs(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + bin/trs.awk | 36 ++++++++++++++++++++++++++++++++++++ man/man1/trs.1df | 23 +++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 bin/trs.awk create mode 100644 man/man1/trs.1df diff --git a/.gitignore b/.gitignore index 59f79713..e2f5a857 100644 --- a/.gitignore +++ b/.gitignore @@ -104,6 +104,7 @@ bin/tl bin/tlcs bin/tm bin/tot +bin/trs bin/try bin/u2d bin/umake diff --git a/Makefile b/Makefile index da41016b..1f620612 100644 --- a/Makefile +++ b/Makefile @@ -177,6 +177,7 @@ BINS = bin/ap \ bin/tlcs \ bin/tm \ bin/tot \ + bin/trs \ bin/try \ bin/u2d \ bin/umake \ diff --git a/README.markdown b/README.markdown index 1738af22..4cd8ebd0 100644 --- a/README.markdown +++ b/README.markdown @@ -532,6 +532,7 @@ Installed by the `install-bin` target: to use Taskwarrior, but found it too complex and buggy. * `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and `new-session` if it doesn't. +* `trs(1df)` replaces strings (not regular expression) in its input. * `try(1df)` repeats a command up to a given number of times until it succeeds, only printing error output if all three attempts failed. Good for tolerating blips or temporary failures in `cron(8)` scripts. diff --git a/bin/trs.awk b/bin/trs.awk new file mode 100644 index 00000000..5966c520 --- /dev/null +++ b/bin/trs.awk @@ -0,0 +1,36 @@ +# Substitute one string for another in input (no regex) +BEGIN { + # Name self + self = "trs" + + # No wordsplitting required + FS = "" + + # Two and only two arguments required + if (ARGC != 3) + fail("Need a string and a replacement") + + # Get arguments and blank them so awk doesn't try to read them as files + str = ARGV[1] + rep = ARGV[2] + ARGV[1] = ARGV[2] = "" + + # String length is relevant here + if (!(len = length(str))) + fail("String to replace cannot be null") +} + +# Bailout function +function fail(str) { + printf "%s: %s\n", self, str | "cat >&2" + exit(2) +} + +# Run on each line +{ + lin = "" + for (buf = $0; ind = index(buf, str); buf = substr(buf, ind + len)) + lin = lin substr(buf, 1, ind - 1) rep + lin = lin buf + print lin +} diff --git a/man/man1/trs.1df b/man/man1/trs.1df new file mode 100644 index 00000000..fa5d2d19 --- /dev/null +++ b/man/man1/trs.1df @@ -0,0 +1,23 @@ +.TH TRS 1df "May 2017" "Manual page for trs" +.SH NAME +.B trs +\- string version of tr(1) +.SH SYNOPSIS +.B trs +STRING REPLACEMENT +< file +.br +program | +.B trs +STRING REPLACEMENT +.SH DESCRIPTION +.B trs +replaces the string given in its first argument with the string given in its +second, with no regex metacharacters, in a way that should work on all POSIX +implementations. It is thereby the string complement for tr(1). +.P +The first argument cannot be a null string. The second argument can be blank +(but must still be specified) to implicitly delete all occurrences of the +string. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 4b780b8415db74508729991e5a2014bc7a54ff17 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 May 2017 22:06:49 +1200 Subject: Correct gt() error output --- sh/shrc.d/gt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/gt.sh b/sh/shrc.d/gt.sh index d18a4ab8..c90af073 100644 --- a/sh/shrc.d/gt.sh +++ b/sh/shrc.d/gt.sh @@ -4,7 +4,7 @@ gt() { # Check argument count if [ "$#" -gt 1 ] ; then - printf >&2 'gd(): Too many arguments\n' + printf >&2 'gt(): Too many arguments\n' return 2 fi -- cgit v1.2.3 From 3f9a35e5babdc63d32408851296d235fa632834b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 May 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 379b8f70..3ec671e1 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 379b8f70822c4a89370575c3967f33cb116087ea +Subproject commit 3ec671e112c760e68eee1e3cc5eeb9408448dab4 -- cgit v1.2.3 From b4b144c3f8aa98a26b9a59c204ec0d5b4619ef72 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 May 2017 18:21:23 +1200 Subject: Shorter/saner implementation for bd() Avoids subshell mess and consequent trailing-space workaround --- sh/shrc.d/bd.sh | 85 ++++++++++++++++++++------------------------------------- 1 file changed, 29 insertions(+), 56 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index bf64a9aa..02da6773 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -3,68 +3,41 @@ bd() { # Check argument count if [ "$#" -gt 1 ] ; then - printf >&2 'bd(): Too many arguments' + printf >&2 'bd(): Too many arguments\n' return 2 fi - # Set positional parameters to an option terminator and what will hopefully - # end up being a target directory - set -- "$( + # Look at argument given + case $1 in - # The requested pattern is the first argument, defaulting to just the - # parent directory - req=${1:-..} + # If it has a leading slash or is . or .., don't touch the arguments + /*|.|..) ;; - # Strip trailing slashes if a trailing slash is not the whole pattern - [ "$req" = / ] || req=${req%/} + # Otherwise, we'll try to find a matching ancestor and then shift the + # initial request off the argument list + *) - # What to do now depends on the request - case $req in + # Push the current directory onto the stack + set -- "$1" "$PWD" - # Just go straight to the root or dot directories if asked - (/|.|..) - dirname=$req - ;; - - # Anything with a leading / needs to anchor to the start of the - # path. A strange request though. Why not just use cd? - (/*) - dirname=$req - case $PWD in - ("$dirname"/*) ;; - (*) dirname='' ;; + # Keep chopping at the current directory until it's empty or it + # matches the request + while [ -n "$2" ] ; do + set -- "$1" "${2%/*}" + case $2 in + (*/"$1") break ;; esac - ;; - - # In all other cases, iterate through the PWD to find a match, or - # whittle the target down to an empty string trying - (*) - dirname=$PWD - while [ -n "$dirname" ] ; do - dirname=${dirname%/*} - case $dirname in - (*/"$req") break ;; - esac - done - ;; - esac - - # Check we have a target after all that - if [ -z "$dirname" ] ; then - printf >&2 'bd(): Directory name not in path\n' - exit 1 - fi - - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${dirname%/}" - )" - - # Remove trailing slash - set -- "${1%/}" - - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return - - # Try to change into the determined directory - command cd -- "$@" + done + + # If the first argument ended up empty, we have no match + if [ -z "$2" ] ; then + printf >&2 'bd(): No match\n' + return 1 + fi + shift + ;; + esac + + # We have a match; try and change into it + command cd -- "$1" } -- cgit v1.2.3 From e199448d724746af892a67608c88fb2ddc075c72 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 May 2017 18:31:36 +1200 Subject: Even terser/nicer bd() --- sh/shrc.d/bd.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 02da6773..5b2c3d59 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -22,18 +22,18 @@ bd() { # Keep chopping at the current directory until it's empty or it # matches the request - while [ -n "$2" ] ; do - set -- "$1" "${2%/*}" + while set -- "$1" "${2%/*}" ; do case $2 in - (*/"$1") break ;; + */"$1") break ;; + */*) ;; + *) + printf >&2 'bd(): No match\n' + return 1 + ;; esac done # If the first argument ended up empty, we have no match - if [ -z "$2" ] ; then - printf >&2 'bd(): No match\n' - return 1 - fi shift ;; esac -- cgit v1.2.3 From 9ed69d70d9201817c7f36c7f210ce163e84eb54b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 00:39:02 +1200 Subject: Reimplement sd() without subshell --- sh/shrc.d/bd.sh | 6 ++--- sh/shrc.d/sd.sh | 80 +++++++++++++++++++++++++++++---------------------------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 5b2c3d59..2dc21173 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -7,8 +7,8 @@ bd() { return 2 fi - # Look at argument given - case $1 in + # Look at argument given; default to going up one level + case ${1:-..} in # If it has a leading slash or is . or .., don't touch the arguments /*|.|..) ;; @@ -18,7 +18,7 @@ bd() { *) # Push the current directory onto the stack - set -- "$1" "$PWD" + set -- "${1%/}" "$PWD" # Keep chopping at the current directory until it's empty or it # matches the request diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index 4d63b7d6..561a77f4 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -40,48 +40,50 @@ sd() { return 2 fi - # Change positional parameters to what will hopefully be a completed - # substitution - set -- "$( + # Read sole optional argument + case $1 in - # Set the positional parameters to either the requested directory, or - # all siblings of the current directory if no request - spec=$1 - set -- - if [ -n "$spec" ] ; then - set -- "$@" ../"$spec" - else - for sib in ../.* ../* ; do - case ${sib#../} in - (.|..|"${PWD##*/}") continue ;; - esac - set -- "$@" "$sib" - done - fi + # If blank, get a full list of directories at this level; include + # dotfiles, but not the . and .. entries, using glob tricks to avoid + # Bash ruining things with `dotglob` + '') + set -- ../[!.]*/ + [ -e "$1" ] || shift + set -- ../.[!.]*/ "$@" + [ -e "$1" ] || shift + set -- ../..?*/ "$@" + [ -e "$1" ] || shift + ;; - # We should have exactly one sibling - case $# in - (1) ;; - (0) - printf >&2 'sd(): No siblings\n' - exit 1 - ;; - (*) - printf >&2 'sd(): More than one sibling\n' - exit 1 - ;; - esac + # If not, get that directory, and the current one; shift it off if it + # doesn't exist + *) + set -- ../"${1%/}"/ ../"${PWD##*/}"/ + [ -e "$1" ] || shift + ;; + esac - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${1%/}" - )" + # We should now have two parameters: the current directory and the matched + # sibling + case $# in + 2) ;; + 0|1) + printf >&2 'sd(): No match\n' + return 1 + ;; + *) + printf >&2 'sd(): Multiple matches\n' + return 1 + ;; + esac - # Remove trailing slash - set -- "${1%/}" + # Find which of these two is not the current directory and set that as our + # sole parameter + case $1 in + ../"${PWD##*/}"/) set -- "$2" ;; + *) set -- "$1" ;; + esac - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return - - # Try to change into the determined directory - command cd -- "$@" + # Try and change into the first parameter + command cd -- "$1" } -- cgit v1.2.3 From cd114eec94fd07e831ef6c70b7732408d0a59e90 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 17:48:49 +1200 Subject: Correct default behaviour for bd() with no args --- sh/shrc.d/bd.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 2dc21173..7901e115 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -1,14 +1,17 @@ # Move back up the directory tree to the first directory matching the name bd() { - # Check argument count - if [ "$#" -gt 1 ] ; then - printf >&2 'bd(): Too many arguments\n' - return 2 - fi + # Check argument count; default to ".." + case $# in + 0) set -- .. ;; + 1) ;; + *) + printf >&2 'bd(): Too many arguments\n' + return 2 + esac # Look at argument given; default to going up one level - case ${1:-..} in + case $1 in # If it has a leading slash or is . or .., don't touch the arguments /*|.|..) ;; -- cgit v1.2.3 From 520f9e174aa0569a95469a7d2b746582bdf0c18c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:23:54 +1200 Subject: More bd() improvements Including rigorous trailing-slash handling --- sh/shrc.d/bd.sh | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 7901e115..9b877faf 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -1,31 +1,48 @@ # Move back up the directory tree to the first directory matching the name bd() { - # Check argument count; default to ".." - case $# in - 0) set -- .. ;; - 1) ;; - *) - printf >&2 'bd(): Too many arguments\n' - return 2 - esac + # Check arguments; default to ".." + if [ "$#" -gt 1 ] ; then + printf >&2 'bd(): Too many arguments\n' + return 2 + fi + set -- "${1:-..}" # Look at argument given; default to going up one level case $1 in - # If it has a leading slash or is . or .., don't touch the arguments - /*|.|..) ;; + # If it's slash, dot, or dot-dot, we'll just go there, like `cd` would + /|.|..) ;; + + # Anything else with a slash anywhere is an error + */*) + printf >&2 'bd(): Illegal slash\n' + return 2 + ;; # Otherwise, we'll try to find a matching ancestor and then shift the # initial request off the argument list *) # Push the current directory onto the stack - set -- "${1%/}" "$PWD" + set -- "$1" "$PWD" # Keep chopping at the current directory until it's empty or it # matches the request - while set -- "$1" "${2%/*}" ; do + while : ; do + + # Make certain there are no trailing slashes to foul us up + while : ; do + case $2 in + */) set -- "$1" "${2%/}" ;; + *) break ;; + esac + done + + # Strip a path element + set -- "$1" "${2%/*}" + + # Check whether we're arrived case $2 in */"$1") break ;; */*) ;; -- cgit v1.2.3 From 2d0fefe4cde7831c7e49641df217ee0354751a63 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:24:13 +1200 Subject: Reimplement ud() More fault-tolerant and no subshell or temporary vars --- sh/shrc.d/ud.sh | 62 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/sh/shrc.d/ud.sh b/sh/shrc.d/ud.sh index 79f4b5e7..a3997702 100644 --- a/sh/shrc.d/ud.sh +++ b/sh/shrc.d/ud.sh @@ -2,48 +2,46 @@ # like cd .., cd ../.., etc ud() { - # Check argument count - if [ "$#" -gt 1 ] ; then + # Check arguments; default to 1 and $PWD + if [ "$#" -gt 2 ] ; then printf >&2 'ud(): Too many arguments\n' return 2 fi + set -- "${1:-1}" "${2:-"$PWD"}" + set -- "$1" "$2" - # Check first argument, number of steps upward, default to 1. - # "0" is weird, but valid; "-1" however makes no sense at all - if [ "${1:-1}" -lt 0 ] ; then + # Check first argument, number of steps upward. "0" is weird, but valid; + # "-1" however makes no sense at all + if [ "$1" -lt 0 ] ; then printf >&2 'ud(): Invalid step count\n' return 2 fi - # Change the positional parameters from the number of steps given to a - # "../../.." string - set -- "$( - - # Append /.. to the target (default PWD) the specified number of times - dirname=${2:-"$PWD"} - i=0 - steps=${1:-1} - while [ "$i" -lt "$steps" ] ; do - dirname=${dirname%/}/.. - i=$((i+1)) + # Check second argument, starting path, for relativity and anchor it if + # need be + case $2 in + /*) ;; + *) set -- "$1" "$PWD"/"$2" ;; + esac + + # Chop an element off the target the specified number of times + while [ "$1" -gt 0 ] ; do + + # Make certain there are no trailing slashes to foul us up + while : ; do + case $2 in + */) set -- "$1" "${2%/}" ;; + *) break ;; + esac done - # Check we have a target after all that - if [ -z "$dirname" ] ; then - printf >&2 'ud(): Destination construction failed\n' - exit 1 - fi + # Strip a path element + set -- "$(($1-1))" "${2%/*}" + done - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${dirname%/}" - )" + # Shift off the count, which should now be zero + shift - # Remove trailing slash - set -- "${1%/}" - - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return - - # Try to change into the determined directory - command cd -- "$@" + # Try to change into the determined directory, or the root if blank + command cd -- "${1:-/}" } -- cgit v1.2.3 From 62f7ea87871b861a079a64ef0e278370865498e4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:34:16 +1200 Subject: Still tinkering with ?d.sh scripts --- sh/shrc.d/pd.sh | 49 ++++++++++++++++++++----------------------------- sh/shrc.d/rd.sh | 2 -- sh/shrc.d/sd.sh | 2 -- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/sh/shrc.d/pd.sh b/sh/shrc.d/pd.sh index ce43837b..e3a6daaa 100644 --- a/sh/shrc.d/pd.sh +++ b/sh/shrc.d/pd.sh @@ -2,39 +2,30 @@ # use when you've got a file path in a variable, or in history, or in Alt+., # and want to quickly move to its containing directory. In the absence of an # argument, this just shifts up a directory, i.e. `cd ..` +# +# Note this is equivalent to `ud 1`. pd() { - # Check argument count + # Check arguments; default to $PWD if [ "$#" -gt 1 ] ; then printf >&2 'pd(): Too many arguments\n' return 2 fi - - # Change the positional parameters from the target to its containing - # directory - set -- "$( - - # Figure out target dirname - dirname=${1:-..} - dirname=${dirname%/} - dirname=${dirname%/*} - - # Check we have a target after that - if [ -z "$dirname" ] ; then - printf >&2 'ud(): Destination construction failed\n' - exit 1 - fi - - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${dirname%/}" - )" - - # Remove trailing slash - set -- "${1%/}" - - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return - - # Try to change into the determined directory - command cd -- "$@" + set -- "${1:-"$PWD"}" + + # Make certain there are no trailing slashes to foul us up, and anchor path + # if relative + while : ; do + case $1 in + */) set -- "${1%/}" ;; + /*) break ;; + *) set -- "$PWD"/"$1" ;; + esac + done + + # Strip a path element + set -- "${1%/*}" + + # Try to change into the determined directory, or root if empty + command cd -- "${1:-/}" } diff --git a/sh/shrc.d/rd.sh b/sh/shrc.d/rd.sh index 3b699c0d..c4c1c063 100644 --- a/sh/shrc.d/rd.sh +++ b/sh/shrc.d/rd.sh @@ -1,4 +1,3 @@ -# # Replace the first instance of the first argument string with the second # argument string in $PWD, and make that the target of the cd builtin. This is # to emulate a feature of the `cd` builtin in Zsh that I like, but that I think @@ -12,7 +11,6 @@ # $ rd usr opt # $ pwd # /opt/bin -# rd() { # Check argument count diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index 561a77f4..af82b67e 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -1,4 +1,3 @@ -# # Shortcut to switch to another directory with the same parent, i.e. a sibling # of the current directory. # @@ -31,7 +30,6 @@ # /tmp/tmp.ZSunna5Eup/a # # Seems to work for symbolic links. -# sd() { # Check argument count -- cgit v1.2.3 From 5fe1ba3c7cbf48f65b5287de6cd36112c16ab4a6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:35:58 +1200 Subject: Remove solved issue This was fixed in 6c4d255 --- ISSUES.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index 4116adda..a69e07df 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -23,4 +23,3 @@ Known issues my own stuff in there * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting -* Copy-mode configuration for tmux needs to be reinstated. -- cgit v1.2.3 From f1bff51c5bc41ace7ddfd35bef76a7e09066aa8d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:37:15 +1200 Subject: Add an issue --- ISSUES.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index a69e07df..83358762 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -23,3 +23,5 @@ Known issues my own stuff in there * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting +* Would be good to remove the remaining subshell expansions in sh/shrc.d if + possible, have already removed them from bd/pd/sd/ud() -- cgit v1.2.3 From 330374feeeca822525beff73354162a3dc33b3a0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:38:25 +1200 Subject: Remove an implemented idea This was done in fd70519 --- IDEAS.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 67283ce2..f73e94b6 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -8,7 +8,6 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * edio(1df), like vipe(1) -* Detect appropriate shell family to install in Makefile * qmp(1df)--quick man page * ad() could be more intelligent; if there's only one directory that matches the *whole pattern*, we can assume it's safe to use that one, rather than -- cgit v1.2.3 From 5fe86cf87d93d4f768e5bf7404cdfbc3908d9023 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:39:40 +1200 Subject: Remove implemented idea This was implemented in 13a4187 --- IDEAS.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index f73e94b6..083df51b 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -7,7 +7,6 @@ Ideas manageable * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? -* edio(1df), like vipe(1) * qmp(1df)--quick man page * ad() could be more intelligent; if there's only one directory that matches the *whole pattern*, we can assume it's safe to use that one, rather than -- cgit v1.2.3 From 361f31b086ebe67a0d9e1733c579c6b8498b0c99 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:40:34 +1200 Subject: Correct comment spelling error --- bash/bash_completion.d/sd.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/sd.bash b/bash/bash_completion.d/sd.bash index aeee1615..aeb76fa0 100644 --- a/bash/bash_completion.d/sd.bash +++ b/bash/bash_completion.d/sd.bash @@ -7,7 +7,7 @@ _sd() { # Current directory can't be root directory [[ $PWD != / ]] || return 1 - # Build list of matching sibiling directories + # Build list of matching sibling directories local dirname while IFS= read -rd '' dirname ; do [[ -n $dirname ]] || continue -- cgit v1.2.3 From df7182774a97fd330f0ce6358ae4c2454b121f9e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:45:23 +1200 Subject: Remove hare-brained no-op line --- sh/shrc.d/ud.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sh/shrc.d/ud.sh b/sh/shrc.d/ud.sh index a3997702..06234569 100644 --- a/sh/shrc.d/ud.sh +++ b/sh/shrc.d/ud.sh @@ -8,7 +8,6 @@ ud() { return 2 fi set -- "${1:-1}" "${2:-"$PWD"}" - set -- "$1" "$2" # Check first argument, number of steps upward. "0" is weird, but valid; # "-1" however makes no sense at all -- cgit v1.2.3 From 0eca7eafffbd667b7e5f4d2423adb54ea5582165 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:45:37 +1200 Subject: Tidy/golf gt() down a bit --- sh/shrc.d/gt.sh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sh/shrc.d/gt.sh b/sh/shrc.d/gt.sh index c90af073..95ab4c2f 100644 --- a/sh/shrc.d/gt.sh +++ b/sh/shrc.d/gt.sh @@ -3,26 +3,24 @@ gt() { # Check argument count - if [ "$#" -gt 1 ] ; then - printf >&2 'gt(): Too many arguments\n' + if [ "$#" -ne 1 ] ; then + printf >&2 'gt(): Need one argument\n' return 2 fi - # Strip trailing slash - set -- "${1%/}" - - # If target doesn't have a leading slash, add PWD prefix - case $1 in - /*) ;; - *) set -- "${PWD%/}"/"$1" - esac + # Make certain there are no trailing slashes to foul us up, and anchor path + # if relative + while : ; do + case $1 in + */) set -- "${1%/}" ;; + /*) break ;; + *) set -- "$PWD"/"$1" ;; + esac + done # If target isn't a directory, chop to its parent [ -d "$1" ] || set -- "${1%/*}" - # If target is now empty, go to the root - [ -n "$1" ] || set -- / - - # Try to change into the determined directory - command cd -- "$@" + # Try to change into the determined directory, or root if empty + command cd -- "${1:-/}" } -- cgit v1.2.3 From 1bca0a6205c0c22bc0e23c642f47da18d5164766 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:46:48 +1200 Subject: Remove ad() It has no real advantages over and isn't as clever as just cd /a*/b*/c* --- IDEAS.markdown | 3 -- README.markdown | 2 -- bash/bash_completion.d/ad.bash | 2 -- sh/shrc.d/ad.sh | 80 ------------------------------------------ 4 files changed, 87 deletions(-) delete mode 100644 bash/bash_completion.d/ad.bash delete mode 100644 sh/shrc.d/ad.sh diff --git a/IDEAS.markdown b/IDEAS.markdown index 083df51b..4cac76f7 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -8,8 +8,5 @@ Ideas * Have eds(1df) accept stdin with the "starting content" for the script * Convert all the manual pages to mandoc maybe? * qmp(1df)--quick man page -* ad() could be more intelligent; if there's only one directory that matches - the *whole pattern*, we can assume it's safe to use that one, rather than - stopping each time any node has more than one match * The solution to chn(1df) not running in parallel is probably backgrounded processes and mkfifo(1). diff --git a/README.markdown b/README.markdown index 4cd8ebd0..9d16abe5 100644 --- a/README.markdown +++ b/README.markdown @@ -189,8 +189,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: * `pmd()` prints the marked directory. * `xd()` swaps the current and marked directories. * Ten other directory management and navigation functions: - * `ad()` is a `cd` shortcut accepting targets like `/u/l/b` for - `/usr/local/bin`, as long as they are unique. * `bd()` changes into a named ancestor of the current directory. * `gt()` changes into a directory or into a file's directory. * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. diff --git a/bash/bash_completion.d/ad.bash b/bash/bash_completion.d/ad.bash deleted file mode 100644 index 390fcb00..00000000 --- a/bash/bash_completion.d/ad.bash +++ /dev/null @@ -1,2 +0,0 @@ -# Completion function for ad(); just directories -complete -A directory ad diff --git a/sh/shrc.d/ad.sh b/sh/shrc.d/ad.sh deleted file mode 100644 index 55866683..00000000 --- a/sh/shrc.d/ad.sh +++ /dev/null @@ -1,80 +0,0 @@ -# Find an abbreviated path -ad() { - - # Check argument count - if [ "$#" -ne 1 ] ; then - printf >&2 'ad(): Need just one argument\n' - return 2 - fi - - # Change the positional parameters from the abbreviated request - # to any matched directory - set -- "$( - - # Clean up and anchor the request - req=${1%/}/ - case $req in - (/*) ;; - (*) req=${PWD%/}/${req#/} ;; - esac - - # Start building the target directory; go through the request piece by - # piece until it is used up - dir= - while [ -n "$req" ] ; do - - # Chop the next front bit off the request and add it to the dir - dir=${dir%/}/${req%%/*} - req=${req#*/} - - # If that exists, all is well and we can keep iterating - [ -d "$dir" ] && continue - - # Set the positional parameters to a glob expansion of the - # abbreviated directory given - set -- "$dir"* - - # Iterate through the positional parameters filtering out - # directories; we need to run right through the whole list to check - # that we have at most one match - entd= - for ent ; do - [ -d "$ent" ] || continue - - # If we already found a match and have found another one, bail - # out - if [ -n "$entd" ] ; then - printf >&2 'ad(): More than one matching dir for %s*:\n' \ - "$dir" - printf >&2 '%s\n' "$@" - exit 1 - fi - - # Otherwise, this can be our first one - entd=$ent - done - - # If we found no match, bail out - if [ -z "$entd" ] ; then - printf >&2 'ad(): No matching dirs: %s*\n' "$dir" - exit 1 - fi - - # All is well, tack on what we have found and keep going - dir=$entd - - done - - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${dir%/}" - )" - - # Remove trailing slash - set -- "${1%/}" - - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return - - # Try to change into the determined directory - command cd -- "$@" -} -- cgit v1.2.3 From a9784dda9f9707342bed9fed1c07ed2336c73e0e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 26 May 2017 20:55:55 +1200 Subject: Make a caveat of swr(1df) clearer --- bin/swr.sh | 2 +- man/man1/swr.1df | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/swr.sh b/bin/swr.sh index 47c84b86..5bad63ae 100644 --- a/bin/swr.sh +++ b/bin/swr.sh @@ -1,4 +1,4 @@ -# Transparently wrap scp(1) targets on the command line +# Transparently wrap scp(1) targets to read (not write) on the command line self=swr # Create a temporary directory with name in $td, and handle POSIX-ish traps to diff --git a/man/man1/swr.1df b/man/man1/swr.1df index 8792b0ed..4c40a6f0 100644 --- a/man/man1/swr.1df +++ b/man/man1/swr.1df @@ -1,7 +1,7 @@ .TH SWR 1df "January 2017" "Manual page for swr" .SH NAME .B swr -\- run a command including remote file arguments for scp(1) retrieval +\- run a command including remote file arguments for scp(1) reading .SH SYNOPSIS .B swr cat remote:.ssh/authorized_keys @@ -18,6 +18,9 @@ circumstances. This even works for the first argument (i.e. the command), provided that it will run on the local system once copied in. .SH CAVEATS +You can't write to remote files with it. The arguments only work as input +streams, so e.g. "cp .vimrc remote:.vimrc" won't do what you expect. +.P This only works for simple commands; you can't put shell syntax into any of the arguments. .P -- cgit v1.2.3 From 8571498f0f8c27b35a2ed813ace1b0c04e2c1dfd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 20:01:34 +1200 Subject: Add history filename squashing to rlwrap(1) calls --- bin/clog.sh | 2 +- bin/osc.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/clog.sh b/bin/clog.sh index b17ff1c5..b62d4f94 100644 --- a/bin/clog.sh +++ b/bin/clog.sh @@ -7,7 +7,7 @@ set -- # If we have rlwrap, quietly use it command -v rlwrap >/dev/null 2>&1 && - set -- rlwrap -C "$self" "$@" + set -- rlwrap --history-filename=/dev/null -C "$self" "$@" # Write the date, the standard input (rlwrapped if applicable), and two dashes # to $CLOG, defaulting to ~/.clog. diff --git a/bin/osc.sh b/bin/osc.sh index ba35d9b7..b145b5cd 100644 --- a/bin/osc.sh +++ b/bin/osc.sh @@ -17,7 +17,7 @@ serv=${2:-https} set -- ## If we have rlwrap, use it, but don't complain if we don't if command -v rlwrap >/dev/null 2>&1 ; then - set -- "$@" rlwrap + set -- "$@" rlwrap --history-filename=/dev/null fi ## The actual openssl(1ssl) and subcommand call set -- "$@" openssl s_client -- cgit v1.2.3 From 1a672fccf7d8c9b41e02d86c1f7f39a5d025aaf6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 21:17:34 +1200 Subject: More refinements to bd() --- sh/shrc.d/bd.sh | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 9b877faf..1b253e3d 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -20,44 +20,27 @@ bd() { return 2 ;; - # Otherwise, we'll try to find a matching ancestor and then shift the - # initial request off the argument list + # Otherwise, add and keep chopping at the current directory until it's + # empty or it matches the request, then shift the request off *) - - # Push the current directory onto the stack set -- "$1" "$PWD" - - # Keep chopping at the current directory until it's empty or it - # matches the request while : ; do - - # Make certain there are no trailing slashes to foul us up - while : ; do - case $2 in - */) set -- "$1" "${2%/}" ;; - *) break ;; - esac - done - - # Strip a path element - set -- "$1" "${2%/*}" - - # Check whether we're arrived case $2 in - */"$1") break ;; - */*) ;; - *) - printf >&2 'bd(): No match\n' - return 1 - ;; + */"$1"|'') break ;; + */) set -- "$1" "${2%/}" ;; + *) set -- "$1" "${2%/*}" ;; esac done - - # If the first argument ended up empty, we have no match shift ;; esac + # If we have nothing to change into, there's an error + if [ -z "$1" ] ; then + printf >&2 'bd(): No match\n' + return 1 + fi + # We have a match; try and change into it command cd -- "$1" } -- cgit v1.2.3 From 05eac418f012b9d92f1955cab3d19a5cb9aef760 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 21:24:17 +1200 Subject: Add safety to bd() Handle case if PWD does not start with a slash--a big "Shouldn't Happen", but easy enough to be worth handling, since it would loop infinitely otherwise --- sh/shrc.d/bd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 1b253e3d..29bde513 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -28,7 +28,8 @@ bd() { case $2 in */"$1"|'') break ;; */) set -- "$1" "${2%/}" ;; - *) set -- "$1" "${2%/*}" ;; + */*) set -- "$1" "${2%/*}" ;; + *) set -- "$1" '' ;; esac done shift -- cgit v1.2.3 From 5db5287e727a2c73278bd33b9728a3cef1a741eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 21:33:02 +1200 Subject: Use -z rather than !-n --- sh/shrc.d/gd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh index fa5776f2..9f6a43e7 100644 --- a/sh/shrc.d/gd.sh +++ b/sh/shrc.d/gd.sh @@ -8,7 +8,7 @@ gd() { fi # Complain if mark not actually set yet - if ! [ -n "$PMD" ] ; then + if [ -z "$PMD" ] ; then printf >&2 'gd(): Mark not set\n' return 1 fi -- cgit v1.2.3 From 1302b279bf2b1b2ae76ea8251a32e480d64f2f7a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 21:33:09 +1200 Subject: Remove redundant `|| return` from gd() It will do that implicitly anyway --- sh/shrc.d/gd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh index 9f6a43e7..10135d01 100644 --- a/sh/shrc.d/gd.sh +++ b/sh/shrc.d/gd.sh @@ -14,5 +14,5 @@ gd() { fi # Go to the marked directory - cd -- "$PMD" || return + cd -- "$PMD" } -- cgit v1.2.3 From cbbec36d4403dbed6d61232e86b5d4995c8da1fe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 22:52:40 +1200 Subject: More error-resistant sd() --- sh/shrc.d/hgrep.sh | 6 ++-- sh/shrc.d/pmd.sh | 2 +- sh/shrc.d/sd.sh | 86 ++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/sh/shrc.d/hgrep.sh b/sh/shrc.d/hgrep.sh index 1c4c3ec5..fe297ab3 100644 --- a/sh/shrc.d/hgrep.sh +++ b/sh/shrc.d/hgrep.sh @@ -6,11 +6,11 @@ hgrep() { if [ "$#" -eq 0 ] ; then printf >&2 'hgrep(): Need a pattern\n' - exit 2 + return 2 fi - if ! [ -n "$HISTFILE" ] ; then + if [ -z "$HISTFILE" ] ; then printf >&2 'hgrep(): No HISTFILE\n' - exit 2 + return 2 fi grep "$@" "$HISTFILE" } diff --git a/sh/shrc.d/pmd.sh b/sh/shrc.d/pmd.sh index c96a50bd..4b0cd5bd 100644 --- a/sh/shrc.d/pmd.sh +++ b/sh/shrc.d/pmd.sh @@ -1,6 +1,6 @@ # Print the marked directory pmd() { - if ! [ -n "$PMD" ] ; then + if [ -z "$PMD" ] ; then printf >&2 'pmd(): Mark not set\n' return 1 fi diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index af82b67e..8b12c170 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -41,45 +41,75 @@ sd() { # Read sole optional argument case $1 in - # If blank, get a full list of directories at this level; include - # dotfiles, but not the . and .. entries, using glob tricks to avoid - # Bash ruining things with `dotglob` + # Slashes aren't allowed + */*) + printf >&2 'bd(): Illegal slash\n' + return 2 + ;; + + # If blank, we try to find if there's just one sibling, and change to + # that if so '') + # First a special case: root dir + case $PWD in + *[!/]*) ;; + *) + printf >&2 'sd(): No siblings\n' + return 1 + ;; + esac + + # Get a full list of directories at this level; include dotfiles, + # but not the . and .. entries, using glob tricks to avoid Bash + # ruining things with `dotglob` set -- ../[!.]*/ [ -e "$1" ] || shift set -- ../.[!.]*/ "$@" [ -e "$1" ] || shift set -- ../..?*/ "$@" [ -e "$1" ] || shift - ;; - # If not, get that directory, and the current one; shift it off if it - # doesn't exist - *) - set -- ../"${1%/}"/ ../"${PWD##*/}"/ - [ -e "$1" ] || shift - ;; - esac + # Check the number of matches + case $# in - # We should now have two parameters: the current directory and the matched - # sibling - case $# in - 2) ;; - 0|1) - printf >&2 'sd(): No match\n' - return 1 - ;; - *) - printf >&2 'sd(): Multiple matches\n' - return 1 + # One match? Must be $PWD, so no siblings--throw in 0 just in + # case, but that Shouldn't Happen (TM) + 0|1) + printf >&2 'sd(): No siblings\n' + return 1 + ;; + + # Two matches; hopefully just one sibling, but which is it? + 2) + + # Push PWD onto the stack, strip trailing slashes + set -- "$1" "$2" "$PWD" + while : ; do + case $3 in + */) set -- "$1" "$2" "${3%/}" ;; + *) break ;; + esac + done + + # Pick whichever of our two parameters doesn't look like + # PWD as our sole parameter + case $1 in + ../"${3##*/}"/) set -- "$2" ;; + *) set -- "$1" ;; + esac + ;; + + # Anything else? Multiple siblings--user will need to specify + *) + printf >&2 'sd(): Multiple siblings\n' + return 1 + ;; + esac ;; - esac - # Find which of these two is not the current directory and set that as our - # sole parameter - case $1 in - ../"${PWD##*/}"/) set -- "$2" ;; - *) set -- "$1" ;; + # If not, simply set our target to that directory, and let `cd` do the + # complaining if it doesn't exist + *) set -- ../"$1" ;; esac # Try and change into the first parameter -- cgit v1.2.3 From ee2a3a4d87665fb8b79363b1f78250908ec78b94 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 22:53:36 +1200 Subject: Revert "Remove redundant `|| return` from gd()" This reverts commit 1302b279bf2b1b2ae76ea8251a32e480d64f2f7a. This was added because of Shellcheck being fussy --- sh/shrc.d/gd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh index 10135d01..9f6a43e7 100644 --- a/sh/shrc.d/gd.sh +++ b/sh/shrc.d/gd.sh @@ -14,5 +14,5 @@ gd() { fi # Go to the marked directory - cd -- "$PMD" + cd -- "$PMD" || return } -- cgit v1.2.3 From 5f714e85e2d97bf820b86db924eb00f459d731eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 23:51:52 +1200 Subject: Simplify rd() a lot Including removing the pesky subshell --- sh/shrc.d/rd.sh | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/sh/shrc.d/rd.sh b/sh/shrc.d/rd.sh index c4c1c063..9633713a 100644 --- a/sh/shrc.d/rd.sh +++ b/sh/shrc.d/rd.sh @@ -23,42 +23,17 @@ rd() { ;; esac - # Set the positional parameters to an option terminator and what will - # hopefully end up being the substituted directory name - set -- "$( - - # Current path: e.g. /foo/ayy/bar/ayy - cur=$PWD - # Pattern to replace: e.g. ayy - pat=$1 - # Text with which to replace pattern: e.g. lmao - # This can be a null string or unset, in order to *remove* the pattern - rep=$2 - - # /foo/ - curtc=${cur%%"$pat"*} - # /bar/ayy - curlc=${cur#*"$pat"} - # /foo/lmao/bar/ayy - new=${curtc}${rep}${curlc} - - # Check that a substitution resulted in an actual change and that we - # ended up with a non-null target, or print an error to stderr - if [ "$cur" = "$curtc" ] || [ -z "$new" ] ; then + # Check there's something to substitute, and do it + case $PWD in + *"$1"*) + set -- "${PWD%%"$1"*}""$2""${PWD#*"$1"}" + ;; + *) printf >&2 'rd(): Substitution failed\n' - exit 1 - fi - - # Print the target with trailing slash to work around newline stripping - printf '%s/' "${new%/}" - )" - - # Remove trailing slash - set -- "${1%/}" - - # If the subshell printed nothing, return with failure - [ -n "$1" ] || return + return 1 + ;; + esac # Try to change into the determined directory - command cd -- "$@" + command cd -- "$1" } -- cgit v1.2.3 From 3550103bbfdbb5675a961dafd6fe13fd58866f15 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 00:21:09 +1200 Subject: Resolve issue Satisfied the remaining subshells are needed --- ISSUES.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index 83358762..a69e07df 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -23,5 +23,3 @@ Known issues my own stuff in there * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting -* Would be good to remove the remaining subshell expansions in sh/shrc.d if - possible, have already removed them from bd/pd/sd/ud() -- cgit v1.2.3 From 8b398553a6d6667c004b5fd2125501613471a2b5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 12:56:15 +1200 Subject: Add mw(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/mw.awk | 10 ++++++++++ man/man1/mw.1df | 25 +++++++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 bin/mw.awk create mode 100644 man/man1/mw.1df diff --git a/.gitignore b/.gitignore index e2f5a857..4d9ef923 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ bin/mktd bin/mode bin/motd bin/murl +bin/mw bin/nlbr bin/onl bin/osc diff --git a/Makefile b/Makefile index 1f620612..d570e6b8 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,7 @@ BINS = bin/ap \ bin/mode \ bin/motd \ bin/murl \ + bin/mw \ bin/nlbr \ bin/onl \ bin/osc \ diff --git a/README.markdown b/README.markdown index 9d16abe5..6b0ff38e 100644 --- a/README.markdown +++ b/README.markdown @@ -502,6 +502,8 @@ Installed by the `install-bin` target: * `mkcp(1df)` creates a directory and copies preceding arguments into it. * `mkmv(1df)` creates a directory and moves preceding arguments into it. * `motd(1df)` shows the system MOTD. +* `mw(1df)` prints alphabetic space-delimited words from the input one per + line. * `onl(1df)` crunches input down to one printable line. * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s `s_client` subcommand. diff --git a/bin/mw.awk b/bin/mw.awk new file mode 100644 index 00000000..f51b8272 --- /dev/null +++ b/bin/mw.awk @@ -0,0 +1,10 @@ +# Crude approach to get alphabetic words one per line from input, not sorted or +# deduplicated +BEGIN { + RS = "(--|['_-]?[^[:alnum:]'_-]+['_-]?)" +} +{ + for (i = 1; i <= NF; i++) + if ($i ~ /[[:alpha:]]/) + print $i +} diff --git a/man/man1/mw.1df b/man/man1/mw.1df new file mode 100644 index 00000000..51623600 --- /dev/null +++ b/man/man1/mw.1df @@ -0,0 +1,25 @@ +.TH MW 1df "May 2017" "Manual page for mw" +.SH NAME +.B mw +\- get space-delimited alphabetic words from input, one per line +.SH SYNOPSIS +.B mw FILE1 +[FILE2...] +.br +prog1 | +.B mw +.SH DESCRIPTION +.B mw +separates the input into space-delimited words and prints them one per line, +with no deduplication or sorting. It's a fairly naïve approach to the problem +but it works fine as a crude initial approach. +.SH NOTES +This was written after watching that lovely old AT&T video where members of the +Unix team (specifically Brian Kernighan and Lorinda Cherry) demonstrate piping +programs together; Kernighan demonstrates `makewords` during his example. +.P + +.SH SEE ALSO +ddup(1df), sort(1), uniq(1) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From c1a8107b028c02ddb7c8d13f5803b5d84d52b070 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 13:08:23 +1200 Subject: Tweak FS a bit for mw(1df) --- bin/mw.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mw.awk b/bin/mw.awk index f51b8272..84332fac 100644 --- a/bin/mw.awk +++ b/bin/mw.awk @@ -1,7 +1,7 @@ # Crude approach to get alphabetic words one per line from input, not sorted or # deduplicated BEGIN { - RS = "(--|['_-]?[^[:alnum:]'_-]+['_-]?)" + RS = "(--|['_-]*[^[:alnum:]'_-]+['_-]*)" } { for (i = 1; i <= NF; i++) -- cgit v1.2.3 From 3df8bf4b48f87d181cf3e289085c30dab38c494c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 13:27:13 +1200 Subject: Add p(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/p.sh | 1 + man/man1/p.1df | 27 +++++++++++++++++++++++++++ 5 files changed, 32 insertions(+) create mode 100644 bin/p.sh create mode 100644 man/man1/p.1df diff --git a/.gitignore b/.gitignore index 4d9ef923..a539a8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ bin/mw bin/nlbr bin/onl bin/osc +bin/p bin/pa bin/paz bin/ped diff --git a/Makefile b/Makefile index d570e6b8..f35e1917 100644 --- a/Makefile +++ b/Makefile @@ -141,6 +141,7 @@ BINS = bin/ap \ bin/ped \ bin/pit \ bin/plmu \ + bin/p \ bin/pp \ bin/pph \ bin/pst \ diff --git a/README.markdown b/README.markdown index 6b0ff38e..c35d3790 100644 --- a/README.markdown +++ b/README.markdown @@ -507,6 +507,8 @@ Installed by the `install-bin` target: * `onl(1df)` crunches input down to one printable line. * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s `s_client` subcommand. +* `p(1df)` prints concatenated standard input; `cat(1)` as it should always + have been * `pa(1df)` prints its arguments, one per line. * `pp(1df)` prints the full path of each argument using `$PWD`. * `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. diff --git a/bin/p.sh b/bin/p.sh new file mode 100644 index 00000000..5b59986e --- /dev/null +++ b/bin/p.sh @@ -0,0 +1 @@ +exec cat -- "${@:--}" diff --git a/man/man1/p.1df b/man/man1/p.1df new file mode 100644 index 00000000..2d291fc1 --- /dev/null +++ b/man/man1/p.1df @@ -0,0 +1,27 @@ +.TH P 1df "May 2017" "Manual page for p" +.SH NAME +.B p +\- print standard input to standard output +.SH SYNOPSIS +.B p +FILE1 [FILE2...] +.br +prog1 | +.B +p +.br +prog1 | +.B +p +FILE1 - FILE2 +.SH DESCRIPTION +.B p +prints concatenated standard input from files to, and nothing else; cat(1) as +it always should have been--no flags, and hence no need for end-of-options for +filenames that start with a dash. +.P +Quicker to type, too. +.SH SEE ALSO +cat(1) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From af85480289c13f091f18a97312e59c599fc1c697 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 13:29:23 +1200 Subject: Add a note --- man/man1/p.1df | 3 +++ 1 file changed, 3 insertions(+) diff --git a/man/man1/p.1df b/man/man1/p.1df index 2d291fc1..cafd8798 100644 --- a/man/man1/p.1df +++ b/man/man1/p.1df @@ -21,6 +21,9 @@ it always should have been--no flags, and hence no need for end-of-options for filenames that start with a dash. .P Quicker to type, too. +.P +Still treats an "-" argument as a shorthand for "standard input" though, +because I like that and it's POSIX. .SH SEE ALSO cat(1) .SH AUTHOR -- cgit v1.2.3 From 30bd54d5da1c7b766fad61c71c7cb24ac79ce06e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 13:41:28 +1200 Subject: Add a pome --- man/man1/p.1df | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/man/man1/p.1df b/man/man1/p.1df index cafd8798..3a06078b 100644 --- a/man/man1/p.1df +++ b/man/man1/p.1df @@ -24,6 +24,18 @@ Quicker to type, too. .P Still treats an "-" argument as a shorthand for "standard input" though, because I like that and it's POSIX. +.SH POETRY + "Prophet!" said I, "thing of evil!--prophet still, if bird or devil!-- +.br + Whether Tempter sent, or whether tempest tossed thee here ashore, +.br + Desolate yet all undaunted, on this desert land enchanted-- +.br + On this home by Horror haunted--tell me truly, I implore-- +.br + Is there--is there balm in Gilead?--tell me--tell me, I implore!" +.br + Quoth the Raven "Nevermore." .SH SEE ALSO cat(1) .SH AUTHOR -- cgit v1.2.3 From fd958555e213e1bf04b8538c2ae1d19d32fa6c02 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 13:43:17 +1200 Subject: Format the quotes a bit more nicely --- man/man1/edda.1df | 10 +++++----- man/man1/p.1df | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/man/man1/edda.1df b/man/man1/edda.1df index c501e571..55a12f45 100644 --- a/man/man1/edda.1df +++ b/man/man1/edda.1df @@ -13,15 +13,15 @@ each of the files given as arguments. Example: w EOF .SH WISDOM -"Each man who is wise and would wise be called, + Each man who is wise and would wise be called, .br - Must ask and answer aright. + Must ask and answer aright. .br - Let one know thy secret, but never a second; + Let one know thy secret, but never a second; .br - If three, a thousand shall know." + If three, a thousand shall know." .P - -- Poetic Edda, Hávamál, 63 + -- Poetic Edda, Hávamál, 63 .br .SH SEE ALSO ed(1) diff --git a/man/man1/p.1df b/man/man1/p.1df index 3a06078b..803fd4c6 100644 --- a/man/man1/p.1df +++ b/man/man1/p.1df @@ -34,8 +34,9 @@ because I like that and it's POSIX. On this home by Horror haunted--tell me truly, I implore-- .br Is there--is there balm in Gilead?--tell me--tell me, I implore!" -.br +.P Quoth the Raven "Nevermore." + -- Poe .SH SEE ALSO cat(1) .SH AUTHOR -- cgit v1.2.3 From 19aa20ea90c3671b29bf1e2237cc5d3bc92990d7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 29 May 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 3ec671e1..17f6f4d5 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 3ec671e112c760e68eee1e3cc5eeb9408448dab4 +Subproject commit 17f6f4d585062ffdcf99b4af80aee3c706b4038f -- cgit v1.2.3 From f2d19bb3ab31fd94eb521859e2f44d99579ed840 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 13:40:25 +1200 Subject: Add an idea --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 4cac76f7..3b0f1c75 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -10,3 +10,5 @@ Ideas * qmp(1df)--quick man page * The solution to chn(1df) not running in parallel is probably backgrounded processes and mkfifo(1). +* Write something like hcat(1df) or tcat(1df) that includes filename headings + for each concatenated file. -- cgit v1.2.3 From 880277e86857e75168707001155180923b601756 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 18:11:45 +1200 Subject: Add "downloads.sh" profile event Looks for ~/.downloads, checks each named dir, if there are any files in it, warns you once per dir including a count. This is to prompt me into sorting my downloads directory. --- sh/profile.d/downloads.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sh/profile.d/downloads.sh diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh new file mode 100644 index 00000000..eb2a9b54 --- /dev/null +++ b/sh/profile.d/downloads.sh @@ -0,0 +1,13 @@ +[ -f "$HOME"/.downloads ] || return +( + while IFS= read -r dir ; do + case $dir in + '#'*) continue ;; + esac + [ -d "$dir" ] || continue + set -- "$dir"/* + [ -e "$1" ] || shift + [ "$#" -gt 0 ] || continue + printf 'You have %u unsorted files in %s.\n' "$#" "$dir" + done < "$HOME"/.downloads +) -- cgit v1.2.3 From 8ca2f8db01b8660a235bede6987bd31e5cc63c14 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 18:14:01 +1200 Subject: Some extra newlines --- sh/profile.d/downloads.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh index eb2a9b54..4c57ddfd 100644 --- a/sh/profile.d/downloads.sh +++ b/sh/profile.d/downloads.sh @@ -8,6 +8,6 @@ set -- "$dir"/* [ -e "$1" ] || shift [ "$#" -gt 0 ] || continue - printf 'You have %u unsorted files in %s.\n' "$#" "$dir" + printf '\nYou have %u unsorted files in %s.\n\n' "$#" "$dir" done < "$HOME"/.downloads ) -- cgit v1.2.3 From 656da025bb037b816b2e7be9102a6705772207b8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 18:15:39 +1200 Subject: Conditions for downloads.sh --- sh/profile.d/downloads.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh index 4c57ddfd..fb8dd64a 100644 --- a/sh/profile.d/downloads.sh +++ b/sh/profile.d/downloads.sh @@ -1,4 +1,19 @@ +# Only if shell is interactive +case $- in + *i*) ;; + *) return ;; +esac + +# Only if not in a tmux window +[ -z "$TMUX" ] || return + +# Not if ~/.hushlogin exists +[ -e "$HOME"/.hushlogin ] && return + +# Not if ~/.downloads doesn't [ -f "$HOME"/.downloads ] || return + +# Count files in each directory, report if greater than zero ( while IFS= read -r dir ; do case $dir in -- cgit v1.2.3 From 15c3cf609f3d4df1f9d43b0eda20d8bd4297e364 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:44:21 +1200 Subject: Adjust man page indent --- man/man1/edda.1df | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/man1/edda.1df b/man/man1/edda.1df index 55a12f45..8c71f3ec 100644 --- a/man/man1/edda.1df +++ b/man/man1/edda.1df @@ -8,10 +8,10 @@ Duplicate any data on stdin into a temporary file, and run ed(1) options over each of the files given as arguments. Example: .P - $ edda /etc/app.d/*.conf <<'EOF' - ,s/foo/bar/g - w - EOF + $ edda /etc/app.d/*.conf <<'EOF' + ,s/foo/bar/g + w + EOF .SH WISDOM Each man who is wise and would wise be called, .br -- cgit v1.2.3 From f156a9f4199842c7a4d19cdabd1c6e932b0123b4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:44:30 +1200 Subject: Adjust p(1df) man page --- man/man1/p.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/p.1df b/man/man1/p.1df index 803fd4c6..1a539e34 100644 --- a/man/man1/p.1df +++ b/man/man1/p.1df @@ -34,8 +34,9 @@ because I like that and it's POSIX. On this home by Horror haunted--tell me truly, I implore-- .br Is there--is there balm in Gilead?--tell me--tell me, I implore!" -.P +.br Quoth the Raven "Nevermore." +.P -- Poe .SH SEE ALSO cat(1) -- cgit v1.2.3 From 4d99ffcec10c522229d9325a8691fc595c6098e9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:45:36 +1200 Subject: Restore a missing word --- man/man1/p.1df | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/man1/p.1df b/man/man1/p.1df index 1a539e34..2f9f3c45 100644 --- a/man/man1/p.1df +++ b/man/man1/p.1df @@ -16,9 +16,9 @@ p FILE1 - FILE2 .SH DESCRIPTION .B p -prints concatenated standard input from files to, and nothing else; cat(1) as -it always should have been--no flags, and hence no need for end-of-options for -filenames that start with a dash. +prints concatenated standard input from files to standard output, and nothing +else; cat(1) as it always should have been--no flags, and hence no need for +end-of-options for filenames that start with a dash. .P Quicker to type, too. .P -- cgit v1.2.3 From dae63c5bb36f05ee733ce298ed6d3a3cf5fadf96 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:49:43 +1200 Subject: Correct a path in bcq(1df) man page --- man/man1/bcq.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/bcq.1df b/man/man1/bcq.1df index 55b44a69..64e2048b 100644 --- a/man/man1/bcq.1df +++ b/man/man1/bcq.1df @@ -6,7 +6,7 @@ .B bcq .SH DESCRIPTION .B bcq -starts bc(1), checking ~/.cache/bc/quiet to see if a --quiet option is +starts bc(1), checking ~/.cache/sh/opt/bc/quiet to see if a --quiet option is available, adding it if so to elide the annoying GNU boilerplate for an interactive session. .SH AUTHOR -- cgit v1.2.3 From 3a96724544969ca1d6e61b2e7b3cde9aed4be243 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:52:45 +1200 Subject: Correct a troff macro in clog(1df) man page --- man/man1/clog.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/clog.1df b/man/man1/clog.1df index 0e3e7b87..43193076 100644 --- a/man/man1/clog.1df +++ b/man/man1/clog.1df @@ -13,7 +13,7 @@ getting real tired of all this overengineering receives a message on stdin, timestamps it with a leading date(1), and writes it to the file with path in environment variable CLOG, defaulting to ~/.clog, terminating each entry with two hyphens. -,P +.P If rlwrap(1) is found, it will be used for the line editing. If not, just the terminal's cooked mode will be used. .SH AUTHOR -- cgit v1.2.3 From 3a15bc2a248c14136d32751d7fda3499a6865800 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:57:27 +1200 Subject: Unbold example arguments in fgscr(1df) man page --- man/man1/fgscr.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/fgscr.1df b/man/man1/fgscr.1df index 80da3798..cc273b89 100644 --- a/man/man1/fgscr.1df +++ b/man/man1/fgscr.1df @@ -5,7 +5,8 @@ .SH SYNOPSIS .B fgscr .br -.B fgscr /path1 /path2 +.B fgscr +/path1 /path2 .SH DESCRIPTION .B fgscr searches for Git repositories recursively with the given ancestor directory -- cgit v1.2.3 From 4cbf95d7b61eff5f31e113a105283356c51bd5fe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 19:58:44 +1200 Subject: Correct copy-paste error in fnl(1df) man page --- man/man1/fnl.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/fnl.1df b/man/man1/fnl.1df index 6c34f19c..d085df6b 100644 --- a/man/man1/fnl.1df +++ b/man/man1/fnl.1df @@ -1,7 +1,7 @@ .TH FNL 1df "August 2016" "Manual page for fnl" .SH NAME .B fnl -\- list the biggest files in the given directory +\- run a command and put stdout and stderr into temporary files .SH SYNOPSIS .B fnl command arg1 ... -- cgit v1.2.3 From 63461b89b2343ed459f1d9cf8000be7dfc4f15b5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 May 2017 20:09:33 +1200 Subject: Correction/referencing for pp/pph(1df) --- man/man1/pp.1df | 2 ++ man/man1/pph.1df | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/man/man1/pp.1df b/man/man1/pp.1df index 322e7b48..0bb55cd1 100644 --- a/man/man1/pp.1df +++ b/man/man1/pp.1df @@ -15,5 +15,7 @@ The path need not actually exist. Newlines in filenames will still work, but the results won't really make sense as they'll be indistinguishable from newlines separating the files. This is for generating human-readable file lists, not for machines. +.SH SEE ALSO +pph(1df) .SH AUTHOR Tom Ryder diff --git a/man/man1/pph.1df b/man/man1/pph.1df index 0ad98fc5..f68b394d 100644 --- a/man/man1/pph.1df +++ b/man/man1/pph.1df @@ -1,9 +1,9 @@ -.TH PPH 1df "January 2017" "Manual page for pp" +.TH PPH 1df "January 2017" "Manual page for pph" .SH NAME -.B pp +.B pph \- print the full path to each argument, hostname prepended .SH SYNOPSIS -.B pp +.B pph /arg arg2 ./arg3 .SH DESCRIPTION .B pph @@ -12,5 +12,7 @@ prepends the machine's hostname and a colon to each line. .SH CAVEATS Newlines in filenames will mess this up. This is for generating human-readable file lists, not for machines. +.SH SEE ALSO +pp(1df) .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 9cb768020c4efaec2a69251c4ef46dfe35f2ce26 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 1 Jun 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index 17f6f4d5..ddfb1f14 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit 17f6f4d585062ffdcf99b4af80aee3c706b4038f +Subproject commit ddfb1f14d7597e6aedc749be06b559a673c437ab -- cgit v1.2.3 From 7b49385f30020777db82732760e667e90b9ae0f8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 1 Jun 2017 11:07:19 +1200 Subject: Add skip-pager to ~/.my.cnf I usually don't want it --- mysql/my.cnf | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql/my.cnf b/mysql/my.cnf index e0df3c23..900cf1a9 100644 --- a/mysql/my.cnf +++ b/mysql/my.cnf @@ -3,3 +3,4 @@ default-character-set=utf8 no-auto-rehash prompt='(\u@\h:\d) mysql> ' safe-updates +skip-pager -- cgit v1.2.3 From 56c8ada346bde4ea44e199020c03afd731727bd6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 18:28:57 +1200 Subject: Simplify some awk --- bin/rfct.awk | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/rfct.awk b/bin/rfct.awk index 256841a7..4467f206 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -6,11 +6,8 @@ BEGIN { ORS = "\n\n" } -{ - # Strip out control characters, except tab and newline - gsub(/[^[:print:]\n\t]/, "") +# Strip out control characters, except tab and newline +{ gsub(/[^[:print:]\n\t]/, "") } - # If there's anything left, print it - if (length) - print -} +# If there's anything left, print it +length($0) -- cgit v1.2.3 From cde3c255ff7024181a54b19e5ec1dac3ab892836 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 20:30:20 +1200 Subject: Add mi5(1df) --- .gitignore | 1 + IDEAS.markdown | 2 ++ Makefile | 1 + README.markdown | 2 ++ bin/mi5.awk | 50 ++++++++++++++++++++++++++++++++++++++++++++ man/man1/mi5.1df | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+) create mode 100644 bin/mi5.awk create mode 100644 man/man1/mi5.1df diff --git a/.gitignore b/.gitignore index a539a8f8..68ac0a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ bin/jfc bin/jfcd bin/jfp bin/loc +bin/mi5 bin/max bin/maybe bin/mean diff --git a/IDEAS.markdown b/IDEAS.markdown index 3b0f1c75..61f1049d 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -12,3 +12,5 @@ Ideas processes and mkfifo(1). * Write something like hcat(1df) or tcat(1df) that includes filename headings for each concatenated file. +* mi5(1df) could be made to handle comment delimiters and $1 $2 expansions + without too much pain (substr/index counting) diff --git a/Makefile b/Makefile index f35e1917..a562b0b1 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,7 @@ BINS = bin/ap \ bin/jfcd \ bin/jfp \ bin/loc \ + bin/mi5 \ bin/max \ bin/maybe \ bin/mean \ diff --git a/README.markdown b/README.markdown index c35d3790..bd0b6682 100644 --- a/README.markdown +++ b/README.markdown @@ -498,6 +498,8 @@ Installed by the `install-bin` target: success, it exits with success or failure. Good for quick tests. * `mex(1df)` makes given filenames in `$PATH` executable. +* `mi5(1df)` pre-processes a crude but less painful macro expansion file + format into m4. * `mftl(1df)` finds usable-looking targets in Makefiles. * `mkcp(1df)` creates a directory and copies preceding arguments into it. * `mkmv(1df)` creates a directory and moves preceding arguments into it. diff --git a/bin/mi5.awk b/bin/mi5.awk new file mode 100644 index 00000000..c05955ff --- /dev/null +++ b/bin/mi5.awk @@ -0,0 +1,50 @@ +# Crude m4 preprocessor +BEGIN { mac = 0 } + +# Print an m4 opener as the first byte +NR == 1 { printf "`" } + +# Blocks +NF == 1 && $1 == "<%" && !mac { + mac = 1 + printf "'" + next +} +NF == 1 && $1 == "%>" && mac { + mac = 0 + printf "`" + next +} + +# If processing macros, strip leading and trailing whitespace and skip blank +# lines +mac { + sub(/^ */, "") + sub(/ *$/, "") +} +mac && !NF { next } + +# Inlines +mac { + print $0 "dnl" +} +!mac { + + # Don't let apostrophes close the comment + gsub(/'/, "''`") + + # Don't let $ signs confound expansion + gsub(/\$/, "$'`") + + # Replace m5 opener with m4 closer + gsub(/<% */, "'") + + # Replace m5 closer with m4 opener + gsub(/ *%>/, "`") + print +} + +# Print an m4 closer and newline deleter as the last bytes +END { + print "'dnl" +} diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df new file mode 100644 index 00000000..dd215d0c --- /dev/null +++ b/man/man1/mi5.1df @@ -0,0 +1,63 @@ +.TH MI5 1df "June 2017" "Manual page for mi5" +.SH NAME +.B mi5 +\- m4 inverted preprocessor +.SH SYNOPSIS +.B mi5 +FILE > out.m4 +.br +.B mi5 +FILE1 FILE2 > out.m4 +.br +prog | +.B mi5 > out.m4 +.br +.SH DESCRIPTION +.B mi5 +is a simple and crude m4 preprocessor to make using m4 slightly more bearable +and predictable for its author, who wants badly to like m4 but doesn't. It's +primarily intended for situations where the majority of a file is simple static +text, and only a few simple macros need to be defined and expanded, which +covers almost every usage case for the author. It's written to work with any +POSIX m4. +.P +mi5 inverts m4's usual approach by approaching most of the file as if it were +part of an m4 comment, with <% and %> as the delimiters to specify markers in +which macro expansion should occur. This makes m4 work in a way reminiscent of +templating libraries or languages like PHP. +.P +Macros can be expanded as blocks: +.P + <% + define(`FOO', `bar') + define(`BAZ', include(`include/quux.inc') + ?> +.P +For this format, "dnl" macros to delete newlines for each declaration are +inserted for you. Blank lines are skipped, and leading and trailing spaces are +ignored. The above code therefore produces no actual output, as it only has two +define calls. +.P +For inline expansion, the syntax is similar, but the behaviour slightly different: +.P + The value of the FOO macro is <% FOO %>. +.P +Spaces immediately after the opening delimiter and before the closing delimiter +are ignored, but spaces produced within the macro are preserved. +.P +Ideally, you do macro definition in an mi5 block at the top of your file, and +very simple macro expansion in an mi5 inline. +.SH CAVEATS +Only very simple macro expansions work in inline calls at the moment. This can +be fixed by the author tokenizing the line properly, which he'll do Real Soon +Now (TM). Specifically, neither comment delimiters nor macro parameters work. +The latter is because of a nasty corner-case in m4 where parameter expansions +$1, $2, $*, etc are expanded +.B even within comments, +one of m4's darkest corners. The workaround is to do as much logic as you can +in a block, defining your result as a single simple macros, and then expanding +that inline. +.SH SEE ALSO +bp(1df), xargs(1) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From bae8dea461ddbceb4f345d2f230460e7234af76d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 20:45:22 +1200 Subject: Move existing .m4 to .m4.mi5 Along with accompanying Makefile rules and .gitignorances --- .gitignore | 3 ++ Makefile | 8 +++- git/gitconfig.m4 | 64 ------------------------- git/gitconfig.m4.mi5 | 64 +++++++++++++++++++++++++ gnupg/gpg.conf.m4 | 52 -------------------- gnupg/gpg.conf.m4.mi5 | 52 ++++++++++++++++++++ tmux/tmux.conf.m4 | 130 -------------------------------------------------- tmux/tmux.conf.m4.mi5 | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 256 insertions(+), 247 deletions(-) delete mode 100644 git/gitconfig.m4 create mode 100644 git/gitconfig.m4.mi5 delete mode 100644 gnupg/gpg.conf.m4 create mode 100644 gnupg/gpg.conf.m4.mi5 delete mode 100644 tmux/tmux.conf.m4 create mode 100644 tmux/tmux.conf.m4.mi5 diff --git a/.gitignore b/.gitignore index 68ac0a0a..873b60a1 100644 --- a/.gitignore +++ b/.gitignore @@ -137,7 +137,10 @@ games/strik games/xyzzy games/zs git/gitconfig +git/gitconfig.m4 gnupg/gpg.conf +gnupg/gpg.conf.m4 man/man7/dotfiles.7df tmux/tmux.conf +tmux/tmux.conf.m4 urxvt/ext/select diff --git a/Makefile b/Makefile index a562b0b1..11bcf6f0 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ lint-xinit .SUFFIXES: -.SUFFIXES: .awk .bash .pl .sed .sh +.SUFFIXES: .awk .bash .mi5 .pl .sed .sh NAME = 'Tom Ryder' EMAIL = tom@sanctum.geek.nz @@ -218,9 +218,12 @@ clean distclean: $(BINS) \ $(GAMES) \ git/gitconfig \ + git/gitconfig.m4 \ gnupg/gpg.conf \ + gnupg/gpg.conf.m4 \ man/man8/dotfiles.7df \ tmux/tmux.conf \ + tmux/tmux.conf.m4 \ urxvt/ext/select git/gitconfig: git/gitconfig.m4 @@ -270,6 +273,9 @@ tmux/tmux.conf: tmux/tmux.conf.m4 sh bin/shb.sh sh < $< > $@ chmod +x ./$@ +.mi5: + awk -f bin/mi5.awk < $< > $@ + install: install-bin \ install-curl \ install-ex \ diff --git a/git/gitconfig.m4 b/git/gitconfig.m4 deleted file mode 100644 index f533f02f..00000000 --- a/git/gitconfig.m4 +++ /dev/null @@ -1,64 +0,0 @@ -[advice] - statusHints = false - detachedHead = false - implicitIdentity = false - pushUpdateRejected = false - -[alias] - amend = commit --amend - ls = log --oneline - others = ls-files --others --exclude-standard - fuckit = "!git clean -dfx ; git reset --hard" - -[color] - ui = true - -[commit] - status = false - -[core] - compression = 9 - -[diff] - algorithm = patience - tool = vimdiff - -[difftool] - prompt = false - -[fetch] - output = compact - prune = true - -[grep] - extendRegexp = true - lineNumber = true - -[log] - date = local - decorate = short - -[merge] - ff = false - -[pager] - diff = cat - -[pull] - ff = only - -[push] - default = current - -[sendemail] - confirm = compose - smtpServer = DF_SENDMAIL - -[status] - short = true - showUntrackedFiles = all - -[user] - name = DF_NAME - email = DF_EMAIL - signingKey = DF_KEY diff --git a/git/gitconfig.m4.mi5 b/git/gitconfig.m4.mi5 new file mode 100644 index 00000000..bce64d6c --- /dev/null +++ b/git/gitconfig.m4.mi5 @@ -0,0 +1,64 @@ +[advice] + statusHints = false + detachedHead = false + implicitIdentity = false + pushUpdateRejected = false + +[alias] + amend = commit --amend + ls = log --oneline + others = ls-files --others --exclude-standard + fuckit = "!git clean -dfx ; git reset --hard" + +[color] + ui = true + +[commit] + status = false + +[core] + compression = 9 + +[diff] + algorithm = patience + tool = vimdiff + +[difftool] + prompt = false + +[fetch] + output = compact + prune = true + +[grep] + extendRegexp = true + lineNumber = true + +[log] + date = local + decorate = short + +[merge] + ff = false + +[pager] + diff = cat + +[pull] + ff = only + +[push] + default = current + +[sendemail] + confirm = compose + smtpServer = <% DF_SENDMAIL %> + +[status] + short = true + showUntrackedFiles = all + +[user] + name = <% DF_NAME %> + email = <% DF_EMAIL %> + signingKey = <% DF_KEY %> diff --git a/gnupg/gpg.conf.m4 b/gnupg/gpg.conf.m4 deleted file mode 100644 index 29534991..00000000 --- a/gnupg/gpg.conf.m4 +++ /dev/null @@ -1,52 +0,0 @@ -# Retrieve certs automatically if possible -auto-key-locate cert pka - -# Prevent boilerplate about needing key decryption, which is handled by the -# agent; the gpg function in my Bash scripts overrides this for certain -# commands where it interferes -batch - -# Use SHA512 as the hash when making key signatures -cert-digest-algo SHA512 - -# Specify the hash algorithms to be used for new keys as available -default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed - -# In the absence of any other recipient, encrypt messages for myself -default-recipient-self - -# Show complete dates and use proper column separation for --with-colon listing mode -fixed-list-mode - -# Use 16-character key IDs as the default 8-character key IDs can be forged -keyid-format 0xlong - -# Use a pool of servers which support HKPS (encrypted key retrieval) -keyserver DF_KEYSERVER - -# Retrieve keys automatically; check the keyserver port cert; use whichever -# server is proffered from the pool -keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=DF_HOME/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem - -# Include trust/validity for UIDs in listings -list-options show-uid-validity - -# Suppress the copyright message -no-greeting - -# Use SHA512 as my message digest, overriding GnuPG's efforts to use the lowest -# common denominator in hashing algorithms -personal-digest-preferences SHA512 - -# Suppress a lot of output; sometimes I add --verbose to undo this -quiet - -# Use the GPG agent for key management and decryption -use-agent - -# Include trust/validity for UIDs when verifying signatures -verify-options pka-lookups show-uid-validity - -# Assume "yes" is the answer to most questions, that is, don't keep asking me -# to confirm something I've asked to be done -yes diff --git a/gnupg/gpg.conf.m4.mi5 b/gnupg/gpg.conf.m4.mi5 new file mode 100644 index 00000000..d8f14c09 --- /dev/null +++ b/gnupg/gpg.conf.m4.mi5 @@ -0,0 +1,52 @@ +# Retrieve certs automatically if possible +auto-key-locate cert pka + +# Prevent boilerplate about needing key decryption, which is handled by the +# agent; the gpg function in my Bash scripts overrides this for certain +# commands where it interferes +batch + +# Use SHA512 as the hash when making key signatures +cert-digest-algo SHA512 + +# Specify the hash algorithms to be used for new keys as available +default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed + +# In the absence of any other recipient, encrypt messages for myself +default-recipient-self + +# Show complete dates and use proper column separation for --with-colon listing mode +fixed-list-mode + +# Use 16-character key IDs as the default 8-character key IDs can be forged +keyid-format 0xlong + +# Use a pool of servers which support HKPS (encrypted key retrieval) +keyserver DF_KEYSERVER + +# Retrieve keys automatically; check the keyserver port cert; use whichever +# server is proffered from the pool +keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% DF_HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem + +# Include trust/validity for UIDs in listings +list-options show-uid-validity + +# Suppress the copyright message +no-greeting + +# Use SHA512 as my message digest, overriding GnuPG's efforts to use the lowest +# common denominator in hashing algorithms +personal-digest-preferences SHA512 + +# Suppress a lot of output; sometimes I add --verbose to undo this +quiet + +# Use the GPG agent for key management and decryption +use-agent + +# Include trust/validity for UIDs when verifying signatures +verify-options pka-lookups show-uid-validity + +# Assume "yes" is the answer to most questions, that is, don't keep asking me +# to confirm something I've asked to be done +yes diff --git a/tmux/tmux.conf.m4 b/tmux/tmux.conf.m4 deleted file mode 100644 index 3a1d2425..00000000 --- a/tmux/tmux.conf.m4 +++ /dev/null @@ -1,130 +0,0 @@ -# Strip out a lot of machine and X11 dependent crap from the initial -# environment -set-environment -gru COLORFGBG -set-environment -gru COLORTERM -set-environment -gru DISPLAY -set-environment -gru SSH_CLIENT -set-environment -gru SSH_CONNECTION -set-environment -gru SSH_TTY -set-environment -gru WINDOWID - -# Otherwise, use the environment we had when we started; don't touch it during -# a session unless I specifically ask -set-option -g update-environment '' - -# Setting this makes each new pane a non-login shell, which suits me better -set-option -g default-command "$SHELL" - -# Expect a 256-color terminal -set-option -g default-terminal 'screen-256color' - -# Change the prefix to ^A rather than the default of ^B, because I'm a godless -# GNU Screen refugee, and also I like using ^B in my shell and in Vim more -unbind-key C-b -set-option -g prefix C-a -bind-key a send-prefix - -# Repeating the prefix switches to the last window and back, a GNU Screen -# feature that's hardwired into my brain now -bind-key C-a last-window - -# Quick ways to kill single windows and the whole server -bind-key '/' confirm-before 'kill-window' -bind-key '\' confirm-before 'kill-server' - -# Slightly more intuitive way to split windows -bind-key '_' split-window -v -bind-key '|' split-window -h - -# Switch to the last active pane -bind-key Tab last-pane - -# Use the vi mode for tmux interaction behaviour in copy and choice modes -set-window-option -g mode-keys vi -bind-key -T copy-mode-vi v send -X begin-selection -bind-key -T copy-mode-vi y send -X copy-selection-and-cancel - -# Detach with Alt-M, no prefix required -bind-key -n M-m detach - -# Vim-like pane resizing -bind-key -r '+' resize-pane -U 5 -bind-key -r '-' resize-pane -D 5 -bind-key -r '<' resize-pane -L 5 -bind-key -r '>' resize-pane -R 5 - -# Vim-like pane switching -bind-key h select-pane -L -bind-key j select-pane -D -bind-key k select-pane -U -bind-key l select-pane -R - -# Join and break panes -bind-key J choose-window "join-pane -h -s '%%'" -bind-key B break-pane -d - -# Select only sessions in the choose-tree menu, not the whole tree of sessions -# and windows, I prefer to drill down -bind-key s choose-session - -# Session title on the left side of the status bar -set-option -g status-left '[#S] ' - -# Username, hostname, and the current date on the right side of the status bar -set-option -g status-right ' [#(whoami)@#H] #(date +"%F %T")' - -# Update the status bar every second -set-option -g status-interval 1 - -# The first window in a session has index 1, rather than 0 -set-option -g base-index 1 - -# Don't worry about timeouts for key combinations, as I don't use Escape as -# meta and prefer things to be snappier -set-option -g escape-time 0 - -# Keep plenty of history -set-option -g history-limit 100000 - -# Don't interfere with my system clipboard -set-option -g set-clipboard off - -# Only force individual windows to the smallest attached terminal size, not -# whole sessions -set-window-option -g aggressive-resize on - -# If I don't set a title on a window, use the program name for the window title -set-window-option -g automatic-rename on - -# However, don't let terminal escape sequences rename my windows -set-window-option -g allow-rename off - -# Window titles are the window index, a colon, the window or command name, and -# any activity or alert indicators -set-window-option -g window-status-format "#I:#W#F" - -# Message dialogs are white on blue -set-option -g message-style "bg=colour18,fg=colour231" - -# Window choosers are white on blue -set-window-option -g mode-style "bg=colour18,fg=colour231" - -# Pane borders are always in the background color -set-option -g pane-border-style "fg=DF_TMUX_BG" -set-option -g pane-active-border-style "fg=DF_TMUX_BG" - -# Inactive windows have slightly washed-out system colours -set-option -g window-style "bg=colour232,fg=colour248" -set-option -g window-active-style "bg=colour0,fg=colour15" - -# The status bar has the defined background and foreground colours -set-option -g status-style "bg=DF_TMUX_BG,fg=DF_TMUX_FG" - -# Titles of windows default to black text with no embellishment -set-window-option -g window-status-style "fg=colour16" - -# The title of the active window is in white rather than black -set-window-option -g window-status-current-style "fg=colour231" - -# A window with a bell has a title with a red background until cleared -set-window-option -g window-status-bell-style "bg=colour9" diff --git a/tmux/tmux.conf.m4.mi5 b/tmux/tmux.conf.m4.mi5 new file mode 100644 index 00000000..76d493c1 --- /dev/null +++ b/tmux/tmux.conf.m4.mi5 @@ -0,0 +1,130 @@ +# Strip out a lot of machine and X11 dependent crap from the initial +# environment +set-environment -gru COLORFGBG +set-environment -gru COLORTERM +set-environment -gru DISPLAY +set-environment -gru SSH_CLIENT +set-environment -gru SSH_CONNECTION +set-environment -gru SSH_TTY +set-environment -gru WINDOWID + +# Otherwise, use the environment we had when we started; don't touch it during +# a session unless I specifically ask +set-option -g update-environment '' + +# Setting this makes each new pane a non-login shell, which suits me better +set-option -g default-command "$SHELL" + +# Expect a 256-color terminal +set-option -g default-terminal 'screen-256color' + +# Change the prefix to ^A rather than the default of ^B, because I'm a godless +# GNU Screen refugee, and also I like using ^B in my shell and in Vim more +unbind-key C-b +set-option -g prefix C-a +bind-key a send-prefix + +# Repeating the prefix switches to the last window and back, a GNU Screen +# feature that's hardwired into my brain now +bind-key C-a last-window + +# Quick ways to kill single windows and the whole server +bind-key '/' confirm-before 'kill-window' +bind-key '\' confirm-before 'kill-server' + +# Slightly more intuitive way to split windows +bind-key '_' split-window -v +bind-key '|' split-window -h + +# Switch to the last active pane +bind-key Tab last-pane + +# Use the vi mode for tmux interaction behaviour in copy and choice modes +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send -X begin-selection +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel + +# Detach with Alt-M, no prefix required +bind-key -n M-m detach + +# Vim-like pane resizing +bind-key -r '+' resize-pane -U 5 +bind-key -r '-' resize-pane -D 5 +bind-key -r '<' resize-pane -L 5 +bind-key -r '>' resize-pane -R 5 + +# Vim-like pane switching +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R + +# Join and break panes +bind-key J choose-window "join-pane -h -s '%%'" +bind-key B break-pane -d + +# Select only sessions in the choose-tree menu, not the whole tree of sessions +# and windows, I prefer to drill down +bind-key s choose-session + +# Session title on the left side of the status bar +set-option -g status-left '[#S] ' + +# Username, hostname, and the current date on the right side of the status bar +set-option -g status-right ' [#(whoami)@#H] #(date +"%F %T")' + +# Update the status bar every second +set-option -g status-interval 1 + +# The first window in a session has index 1, rather than 0 +set-option -g base-index 1 + +# Don't worry about timeouts for key combinations, as I don't use Escape as +# meta and prefer things to be snappier +set-option -g escape-time 0 + +# Keep plenty of history +set-option -g history-limit 100000 + +# Don't interfere with my system clipboard +set-option -g set-clipboard off + +# Only force individual windows to the smallest attached terminal size, not +# whole sessions +set-window-option -g aggressive-resize on + +# If I don't set a title on a window, use the program name for the window title +set-window-option -g automatic-rename on + +# However, don't let terminal escape sequences rename my windows +set-window-option -g allow-rename off + +# Window titles are the window index, a colon, the window or command name, and +# any activity or alert indicators +set-window-option -g window-status-format "#I:#W#F" + +# Message dialogs are white on blue +set-option -g message-style "bg=colour18,fg=colour231" + +# Window choosers are white on blue +set-window-option -g mode-style "bg=colour18,fg=colour231" + +# Pane borders are always in the background color +set-option -g pane-border-style "fg=<% DF_TMUX_BG %>" +set-option -g pane-active-border-style "fg=<% DF_TMUX_BG %>" + +# Inactive windows have slightly washed-out system colours +set-option -g window-style "bg=colour232,fg=colour248" +set-option -g window-active-style "bg=colour0,fg=colour15" + +# The status bar has the defined background and foreground colours +set-option -g status-style "bg=<% DF_TMUX_BG %>,fg=<% DF_TMUX_FG %>" + +# Titles of windows default to black text with no embellishment +set-window-option -g window-status-style "fg=colour16" + +# The title of the active window is in white rather than black +set-window-option -g window-status-current-style "fg=colour231" + +# A window with a bell has a title with a red background until cleared +set-window-option -g window-status-bell-style "bg=colour9" -- cgit v1.2.3 From 78e2ead680d0f35aa1dd70de91f28932284b3664 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 20:48:15 +1200 Subject: Correct some terms in man mi5(1df) --- man/man1/mi5.1df | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index dd215d0c..b56bed93 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -22,7 +22,7 @@ covers almost every usage case for the author. It's written to work with any POSIX m4. .P mi5 inverts m4's usual approach by approaching most of the file as if it were -part of an m4 comment, with <% and %> as the delimiters to specify markers in +part of an m4 quote, with <% and %> as the delimiters to specify markers in which macro expansion should occur. This makes m4 work in a way reminiscent of templating libraries or languages like PHP. .P @@ -50,10 +50,10 @@ very simple macro expansion in an mi5 inline. .SH CAVEATS Only very simple macro expansions work in inline calls at the moment. This can be fixed by the author tokenizing the line properly, which he'll do Real Soon -Now (TM). Specifically, neither comment delimiters nor macro parameters work. +Now (TM). Specifically, neither quote delimiters nor macro parameters work. The latter is because of a nasty corner-case in m4 where parameter expansions $1, $2, $*, etc are expanded -.B even within comments, +.B even within quotes, one of m4's darkest corners. The workaround is to do as much logic as you can in a block, defining your result as a single simple macros, and then expanding that inline. -- cgit v1.2.3 From bc1d5fb28841f6050605e93886685b3a02e7787a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 22:07:52 +1200 Subject: Use mi5 to make templated shell scripts --- .gitignore | 21 +++++++- Makefile | 77 ++++++++++++++++++++---------- bin/chn.mi5 | 57 ++++++++++++++++++++++ bin/chn.sh | 69 --------------------------- bin/edda.mi5 | 21 ++++++++ bin/edda.sh | 33 ------------- bin/pst.mi5 | 19 ++++++++ bin/pst.sh | 32 ------------- bin/rndl.mi5 | 38 +++++++++++++++ bin/rndl.sh | 50 ------------------- bin/swr.mi5 | 52 ++++++++++++++++++++ bin/swr.sh | 64 ------------------------- bin/tlcs.mi5 | 81 +++++++++++++++++++++++++++++++ bin/tlcs.sh | 93 ------------------------------------ bin/try.mi5 | 65 +++++++++++++++++++++++++ bin/try.sh | 77 ------------------------------ bin/urlc.mi5 | 64 +++++++++++++++++++++++++ bin/urlc.sh | 76 ----------------------------- git/gitconfig.m4.mi5 | 64 ------------------------- git/gitconfig.mi5 | 64 +++++++++++++++++++++++++ gnupg/gpg.conf.m4.mi5 | 52 -------------------- gnupg/gpg.conf.mi5 | 52 ++++++++++++++++++++ include/mktd.mi5 | 15 ++++++ tmux/tmux.conf.m4.mi5 | 130 -------------------------------------------------- tmux/tmux.conf.mi5 | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 25 files changed, 730 insertions(+), 766 deletions(-) create mode 100644 bin/chn.mi5 delete mode 100644 bin/chn.sh create mode 100644 bin/edda.mi5 delete mode 100644 bin/edda.sh create mode 100644 bin/pst.mi5 delete mode 100644 bin/pst.sh create mode 100644 bin/rndl.mi5 delete mode 100644 bin/rndl.sh create mode 100644 bin/swr.mi5 delete mode 100644 bin/swr.sh create mode 100644 bin/tlcs.mi5 delete mode 100644 bin/tlcs.sh create mode 100644 bin/try.mi5 delete mode 100644 bin/try.sh create mode 100644 bin/urlc.mi5 delete mode 100644 bin/urlc.sh delete mode 100644 git/gitconfig.m4.mi5 create mode 100644 git/gitconfig.mi5 delete mode 100644 gnupg/gpg.conf.m4.mi5 create mode 100644 gnupg/gpg.conf.mi5 create mode 100644 include/mktd.mi5 delete mode 100644 tmux/tmux.conf.m4.mi5 create mode 100644 tmux/tmux.conf.mi5 diff --git a/.gitignore b/.gitignore index 873b60a1..153d2227 100644 --- a/.gitignore +++ b/.gitignore @@ -12,16 +12,20 @@ bin/cf bin/cfr bin/chc bin/chn +bin/chn.sh +bin/chn.m4 bin/clog bin/clrd bin/clwr bin/csmw -bin/dam bin/d2u +bin/dam bin/ddup bin/dmp bin/dub bin/edda +bin/edda.sh +bin/edda.m4 bin/eds bin/exm bin/fgscr @@ -46,13 +50,13 @@ bin/jfc bin/jfcd bin/jfp bin/loc -bin/mi5 bin/max bin/maybe bin/mean bin/med bin/mex bin/mftl +bin/mi5 bin/min bin/mkcp bin/mkmv @@ -73,6 +77,8 @@ bin/plmu bin/pp bin/pph bin/pst +bin/pst.sh +bin/pst.m4 bin/pvi bin/pwg bin/quo @@ -84,6 +90,8 @@ bin/rnda bin/rndf bin/rndi bin/rndl +bin/rndl.sh +bin/rndl.m4 bin/rnds bin/sd2u bin/sec @@ -102,17 +110,25 @@ bin/su2d bin/sue bin/supp bin/swr +bin/swr.sh +bin/swr.m4 bin/td bin/tl bin/tlcs +bin/tlcs.sh +bin/tlcs.m4 bin/tm bin/tot bin/trs bin/try +bin/try.sh +bin/try.m4 bin/u2d bin/umake bin/unf bin/urlc +bin/urlc.sh +bin/urlc.m4 bin/urlh bin/urlmt bin/uts @@ -140,6 +156,7 @@ git/gitconfig git/gitconfig.m4 gnupg/gpg.conf gnupg/gpg.conf.m4 +include/mktd.m4 man/man7/dotfiles.7df tmux/tmux.conf tmux/tmux.conf.m4 diff --git a/Makefile b/Makefile index 11bcf6f0..8f278325 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ lint-xinit .SUFFIXES: -.SUFFIXES: .awk .bash .mi5 .pl .sed .sh +.SUFFIXES: .awk .bash .m4 .mi5 .pl .sed .sh NAME = 'Tom Ryder' EMAIL = tom@sanctum.geek.nz @@ -217,15 +217,67 @@ clean distclean: rm -f -- \ $(BINS) \ $(GAMES) \ + bin/chn.sh \ + bin/chn.m4 \ + bin/edda.sh \ + bin/edda.m4 \ + bin/pst.sh \ + bin/pst.m4 \ + bin/rndl.sh \ + bin/rndl.m4 \ + bin/swr.sh \ + bin/swr.m4 \ + bin/tlcs.sh \ + bin/tlcs.m4 \ + bin/try.sh \ + bin/try.m4 \ + bin/urlc.sh \ + bin/urlc.m4 \ git/gitconfig \ git/gitconfig.m4 \ gnupg/gpg.conf \ gnupg/gpg.conf.m4 \ + include/mktd.m4 \ man/man8/dotfiles.7df \ tmux/tmux.conf \ tmux/tmux.conf.m4 \ urxvt/ext/select +.awk: + sh bin/shb.sh awk -f < $< > $@ + chmod +x ./$@ + +.bash: + sh bin/shb.sh bash < $< > $@ + chmod +x ./$@ + +.pl: + sh bin/shb.sh perl < $< > $@ + chmod +x ./$@ + +.sed: + sh bin/shb.sh sed -f < $< > $@ + chmod +x ./$@ + +.sh: + sh bin/shb.sh sh < $< > $@ + chmod +x ./$@ + +.mi5.m4: + awk -f bin/mi5.awk < $< > $@ + +.m4.sh: + m4 < $< > $@ + +bin/chn.sh: include/mktd.m4 +bin/edda.sh: include/mktd.m4 +bin/pst.sh: include/mktd.m4 +bin/rndl.sh: include/mktd.m4 +bin/swr.sh: include/mktd.m4 +bin/tlcs.sh: include/mktd.m4 +bin/try.sh: include/mktd.m4 +bin/urlc.sh: include/mktd.m4 + git/gitconfig: git/gitconfig.m4 m4 \ -D DF_NAME=$(NAME) \ @@ -253,29 +305,6 @@ tmux/tmux.conf: tmux/tmux.conf.m4 m4 -D DF_TMUX_BG=$(TMUX_BG) -D DF_TMUX_FG=$(TMUX_FG) \ tmux/tmux.conf.m4 > $@ -.awk: - sh bin/shb.sh awk -f < $< > $@ - chmod +x ./$@ - -.bash: - sh bin/shb.sh bash < $< > $@ - chmod +x ./$@ - -.pl: - sh bin/shb.sh perl < $< > $@ - chmod +x ./$@ - -.sed: - sh bin/shb.sh sed -f < $< > $@ - chmod +x ./$@ - -.sh: - sh bin/shb.sh sh < $< > $@ - chmod +x ./$@ - -.mi5: - awk -f bin/mi5.awk < $< > $@ - install: install-bin \ install-curl \ install-ex \ diff --git a/bin/chn.mi5 b/bin/chn.mi5 new file mode 100644 index 00000000..dfc1000c --- /dev/null +++ b/bin/chn.mi5 @@ -0,0 +1,57 @@ +# Repeat a command to filter input several times +self=chn + +# Check arguments. +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need a count and a program name\n' "$self" + exit 2 +fi + +# Shift off the repetition count. +c=$1 +shift + +# Check the repetition count looks sane. Zero is fine! +if [ "$c" -lt 0 ] ; then + printf >&2 '%s: Nonsensical negative count\n' "$self" + exit 2 +fi + +# If the count is zero, just run the input straight through! +if [ "$c" -eq 0 ] ; then + cat + exit +fi + +<% +include(`include/mktd.m4') +%> + +# Define and create input and output files +if=$td/if of=$td/of +touch -- "$if" "$of" + +# Iterate through the count +while [ "${n=1}" -le "$c" ] ; do + + # Start a subshell so we can deal with FDs cleanly + ( + # If this isn't the first iteration, our input comes from $if + [ "$n" -eq 1 ] || + exec <"$if" + + # If this isn't the last iteration, our output goes to $of + [ "$n" -eq "$c" ] || + exec >"$of" + + # Run the command with the descriptors above; if the command fails, the + # subshell will exit, which will in turn exit the program + "$@" + ) || exit + + # Copy the output file over the input one + cp -- "$of" "$if" + + # Increment the counter for the next while loop run + n=$((n+1)) +done diff --git a/bin/chn.sh b/bin/chn.sh deleted file mode 100644 index 9103dd07..00000000 --- a/bin/chn.sh +++ /dev/null @@ -1,69 +0,0 @@ -# Repeat a command to filter input several times -self=chn - -# Check arguments. -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need a count and a program name\n' "$self" - exit 2 -fi - -# Shift off the repetition count. -c=$1 -shift - -# Check the repetition count looks sane. Zero is fine! -if [ "$c" -lt 0 ] ; then - printf >&2 '%s: Nonsensical negative count\n' "$self" - exit 2 -fi - -# If the count is zero, just run the input straight through! -if [ "$c" -eq 0 ] ; then - cat - exit -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Define and create input and output files -if=$td/if of=$td/of -touch -- "$if" "$of" - -# Iterate through the count -while [ "${n=1}" -le "$c" ] ; do - - # Start a subshell so we can deal with FDs cleanly - ( - # If this isn't the first iteration, our input comes from $if - [ "$n" -eq 1 ] || - exec <"$if" - - # If this isn't the last iteration, our output goes to $of - [ "$n" -eq "$c" ] || - exec >"$of" - - # Run the command with the descriptors above; if the command fails, the - # subshell will exit, which will in turn exit the program - "$@" - ) || exit - - # Copy the output file over the input one - cp -- "$of" "$if" - - # Increment the counter for the next while loop run - n=$((n+1)) -done diff --git a/bin/edda.mi5 b/bin/edda.mi5 new file mode 100644 index 00000000..aaf974cf --- /dev/null +++ b/bin/edda.mi5 @@ -0,0 +1,21 @@ +# Run ed(1) over multiple files, duplicating stdin. +self=edda + +# Need at least one file +if [ "$#" -eq 0 ] ; then + printf >&2 'edda: Need at least one file\n' + exit 2 +fi + +<% +include(`include/mktd.m4') +%> + +# Duplicate stdin into a file +script=$td/script +cat >"$script" || exit + +# Run ed(1) over each file with the stdin given +for file ; do + ed -- "$file" <"$script" +done diff --git a/bin/edda.sh b/bin/edda.sh deleted file mode 100644 index b1d7b27a..00000000 --- a/bin/edda.sh +++ /dev/null @@ -1,33 +0,0 @@ -# Run ed(1) over multiple files, duplicating stdin. -self=edda - -# Need at least one file -if [ "$#" -eq 0 ] ; then - printf >&2 'edda: Need at least one file\n' - exit 2 -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Duplicate stdin into a file -script=$td/script -cat >"$script" || exit - -# Run ed(1) over each file with the stdin given -for file ; do - ed -- "$file" <"$script" -done diff --git a/bin/pst.mi5 b/bin/pst.mi5 new file mode 100644 index 00000000..34ffbd8c --- /dev/null +++ b/bin/pst.mi5 @@ -0,0 +1,19 @@ +# Interrupt a pipe with manual /dev/tty input to a program +self=pst + +# Don't accept terminal as stdin +if [ -t 0 ] ; then + printf >&2 '%s: stdin is a term\n' "$self" + exit 2 +fi + +<% +include(`include/mktd.m4') +%> + +# Run the interactive command on the temporary file forcing /dev/tty as +# input/output +tf=$td/data +cat - > "$tf" || exit +"${@:-"${PAGER:-more}"}" "$tf" /dev/tty +cat -- "$tf" || exit diff --git a/bin/pst.sh b/bin/pst.sh deleted file mode 100644 index fdea9884..00000000 --- a/bin/pst.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Interrupt a pipe with manual /dev/tty input to a program -self=pst - -# Don't accept terminal as stdin -if [ -t 0 ] ; then - printf >&2 '%s: stdin is a term\n' "$self" - exit 2 -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Run the interactive command on the temporary file forcing /dev/tty as -# input/output -tf=$td/data -cat - > "$tf" || exit -"${@:-"${PAGER:-more}"}" "$tf" /dev/tty -cat -- "$tf" || exit diff --git a/bin/rndl.mi5 b/bin/rndl.mi5 new file mode 100644 index 00000000..f99ccbea --- /dev/null +++ b/bin/rndl.mi5 @@ -0,0 +1,38 @@ +# Print a random line from input +self=rndl + +# If there are no arguments, we're checking stdin; this is more complicated +# than checking file arguments because we have to count the lines in order to +# correctly choose a random one, and two passes means we require a temporary +# file if we don't want to read all of the input into memory (!) +if [ "$#" -eq 0 ] ; then + +<% +include(`include/mktd.m4') +%> + + # We'll operate on stdin in the temp directory; write the script's stdin to + # it with cat(1) + set -- "$td"/stdin + cat >"$td"/stdin +fi + +# Count the number of lines in the input +lc=$(sed -- '$=;d' "$@") || exit + +# If there were none, bail +case $lc in + ''|0) + printf >&2 'rndl: No lines found on input\n' + exit 2 + ;; +esac + +# Try to get a random seed from rnds(1df) for rndi(1df) +seed=$(rnds) + +# Get a random line number from rndi(1df) +ri=$(rndi 1 "$lc" "$seed") || exit + +# Print the line using sed(1) +sed -- "$ri"'!d' "$@" diff --git a/bin/rndl.sh b/bin/rndl.sh deleted file mode 100644 index 18bcec07..00000000 --- a/bin/rndl.sh +++ /dev/null @@ -1,50 +0,0 @@ -# Print a random line from input -self=rndl - -# If there are no arguments, we're checking stdin; this is more complicated -# than checking file arguments because we have to count the lines in order to -# correctly choose a random one, and two passes means we require a temporary -# file if we don't want to read all of the input into memory (!) -if [ "$#" -eq 0 ] ; then - - # Create a temporary directory with name in $td, and handle POSIX-ish traps to - # remove it when the script exits. - td= - cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi - } - for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" - done - td=$(mktd "$self") || exit - - # We'll operate on stdin in the temp directory; write the script's stdin to - # it with cat(1) - set -- "$td"/stdin - cat >"$td"/stdin -fi - -# Count the number of lines in the input -lc=$(sed -- '$=;d' "$@") || exit - -# If there were none, bail -case $lc in - ''|0) - printf >&2 'rndl: No lines found on input\n' - exit 2 - ;; -esac - -# Try to get a random seed from rnds(1df) for rndi(1df) -seed=$(rnds) - -# Get a random line number from rndi(1df) -ri=$(rndi 1 "$lc" "$seed") || exit - -# Print the line using sed(1) -sed -- "$ri"'!d' "$@" diff --git a/bin/swr.mi5 b/bin/swr.mi5 new file mode 100644 index 00000000..9b73b6d6 --- /dev/null +++ b/bin/swr.mi5 @@ -0,0 +1,52 @@ +# Transparently wrap scp(1) targets to read (not write) on the command line +self=swr + +<% +include(`include/mktd.m4') +%> + +# Set a flag to manage resetting the positional parameters at the start of the +# loop +n=1 +for arg ; do + + # If this is our first iteration, reset the shell parameters + case $n in + 1) set -- ;; + esac + + # Test whether this argument looks like a remote file + if ( + + # Test it contains a colon + case $arg in + *:*) ;; + *) exit 1 ;; + esac + + # Test the part before the first colon has at least one character and + # only hostname characters + case ${arg%%:*} in + '') exit 1 ;; + *[!a-zA-Z0-9-.]*) exit 1 ;; + esac + + ) ; then + + # Looks like a remote file request; try to copy it into the temporary + # directory, bail out completely if we can't + dst=$td/$n + scp -q -- "$arg" "$dst" || exit + set -- "$@" "$dst" + + else + # Just a plain old argument; stack it up + set -- "$@" "$arg" + fi + + # Bump n + n=$((n+1)) +done + +# Run the command with the processed arguments +exec "$@" diff --git a/bin/swr.sh b/bin/swr.sh deleted file mode 100644 index 5bad63ae..00000000 --- a/bin/swr.sh +++ /dev/null @@ -1,64 +0,0 @@ -# Transparently wrap scp(1) targets to read (not write) on the command line -self=swr - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Set a flag to manage resetting the positional parameters at the start of the -# loop -n=1 -for arg ; do - - # If this is our first iteration, reset the shell parameters - case $n in - 1) set -- ;; - esac - - # Test whether this argument looks like a remote file - if ( - - # Test it contains a colon - case $arg in - *:*) ;; - *) exit 1 ;; - esac - - # Test the part before the first colon has at least one character and - # only hostname characters - case ${arg%%:*} in - '') exit 1 ;; - *[!a-zA-Z0-9-.]*) exit 1 ;; - esac - - ) ; then - - # Looks like a remote file request; try to copy it into the temporary - # directory, bail out completely if we can't - dst=$td/$n - scp -q -- "$arg" "$dst" || exit - set -- "$@" "$dst" - - else - # Just a plain old argument; stack it up - set -- "$@" "$arg" - fi - - # Bump n - n=$((n+1)) -done - -# Run the command with the processed arguments -exec "$@" diff --git a/bin/tlcs.mi5 b/bin/tlcs.mi5 new file mode 100644 index 00000000..a3e17c82 --- /dev/null +++ b/bin/tlcs.mi5 @@ -0,0 +1,81 @@ +# Execute a command and tag the output of the stdout and stderr streams. +self=tlcs + +# Set the default prefixes and suffixes for stdout/err +out_pref='stdout: ' +err_pref='stderr: ' +out_suff= +err_suff= + +# Parse options out, give help if necessary +while getopts 'co:e:' opt ; do + case $opt in + c) + color=1 + ;; + o) + out_pref=$OPTARG + ;; + e) + err_pref=$OPTARG + ;; + \?) + printf >&2 'Unknown option %s\n' "$opt" + exit 2 + ;; + esac +done +shift "$((OPTIND-1))" + +# We need at least one more argument +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a command to run\n' "$self" + exit 2 +fi + +# If color was requested for the output, try and get a count of available +# colors; otherwise default to zero +[ -n "$color" ] && color_count=$( { + tput colors || tput Co +} 2>/dev/null ) +: "${color_count:=0}" + +# If the color count is 8 or greater, we'll color the output +if [ "$((color_count >= 8))" -eq 1 ] ; then + + # Color code for resetting + color_reset=$( { + tput me || tput sgr0 + } 2>/dev/null ) + + # If stdout is a terminal, color it + if [ -t 1 ] ; then + color_stdout=$( { + tput AF 2 || tput setaf 2 + } 2>/dev/null ) + out_pref=${color_stdout}${out_pref} + out_suff=${out_suff}${color_reset} + fi + + # If stderr is a terminal, color it + if [ -t 2 ] ; then + color_stderr=$( { + tput AF 1 || tput setaf 1 + } 2>/dev/null ) + err_pref=${color_stderr}${err_pref} + out_suff=${err_suff}${color_reset} + fi +fi + +<% +include(`include/mktd.m4') +%> + +# Execute the command, passing stdout and stderr to tl(1df) calls as appropriate +# via named pipes +out=$td/out err=$td/err +mkfifo -- "$out" "$err" || exit +tl -p "$out_pref" -s "$out_suff" < "$out" & +tl -p "$err_pref" -s "$err_suff" < "$err" & +"$@" >"$out" 2>"$err" +ex=$? ; wait ; exit "$ex" diff --git a/bin/tlcs.sh b/bin/tlcs.sh deleted file mode 100644 index f20b160e..00000000 --- a/bin/tlcs.sh +++ /dev/null @@ -1,93 +0,0 @@ -# Execute a command and tag the output of the stdout and stderr streams. -self=tlcs - -# Set the default prefixes and suffixes for stdout/err -out_pref='stdout: ' -err_pref='stderr: ' -out_suff= -err_suff= - -# Parse options out, give help if necessary -while getopts 'co:e:' opt ; do - case $opt in - c) - color=1 - ;; - o) - out_pref=$OPTARG - ;; - e) - err_pref=$OPTARG - ;; - \?) - printf >&2 'Unknown option %s\n' "$opt" - exit 2 - ;; - esac -done -shift "$((OPTIND-1))" - -# We need at least one more argument -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need a command to run\n' "$self" - exit 2 -fi - -# If color was requested for the output, try and get a count of available -# colors; otherwise default to zero -[ -n "$color" ] && color_count=$( { - tput colors || tput Co -} 2>/dev/null ) -: "${color_count:=0}" - -# If the color count is 8 or greater, we'll color the output -if [ "$((color_count >= 8))" -eq 1 ] ; then - - # Color code for resetting - color_reset=$( { - tput me || tput sgr0 - } 2>/dev/null ) - - # If stdout is a terminal, color it - if [ -t 1 ] ; then - color_stdout=$( { - tput AF 2 || tput setaf 2 - } 2>/dev/null ) - out_pref=${color_stdout}${out_pref} - out_suff=${out_suff}${color_reset} - fi - - # If stderr is a terminal, color it - if [ -t 2 ] ; then - color_stderr=$( { - tput AF 1 || tput setaf 1 - } 2>/dev/null ) - err_pref=${color_stderr}${err_pref} - out_suff=${err_suff}${color_reset} - fi -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Execute the command, passing stdout and stderr to tl(1df) calls as appropriate -# via named pipes -out=$td/out err=$td/err -mkfifo -- "$out" "$err" || exit -tl -p "$out_pref" -s "$out_suff" < "$out" & -tl -p "$err_pref" -s "$err_suff" < "$err" & -"$@" >"$out" 2>"$err" -ex=$? ; wait ; exit "$ex" diff --git a/bin/try.mi5 b/bin/try.mi5 new file mode 100644 index 00000000..ea39d717 --- /dev/null +++ b/bin/try.mi5 @@ -0,0 +1,65 @@ +# Attempt a certain number of times to perform a task, buffer stderr unless and +# until all command attempts fail +self=try + +# Parse options +while getopts 's:n:' opt ; do + case $opt in + n) + attn=$OPTARG + ;; + s) + sleep=$OPTARG + ;; + \?) + printf >&2 '%s: Unknown option\n' "$self" + exit 2 + ;; + esac +done +shift "$((OPTIND-1))" + +# Check we have at least one argument left (the command to run) +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a command to run\n' "$self" + exit 2 +fi + +<% +include(`include/mktd.m4') +%> + +# Open a filehandle to the error buffer, just to save on file operations +errbuff=$td/errbuff +exec 3>"$errbuff" + +# Keep trying the command, writing error output to the buffer file, and exit +# if we succeed on any of them +attc=1 +: "${attn:=3}" "${sleep:=0}" +while [ "$attc" -le "$attn" ] ; do + + # Try running the command; if it succeeds, we're done, and any previous + # failures get their errors discarded + if "$@" 2>&3 ; then + exit + + # If the command failed, record the exit value + else + ex=$? + fi + + # If this isn't the last run, have a sleep + if [ "$attc" -lt "$attn" ] ; then + sleep "${sleep:=0}" + fi + + # Increment the attempt count + attc=$((attc + 1)) +done + +# Attempts were exhausted, and all failed; print the error output from all of +# the failures and exit with the non-zero exit value of the most recent one +exec 3>&- +cat -- "$td"/errbuff >&2 +exit "$ex" diff --git a/bin/try.sh b/bin/try.sh deleted file mode 100644 index 20ccbe5f..00000000 --- a/bin/try.sh +++ /dev/null @@ -1,77 +0,0 @@ -# Attempt a certain number of times to perform a task, buffer stderr unless and -# until all command attempts fail -self=try - -# Parse options -while getopts 's:n:' opt ; do - case $opt in - n) - attn=$OPTARG - ;; - s) - sleep=$OPTARG - ;; - \?) - printf >&2 '%s: Unknown option\n' "$self" - exit 2 - ;; - esac -done -shift "$((OPTIND-1))" - -# Check we have at least one argument left (the command to run) -if [ "$#" -eq 0 ] ; then - printf >&2 '%s: Need a command to run\n' "$self" - exit 2 -fi - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Open a filehandle to the error buffer, just to save on file operations -errbuff=$td/errbuff -exec 3>"$errbuff" - -# Keep trying the command, writing error output to the buffer file, and exit -# if we succeed on any of them -attc=1 -: "${attn:=3}" "${sleep:=0}" -while [ "$attc" -le "$attn" ] ; do - - # Try running the command; if it succeeds, we're done, and any previous - # failures get their errors discarded - if "$@" 2>&3 ; then - exit - - # If the command failed, record the exit value - else - ex=$? - fi - - # If this isn't the last run, have a sleep - if [ "$attc" -lt "$attn" ] ; then - sleep "${sleep:=0}" - fi - - # Increment the attempt count - attc=$((attc + 1)) -done - -# Attempts were exhausted, and all failed; print the error output from all of -# the failures and exit with the non-zero exit value of the most recent one -exec 3>&- -cat -- "$td"/errbuff >&2 -exit "$ex" diff --git a/bin/urlc.mi5 b/bin/urlc.mi5 new file mode 100644 index 00000000..55dac171 --- /dev/null +++ b/bin/urlc.mi5 @@ -0,0 +1,64 @@ +# Try to find erroneous or insecure URLs +self=urlc + +# cURL request timeout +tm=${URLCHECK_TIMEOUT:-8} + +<% +include(`include/mktd.m4') +%> + +# Create buffer files for the headers and body content, to be cleaned up on +# exit +list=$td/list head=$td/head body=$td/body + +# Iterate through input; ignore leading/trailing whitespace +cat -- "${@:--}" >"$list" +while read -r url ; do + + # Skip anything that doesn't start with HTTP + case $url in + http*) ;; + *) continue ;; + esac + + # Make initial request, log head and body to files, cry and skip on error + if ! curl -A Mozilla -fHLsS -D "$head" -m "$tm" -o "$body" -- \ + "$url" ; then + printf >&2 '%s: %s raises error\n' \ + "$self" "$url" + ex=1 + continue + fi + + # Iterate through header file, cry about the first redirect we find + while IFS=': ' read -r header value ; do + [ "$header" = 'Location' ] || continue + printf >&2 '%s: %s redirects to %s\n' \ + "$self" "$url" "$value" >&2 + ex=1 + break + done < "$head" + + # Skip anything that's already secure + case $url in + https*) continue ;; + *) ;; + esac + + # Form a naïve attempt at a possible secure URL and try to request it, + # point it out if it actually works + surl=https://${url#http://} + if curl -A Mozilla -fLsS -D "$head" -m "$tm" -o "$body" -- \ + "$surl" 2>/dev/null ; then + printf >&2 '%s: %s has a working secure version at %s\n' \ + "$self" "$url" "$surl" + ex=1 + fi +done <"$list" + +# Wait for the input process to finish +wait + +# Exit if any errors +exit "${ex:-0}" diff --git a/bin/urlc.sh b/bin/urlc.sh deleted file mode 100644 index 0e6530fa..00000000 --- a/bin/urlc.sh +++ /dev/null @@ -1,76 +0,0 @@ -# Try to find erroneous or insecure URLs -self=urlc - -# cURL request timeout -tm=${URLCHECK_TIMEOUT:-8} - -# Create a temporary directory with name in $td, and handle POSIX-ish traps to -# remove it when the script exits. -td= -cleanup() { - [ -n "$td" ] && rm -fr -- "$td" - if [ "$1" != EXIT ] ; then - trap - "$1" - kill "-$1" "$$" - fi -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done -td=$(mktd "$self") || exit - -# Create buffer files for the headers and body content, to be cleaned up on -# exit -list=$td/list head=$td/head body=$td/body - -# Iterate through input; ignore leading/trailing whitespace -cat -- "${@:--}" >"$list" -while read -r url ; do - - # Skip anything that doesn't start with HTTP - case $url in - http*) ;; - *) continue ;; - esac - - # Make initial request, log head and body to files, cry and skip on error - if ! curl -A Mozilla -fHLsS -D "$head" -m "$tm" -o "$body" -- \ - "$url" ; then - printf >&2 '%s: %s raises error\n' \ - "$self" "$url" - ex=1 - continue - fi - - # Iterate through header file, cry about the first redirect we find - while IFS=': ' read -r header value ; do - [ "$header" = 'Location' ] || continue - printf >&2 '%s: %s redirects to %s\n' \ - "$self" "$url" "$value" >&2 - ex=1 - break - done < "$head" - - # Skip anything that's already secure - case $url in - https*) continue ;; - *) ;; - esac - - # Form a naïve attempt at a possible secure URL and try to request it, - # point it out if it actually works - surl=https://${url#http://} - if curl -A Mozilla -fLsS -D "$head" -m "$tm" -o "$body" -- \ - "$surl" 2>/dev/null ; then - printf >&2 '%s: %s has a working secure version at %s\n' \ - "$self" "$url" "$surl" - ex=1 - fi -done <"$list" - -# Wait for the input process to finish -wait - -# Exit if any errors -exit "${ex:-0}" diff --git a/git/gitconfig.m4.mi5 b/git/gitconfig.m4.mi5 deleted file mode 100644 index bce64d6c..00000000 --- a/git/gitconfig.m4.mi5 +++ /dev/null @@ -1,64 +0,0 @@ -[advice] - statusHints = false - detachedHead = false - implicitIdentity = false - pushUpdateRejected = false - -[alias] - amend = commit --amend - ls = log --oneline - others = ls-files --others --exclude-standard - fuckit = "!git clean -dfx ; git reset --hard" - -[color] - ui = true - -[commit] - status = false - -[core] - compression = 9 - -[diff] - algorithm = patience - tool = vimdiff - -[difftool] - prompt = false - -[fetch] - output = compact - prune = true - -[grep] - extendRegexp = true - lineNumber = true - -[log] - date = local - decorate = short - -[merge] - ff = false - -[pager] - diff = cat - -[pull] - ff = only - -[push] - default = current - -[sendemail] - confirm = compose - smtpServer = <% DF_SENDMAIL %> - -[status] - short = true - showUntrackedFiles = all - -[user] - name = <% DF_NAME %> - email = <% DF_EMAIL %> - signingKey = <% DF_KEY %> diff --git a/git/gitconfig.mi5 b/git/gitconfig.mi5 new file mode 100644 index 00000000..bce64d6c --- /dev/null +++ b/git/gitconfig.mi5 @@ -0,0 +1,64 @@ +[advice] + statusHints = false + detachedHead = false + implicitIdentity = false + pushUpdateRejected = false + +[alias] + amend = commit --amend + ls = log --oneline + others = ls-files --others --exclude-standard + fuckit = "!git clean -dfx ; git reset --hard" + +[color] + ui = true + +[commit] + status = false + +[core] + compression = 9 + +[diff] + algorithm = patience + tool = vimdiff + +[difftool] + prompt = false + +[fetch] + output = compact + prune = true + +[grep] + extendRegexp = true + lineNumber = true + +[log] + date = local + decorate = short + +[merge] + ff = false + +[pager] + diff = cat + +[pull] + ff = only + +[push] + default = current + +[sendemail] + confirm = compose + smtpServer = <% DF_SENDMAIL %> + +[status] + short = true + showUntrackedFiles = all + +[user] + name = <% DF_NAME %> + email = <% DF_EMAIL %> + signingKey = <% DF_KEY %> diff --git a/gnupg/gpg.conf.m4.mi5 b/gnupg/gpg.conf.m4.mi5 deleted file mode 100644 index d8f14c09..00000000 --- a/gnupg/gpg.conf.m4.mi5 +++ /dev/null @@ -1,52 +0,0 @@ -# Retrieve certs automatically if possible -auto-key-locate cert pka - -# Prevent boilerplate about needing key decryption, which is handled by the -# agent; the gpg function in my Bash scripts overrides this for certain -# commands where it interferes -batch - -# Use SHA512 as the hash when making key signatures -cert-digest-algo SHA512 - -# Specify the hash algorithms to be used for new keys as available -default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed - -# In the absence of any other recipient, encrypt messages for myself -default-recipient-self - -# Show complete dates and use proper column separation for --with-colon listing mode -fixed-list-mode - -# Use 16-character key IDs as the default 8-character key IDs can be forged -keyid-format 0xlong - -# Use a pool of servers which support HKPS (encrypted key retrieval) -keyserver DF_KEYSERVER - -# Retrieve keys automatically; check the keyserver port cert; use whichever -# server is proffered from the pool -keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% DF_HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem - -# Include trust/validity for UIDs in listings -list-options show-uid-validity - -# Suppress the copyright message -no-greeting - -# Use SHA512 as my message digest, overriding GnuPG's efforts to use the lowest -# common denominator in hashing algorithms -personal-digest-preferences SHA512 - -# Suppress a lot of output; sometimes I add --verbose to undo this -quiet - -# Use the GPG agent for key management and decryption -use-agent - -# Include trust/validity for UIDs when verifying signatures -verify-options pka-lookups show-uid-validity - -# Assume "yes" is the answer to most questions, that is, don't keep asking me -# to confirm something I've asked to be done -yes diff --git a/gnupg/gpg.conf.mi5 b/gnupg/gpg.conf.mi5 new file mode 100644 index 00000000..d8f14c09 --- /dev/null +++ b/gnupg/gpg.conf.mi5 @@ -0,0 +1,52 @@ +# Retrieve certs automatically if possible +auto-key-locate cert pka + +# Prevent boilerplate about needing key decryption, which is handled by the +# agent; the gpg function in my Bash scripts overrides this for certain +# commands where it interferes +batch + +# Use SHA512 as the hash when making key signatures +cert-digest-algo SHA512 + +# Specify the hash algorithms to be used for new keys as available +default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed + +# In the absence of any other recipient, encrypt messages for myself +default-recipient-self + +# Show complete dates and use proper column separation for --with-colon listing mode +fixed-list-mode + +# Use 16-character key IDs as the default 8-character key IDs can be forged +keyid-format 0xlong + +# Use a pool of servers which support HKPS (encrypted key retrieval) +keyserver DF_KEYSERVER + +# Retrieve keys automatically; check the keyserver port cert; use whichever +# server is proffered from the pool +keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% DF_HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem + +# Include trust/validity for UIDs in listings +list-options show-uid-validity + +# Suppress the copyright message +no-greeting + +# Use SHA512 as my message digest, overriding GnuPG's efforts to use the lowest +# common denominator in hashing algorithms +personal-digest-preferences SHA512 + +# Suppress a lot of output; sometimes I add --verbose to undo this +quiet + +# Use the GPG agent for key management and decryption +use-agent + +# Include trust/validity for UIDs when verifying signatures +verify-options pka-lookups show-uid-validity + +# Assume "yes" is the answer to most questions, that is, don't keep asking me +# to confirm something I've asked to be done +yes diff --git a/include/mktd.mi5 b/include/mktd.mi5 new file mode 100644 index 00000000..388eb9be --- /dev/null +++ b/include/mktd.mi5 @@ -0,0 +1,15 @@ +# Create a temporary directory with name in $td, and handle POSIX-ish traps to +# remove it when the script exits. +td= +cleanup() { + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done +td=$(mktd "$self") || exit diff --git a/tmux/tmux.conf.m4.mi5 b/tmux/tmux.conf.m4.mi5 deleted file mode 100644 index 76d493c1..00000000 --- a/tmux/tmux.conf.m4.mi5 +++ /dev/null @@ -1,130 +0,0 @@ -# Strip out a lot of machine and X11 dependent crap from the initial -# environment -set-environment -gru COLORFGBG -set-environment -gru COLORTERM -set-environment -gru DISPLAY -set-environment -gru SSH_CLIENT -set-environment -gru SSH_CONNECTION -set-environment -gru SSH_TTY -set-environment -gru WINDOWID - -# Otherwise, use the environment we had when we started; don't touch it during -# a session unless I specifically ask -set-option -g update-environment '' - -# Setting this makes each new pane a non-login shell, which suits me better -set-option -g default-command "$SHELL" - -# Expect a 256-color terminal -set-option -g default-terminal 'screen-256color' - -# Change the prefix to ^A rather than the default of ^B, because I'm a godless -# GNU Screen refugee, and also I like using ^B in my shell and in Vim more -unbind-key C-b -set-option -g prefix C-a -bind-key a send-prefix - -# Repeating the prefix switches to the last window and back, a GNU Screen -# feature that's hardwired into my brain now -bind-key C-a last-window - -# Quick ways to kill single windows and the whole server -bind-key '/' confirm-before 'kill-window' -bind-key '\' confirm-before 'kill-server' - -# Slightly more intuitive way to split windows -bind-key '_' split-window -v -bind-key '|' split-window -h - -# Switch to the last active pane -bind-key Tab last-pane - -# Use the vi mode for tmux interaction behaviour in copy and choice modes -set-window-option -g mode-keys vi -bind-key -T copy-mode-vi v send -X begin-selection -bind-key -T copy-mode-vi y send -X copy-selection-and-cancel - -# Detach with Alt-M, no prefix required -bind-key -n M-m detach - -# Vim-like pane resizing -bind-key -r '+' resize-pane -U 5 -bind-key -r '-' resize-pane -D 5 -bind-key -r '<' resize-pane -L 5 -bind-key -r '>' resize-pane -R 5 - -# Vim-like pane switching -bind-key h select-pane -L -bind-key j select-pane -D -bind-key k select-pane -U -bind-key l select-pane -R - -# Join and break panes -bind-key J choose-window "join-pane -h -s '%%'" -bind-key B break-pane -d - -# Select only sessions in the choose-tree menu, not the whole tree of sessions -# and windows, I prefer to drill down -bind-key s choose-session - -# Session title on the left side of the status bar -set-option -g status-left '[#S] ' - -# Username, hostname, and the current date on the right side of the status bar -set-option -g status-right ' [#(whoami)@#H] #(date +"%F %T")' - -# Update the status bar every second -set-option -g status-interval 1 - -# The first window in a session has index 1, rather than 0 -set-option -g base-index 1 - -# Don't worry about timeouts for key combinations, as I don't use Escape as -# meta and prefer things to be snappier -set-option -g escape-time 0 - -# Keep plenty of history -set-option -g history-limit 100000 - -# Don't interfere with my system clipboard -set-option -g set-clipboard off - -# Only force individual windows to the smallest attached terminal size, not -# whole sessions -set-window-option -g aggressive-resize on - -# If I don't set a title on a window, use the program name for the window title -set-window-option -g automatic-rename on - -# However, don't let terminal escape sequences rename my windows -set-window-option -g allow-rename off - -# Window titles are the window index, a colon, the window or command name, and -# any activity or alert indicators -set-window-option -g window-status-format "#I:#W#F" - -# Message dialogs are white on blue -set-option -g message-style "bg=colour18,fg=colour231" - -# Window choosers are white on blue -set-window-option -g mode-style "bg=colour18,fg=colour231" - -# Pane borders are always in the background color -set-option -g pane-border-style "fg=<% DF_TMUX_BG %>" -set-option -g pane-active-border-style "fg=<% DF_TMUX_BG %>" - -# Inactive windows have slightly washed-out system colours -set-option -g window-style "bg=colour232,fg=colour248" -set-option -g window-active-style "bg=colour0,fg=colour15" - -# The status bar has the defined background and foreground colours -set-option -g status-style "bg=<% DF_TMUX_BG %>,fg=<% DF_TMUX_FG %>" - -# Titles of windows default to black text with no embellishment -set-window-option -g window-status-style "fg=colour16" - -# The title of the active window is in white rather than black -set-window-option -g window-status-current-style "fg=colour231" - -# A window with a bell has a title with a red background until cleared -set-window-option -g window-status-bell-style "bg=colour9" diff --git a/tmux/tmux.conf.mi5 b/tmux/tmux.conf.mi5 new file mode 100644 index 00000000..76d493c1 --- /dev/null +++ b/tmux/tmux.conf.mi5 @@ -0,0 +1,130 @@ +# Strip out a lot of machine and X11 dependent crap from the initial +# environment +set-environment -gru COLORFGBG +set-environment -gru COLORTERM +set-environment -gru DISPLAY +set-environment -gru SSH_CLIENT +set-environment -gru SSH_CONNECTION +set-environment -gru SSH_TTY +set-environment -gru WINDOWID + +# Otherwise, use the environment we had when we started; don't touch it during +# a session unless I specifically ask +set-option -g update-environment '' + +# Setting this makes each new pane a non-login shell, which suits me better +set-option -g default-command "$SHELL" + +# Expect a 256-color terminal +set-option -g default-terminal 'screen-256color' + +# Change the prefix to ^A rather than the default of ^B, because I'm a godless +# GNU Screen refugee, and also I like using ^B in my shell and in Vim more +unbind-key C-b +set-option -g prefix C-a +bind-key a send-prefix + +# Repeating the prefix switches to the last window and back, a GNU Screen +# feature that's hardwired into my brain now +bind-key C-a last-window + +# Quick ways to kill single windows and the whole server +bind-key '/' confirm-before 'kill-window' +bind-key '\' confirm-before 'kill-server' + +# Slightly more intuitive way to split windows +bind-key '_' split-window -v +bind-key '|' split-window -h + +# Switch to the last active pane +bind-key Tab last-pane + +# Use the vi mode for tmux interaction behaviour in copy and choice modes +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send -X begin-selection +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel + +# Detach with Alt-M, no prefix required +bind-key -n M-m detach + +# Vim-like pane resizing +bind-key -r '+' resize-pane -U 5 +bind-key -r '-' resize-pane -D 5 +bind-key -r '<' resize-pane -L 5 +bind-key -r '>' resize-pane -R 5 + +# Vim-like pane switching +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R + +# Join and break panes +bind-key J choose-window "join-pane -h -s '%%'" +bind-key B break-pane -d + +# Select only sessions in the choose-tree menu, not the whole tree of sessions +# and windows, I prefer to drill down +bind-key s choose-session + +# Session title on the left side of the status bar +set-option -g status-left '[#S] ' + +# Username, hostname, and the current date on the right side of the status bar +set-option -g status-right ' [#(whoami)@#H] #(date +"%F %T")' + +# Update the status bar every second +set-option -g status-interval 1 + +# The first window in a session has index 1, rather than 0 +set-option -g base-index 1 + +# Don't worry about timeouts for key combinations, as I don't use Escape as +# meta and prefer things to be snappier +set-option -g escape-time 0 + +# Keep plenty of history +set-option -g history-limit 100000 + +# Don't interfere with my system clipboard +set-option -g set-clipboard off + +# Only force individual windows to the smallest attached terminal size, not +# whole sessions +set-window-option -g aggressive-resize on + +# If I don't set a title on a window, use the program name for the window title +set-window-option -g automatic-rename on + +# However, don't let terminal escape sequences rename my windows +set-window-option -g allow-rename off + +# Window titles are the window index, a colon, the window or command name, and +# any activity or alert indicators +set-window-option -g window-status-format "#I:#W#F" + +# Message dialogs are white on blue +set-option -g message-style "bg=colour18,fg=colour231" + +# Window choosers are white on blue +set-window-option -g mode-style "bg=colour18,fg=colour231" + +# Pane borders are always in the background color +set-option -g pane-border-style "fg=<% DF_TMUX_BG %>" +set-option -g pane-active-border-style "fg=<% DF_TMUX_BG %>" + +# Inactive windows have slightly washed-out system colours +set-option -g window-style "bg=colour232,fg=colour248" +set-option -g window-active-style "bg=colour0,fg=colour15" + +# The status bar has the defined background and foreground colours +set-option -g status-style "bg=<% DF_TMUX_BG %>,fg=<% DF_TMUX_FG %>" + +# Titles of windows default to black text with no embellishment +set-window-option -g window-status-style "fg=colour16" + +# The title of the active window is in white rather than black +set-window-option -g window-status-current-style "fg=colour231" + +# A window with a bell has a title with a red background until cleared +set-window-option -g window-status-bell-style "bg=colour9" -- cgit v1.2.3 From 54e85f42174610a0aaf29a4912c22bb8d7a4f742 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 22:08:15 +1200 Subject: Remove lies from mi5 The second pass of the evaluator confounded me --- bin/mi5.awk | 3 --- man/man1/mi5.1df | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index c05955ff..32bac6e9 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -33,9 +33,6 @@ mac { # Don't let apostrophes close the comment gsub(/'/, "''`") - # Don't let $ signs confound expansion - gsub(/\$/, "$'`") - # Replace m5 opener with m4 closer gsub(/<% */, "'") diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index b56bed93..7fb41078 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -50,13 +50,7 @@ very simple macro expansion in an mi5 inline. .SH CAVEATS Only very simple macro expansions work in inline calls at the moment. This can be fixed by the author tokenizing the line properly, which he'll do Real Soon -Now (TM). Specifically, neither quote delimiters nor macro parameters work. -The latter is because of a nasty corner-case in m4 where parameter expansions -$1, $2, $*, etc are expanded -.B even within quotes, -one of m4's darkest corners. The workaround is to do as much logic as you can -in a block, defining your result as a single simple macros, and then expanding -that inline. +Now (TM). Specifically, quote delimiters do not work. .SH SEE ALSO bp(1df), xargs(1) .SH AUTHOR -- cgit v1.2.3 From 62805cfe64f752ef2ee0c6e086d56a4fa7ed386e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 22:11:27 +1200 Subject: Restore a cosmetic newline --- bin/mi5.awk | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/mi5.awk b/bin/mi5.awk index 32bac6e9..46bbbb25 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -38,6 +38,7 @@ mac { # Replace m5 closer with m4 opener gsub(/ *%>/, "`") + print } -- cgit v1.2.3 From c3d83b52038193ebeb95281bd7a275bae0e3c0a3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 22:14:01 +1200 Subject: Correct mi5(1df) man page formatting --- man/man1/mi5.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 7fb41078..7782ebce 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -10,7 +10,8 @@ FILE > out.m4 FILE1 FILE2 > out.m4 .br prog | -.B mi5 > out.m4 +.B mi5 +> out.m4 .br .SH DESCRIPTION .B mi5 -- cgit v1.2.3 From e69db9954057b6df99e8e666b199e499aec12007 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 22:52:40 +1200 Subject: Implemented an idea Slightly cleverer parsing for mi5 --- IDEAS.markdown | 2 -- bin/mi5.awk | 54 ++++++++++++++++++++++++++++++++++++------------------ man/man1/mi5.1df | 34 ++++++++++++++++++++-------------- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 61f1049d..3b0f1c75 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -12,5 +12,3 @@ Ideas processes and mkfifo(1). * Write something like hcat(1df) or tcat(1df) that includes filename headings for each concatenated file. -* mi5(1df) could be made to handle comment delimiters and $1 $2 expansions - without too much pain (substr/index counting) diff --git a/bin/mi5.awk b/bin/mi5.awk index 46bbbb25..1ddc5a2f 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -16,33 +16,51 @@ NF == 1 && $1 == "%>" && mac { next } -# If processing macros, strip leading and trailing whitespace and skip blank -# lines -mac { +# If in a block, print each line with any content on it after stripping leading +# and trailing whitespace +mac && NF { sub(/^ */, "") sub(/ *$/, "") -} -mac && !NF { next } - -# Inlines -mac { print $0 "dnl" } + +# If not in a block, look for inlines to process !mac { - # Don't let apostrophes close the comment - gsub(/'/, "''`") + # We'll empty one variable into another + src = $0 + dst = "" + + # As long as there's a pair of opening and closing tags + while (src ~ /<%.*%>/) { - # Replace m5 opener with m4 closer - gsub(/<% */, "'") + # Read up to opening tag into seg, shift from src + ind = index(src, "<%") + seg = substr(src, 1, ind - 1) + src = substr(src, ind) - # Replace m5 closer with m4 opener - gsub(/ *%>/, "`") + # Escape quote closer and add to dst + gsub(/'/, "''`", seg) + dst = dst seg - print + # Read up to closing tag into seg, shift from src + ind = index(src, "%>") + seg = substr(src, 1, ind + 1) + src = substr(src, ind + 2) + + # Translate tags to quote open and close and add to dst + sub(/^<% */ , "'", seg) + sub(/ *%>$/ , "`", seg) + dst = dst seg + } + + # Escape quote closers in whatever's left + gsub(/'/, "''`", src) + + # Tack that onto the end, and print it + dst = dst src + print dst } # Print an m4 closer and newline deleter as the last bytes -END { - print "'dnl" -} +END { print "'dnl" } diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 7782ebce..04f964c1 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -20,21 +20,23 @@ and predictable for its author, who wants badly to like m4 but doesn't. It's primarily intended for situations where the majority of a file is simple static text, and only a few simple macros need to be defined and expanded, which covers almost every usage case for the author. It's written to work with any -POSIX m4. +POSIX awk and to generate output for any POSIX m4. .P mi5 inverts m4's usual approach by approaching most of the file as if it were part of an m4 quote, with <% and %> as the delimiters to specify markers in -which macro expansion should occur. This makes m4 work in a way reminiscent of -templating libraries or languages like PHP. +which macro expansion should occur. This is therefore a way to shoehorn m4 into +working in a way reminiscent of templating libraries or languages like PHP. .P Macros can be expanded as blocks: .P <% - define(`FOO', `bar') - define(`BAZ', include(`include/quux.inc') - ?> + + define(`FOO', `bar') + define(`BAZ', include(`include/quux.inc') + + %> .P -For this format, "dnl" macros to delete newlines for each declaration are +For this format, `dnl' macros to delete newlines for each declaration are inserted for you. Blank lines are skipped, and leading and trailing spaces are ignored. The above code therefore produces no actual output, as it only has two define calls. @@ -44,15 +46,19 @@ For inline expansion, the syntax is similar, but the behaviour slightly differen The value of the FOO macro is <% FOO %>. .P Spaces immediately after the opening delimiter and before the closing delimiter -are ignored, but spaces produced within the macro are preserved. +are ignored, but spaces produced within the macro are preserved. `dnl` macros +are not inserted for inline blocks. .P -Ideally, you do macro definition in an mi5 block at the top of your file, and -very simple macro expansion in an mi5 inline. +Ideally, you do your complex macro definition in a block at the top of your +file, and your simple macro expansion of those results in an inline. .SH CAVEATS -Only very simple macro expansions work in inline calls at the moment. This can -be fixed by the author tokenizing the line properly, which he'll do Real Soon -Now (TM). Specifically, quote delimiters do not work. +The <% delimiters %> are hardcoded for now. +.P +Inline expansions cannot span multiple lines. Use blocks for that. +.P +Doesn't cope at all with `changequote'. If you need that, you should probably +write raw m4. .SH SEE ALSO -bp(1df), xargs(1) +m4(1) .SH AUTHOR Tom Ryder -- cgit v1.2.3 From ac1306bd64f5132f2a03ec166144eddea4d31326 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:11:01 +1200 Subject: Tidier implementation for mi5 sh --- Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8f278325..5bb29685 100644 --- a/Makefile +++ b/Makefile @@ -197,6 +197,15 @@ BINS = bin/ap \ bin/xrbg \ bin/xrq +BINS_MI5 = bin/chn.sh \ + bin/edda.sh \ + bin/pst.sh \ + bin/rndl.sh \ + bin/swr.sh \ + bin/tlcs.sh \ + bin/try.sh \ + bin/urlc.sh + GAMES = games/aaf \ games/acq \ games/aesth \ @@ -269,14 +278,7 @@ clean distclean: .m4.sh: m4 < $< > $@ -bin/chn.sh: include/mktd.m4 -bin/edda.sh: include/mktd.m4 -bin/pst.sh: include/mktd.m4 -bin/rndl.sh: include/mktd.m4 -bin/swr.sh: include/mktd.m4 -bin/tlcs.sh: include/mktd.m4 -bin/try.sh: include/mktd.m4 -bin/urlc.sh: include/mktd.m4 +$(BINS_MI5): include/mktd.m4 git/gitconfig: git/gitconfig.m4 m4 \ @@ -498,7 +500,7 @@ check: check-bin \ check-bash: sh check/bash.sh -check-bin: +check-bin: $(BINS_MI5) sh check/bin.sh check-games: -- cgit v1.2.3 From 5d5c0c756d386663107fbb46634b811882c9a1c9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:16:12 +1200 Subject: Add an mi5(1df) caveat --- man/man1/mi5.1df | 3 +++ 1 file changed, 3 insertions(+) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 04f964c1..91ce3d07 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -56,6 +56,9 @@ The <% delimiters %> are hardcoded for now. .P Inline expansions cannot span multiple lines. Use blocks for that. .P +You can't include the closing delimiter %> anywhere within an inline expansion, +even quoted. The parser is too dumb to cope with that. +.P Doesn't cope at all with `changequote'. If you need that, you should probably write raw m4. .SH SEE ALSO -- cgit v1.2.3 From 491a112b3daca6c5d48939ffc51c13a2e4268363 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:18:30 +1200 Subject: Add another mi5(1df) caveat --- man/man1/mi5.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 91ce3d07..fddcf725 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -52,7 +52,7 @@ are not inserted for inline blocks. Ideally, you do your complex macro definition in a block at the top of your file, and your simple macro expansion of those results in an inline. .SH CAVEATS -The <% delimiters %> are hardcoded for now. +The <% delimiters %> are hardcoded for now, and there's no way to escape them. .P Inline expansions cannot span multiple lines. Use blocks for that. .P -- cgit v1.2.3 From 31460b8e225813a63cc28331b794769246447397 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:35:33 +1200 Subject: Allow custom delimiters for mi5(1df) --- bin/mi5.awk | 26 ++++++++++++++++---------- man/man1/mi5.1df | 12 ++++++++---- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 1ddc5a2f..82c5f914 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -1,16 +1,22 @@ # Crude m4 preprocessor -BEGIN { mac = 0 } +BEGIN { + mac = 0 + if (!length(open)) + open = "<%" + if (!length(shut)) + shut = "%>" +} # Print an m4 opener as the first byte NR == 1 { printf "`" } # Blocks -NF == 1 && $1 == "<%" && !mac { +NF == 1 && $1 == open && !mac { mac = 1 printf "'" next } -NF == 1 && $1 == "%>" && mac { +NF == 1 && $1 == shut && mac { mac = 0 printf "`" next @@ -32,10 +38,10 @@ mac && NF { dst = "" # As long as there's a pair of opening and closing tags - while (src ~ /<%.*%>/) { + while (src ~ open ".*" shut) { # Read up to opening tag into seg, shift from src - ind = index(src, "<%") + ind = index(src, open) seg = substr(src, 1, ind - 1) src = substr(src, ind) @@ -44,13 +50,13 @@ mac && NF { dst = dst seg # Read up to closing tag into seg, shift from src - ind = index(src, "%>") - seg = substr(src, 1, ind + 1) - src = substr(src, ind + 2) + ind = index(src, shut) + seg = substr(src, 1, ind + length(shut) - 1) + src = substr(src, ind + length(shut)) # Translate tags to quote open and close and add to dst - sub(/^<% */ , "'", seg) - sub(/ *%>$/ , "`", seg) + sub("^" open " *", "'", seg) + sub(" *" shut "$", "`", seg) dst = dst seg } diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index fddcf725..8c9c1c5c 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -7,6 +7,9 @@ FILE > out.m4 .br .B mi5 +-v open='{{{' -v shut='}}}' FILE > out.m4 +.br +.B mi5 FILE1 FILE2 > out.m4 .br prog | @@ -23,9 +26,10 @@ covers almost every usage case for the author. It's written to work with any POSIX awk and to generate output for any POSIX m4. .P mi5 inverts m4's usual approach by approaching most of the file as if it were -part of an m4 quote, with <% and %> as the delimiters to specify markers in -which macro expansion should occur. This is therefore a way to shoehorn m4 into -working in a way reminiscent of templating libraries or languages like PHP. +part of an m4 quote, with <% and %> as the (default) delimiters to specify +markers in which macro expansion should occur. This is therefore a way to +shoehorn m4 into working in a way reminiscent of templating libraries or +languages like PHP. .P Macros can be expanded as blocks: .P @@ -52,7 +56,7 @@ are not inserted for inline blocks. Ideally, you do your complex macro definition in a block at the top of your file, and your simple macro expansion of those results in an inline. .SH CAVEATS -The <% delimiters %> are hardcoded for now, and there's no way to escape them. +There's no way to escape the delimiters. .P Inline expansions cannot span multiple lines. Use blocks for that. .P -- cgit v1.2.3 From f99829be0bb1eaf89d0fd29afbee08d95d07d0a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:49:05 +1200 Subject: Remove regex operations on mi5(1df) delims --- bin/mi5.awk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 82c5f914..27974274 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -38,7 +38,7 @@ mac && NF { dst = "" # As long as there's a pair of opening and closing tags - while (src ~ open ".*" shut) { + while (index(src,open)) { # Read up to opening tag into seg, shift from src ind = index(src, open) @@ -51,12 +51,12 @@ mac && NF { # Read up to closing tag into seg, shift from src ind = index(src, shut) - seg = substr(src, 1, ind + length(shut) - 1) + seg = substr(src, length(open) + 1, ind - length(shut) - 1) src = substr(src, ind + length(shut)) # Translate tags to quote open and close and add to dst - sub("^" open " *", "'", seg) - sub(" *" shut "$", "`", seg) + sub(/^ */, "'", seg) + sub(/ *$/, "`", seg) dst = dst seg } -- cgit v1.2.3 From d35b95dedee317c6f8a8c3a87bd6ac7d8c5bb0f2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 2 Jun 2017 23:52:40 +1200 Subject: Remove misplaced shebangs --- bin/clog.sh | 1 - bin/jfp.sed | 1 - 2 files changed, 2 deletions(-) diff --git a/bin/clog.sh b/bin/clog.sh index b62d4f94..1b612d68 100644 --- a/bin/clog.sh +++ b/bin/clog.sh @@ -1,4 +1,3 @@ -#!/bin/sh # Record a timestamped message to a logfile, defaulting to ~/.clog self=clog diff --git a/bin/jfp.sed b/bin/jfp.sed index 938c4e4d..1237bcbc 100644 --- a/bin/jfp.sed +++ b/bin/jfp.sed @@ -1,4 +1,3 @@ -#!/bin/sed -f 1 { /^\#\!/d } -- cgit v1.2.3 From e5c7c6fc496310df68e73ff21e5aa5e9665eb6fc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index fcbe2d3e..9aa4a1c7 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit fcbe2d3eaf3ac1438da122e65badbf410d7990ef +Subproject commit 9aa4a1c79c61c581ace5caa5b09b0e283d5c72ae -- cgit v1.2.3 From 50a5b0d2235b3d2a1d3355832fc21e3bc180aa19 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:07:09 +1200 Subject: Check presence of delimiters correctly --- bin/mi5.awk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 27974274..0bcc1930 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -38,10 +38,9 @@ mac && NF { dst = "" # As long as there's a pair of opening and closing tags - while (index(src,open)) { + while (ind = index(src, open) && index(src, shut) > ind) { # Read up to opening tag into seg, shift from src - ind = index(src, open) seg = substr(src, 1, ind - 1) src = substr(src, ind) -- cgit v1.2.3 From 802729b618ad32986d640d34a085a819cf1752db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:09:25 +1200 Subject: Nicer toggle --- bin/mi5.awk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 0bcc1930..2deec375 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -11,13 +11,11 @@ BEGIN { NR == 1 { printf "`" } # Blocks -NF == 1 && $1 == open && !mac { - mac = 1 +NF == 1 && $1 == open && !mac++ { printf "'" next } -NF == 1 && $1 == shut && mac { - mac = 0 +NF == 1 && $1 == shut && mac-- { printf "`" next } -- cgit v1.2.3 From 95a79bb97af9998cf3416f62f6f0f6dfcad2fb1d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:28:18 +1200 Subject: Use full length($0) rather than just length The latter is allowed by POSIX, but not historically accepted everywhere and the former being explicit is more readable anyway --- bin/unf.awk | 2 +- games/squ.awk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/unf.awk b/bin/unf.awk index a9837a8a..ac6172f7 100644 --- a/bin/unf.awk +++ b/bin/unf.awk @@ -8,7 +8,7 @@ function wrbuf() { } # Flag to stop processing once we hit the first blank line -!length { +!length($0) { wrbuf() body = 1 } diff --git a/games/squ.awk b/games/squ.awk index abd16934..be72a3b6 100644 --- a/games/squ.awk +++ b/games/squ.awk @@ -1,5 +1,5 @@ # Make a reduced Latin square out of each line of input -l = length { +l = length($0) { str = toupper($0) for (j = 0; j < l; j++) for (k = 0; k < l; k++) -- cgit v1.2.3 From f095526805fd347c23bf0a9e27609a6949051616 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:37:36 +1200 Subject: Add rep(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + bin/rep.sh | 25 +++++++++++++++++++++++++ man/man1/chn.1df | 7 ++++--- man/man1/rep.1df | 15 +++++++++++++++ 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 bin/rep.sh create mode 100644 man/man1/rep.1df diff --git a/.gitignore b/.gitignore index 153d2227..3f2aeb76 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ bin/pst.m4 bin/pvi bin/pwg bin/quo +bin/rep bin/rfcf bin/rfcr bin/rfct diff --git a/Makefile b/Makefile index 5bb29685..b302c217 100644 --- a/Makefile +++ b/Makefile @@ -149,6 +149,7 @@ BINS = bin/ap \ bin/pvi \ bin/pwg \ bin/quo \ + bin/rep \ bin/rfcf \ bin/rfcr \ bin/rfct \ diff --git a/README.markdown b/README.markdown index bd0b6682..f50583ce 100644 --- a/README.markdown +++ b/README.markdown @@ -521,6 +521,7 @@ Installed by the `install-bin` target: [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in `~/.plenv/non-cpan-modules`, and updates them all. * `pwg(1df)` generates just one decent password with `pwgen(1)`. +* `rep(1df)` repeats a command a given number of times. * `rgl(1df)` is a very crude interactive `grep(1)` loop. * `shb(1df)` attempts to build shebang lines for scripts from the system paths. diff --git a/bin/rep.sh b/bin/rep.sh new file mode 100644 index 00000000..e53cbac3 --- /dev/null +++ b/bin/rep.sh @@ -0,0 +1,25 @@ +# Repeat a command +self=rep + +# Check arguments. +if [ "$#" -lt 2 ] ; then + printf >&2 '%s: Need a count and a program name\n' "$self" + exit 2 +fi + +# Shift off the repetition count. +c=$1 +shift + +# Check the repetition count looks sane. Zero is fine! +if [ "$c" -lt 0 ] ; then + printf >&2 '%s: Nonsensical negative count\n' "$self" + exit 2 +fi + +# Run the command the specified number of times. Stop immediately as soon as a +# run fails. +while [ "${n=1}" -le "$c" ] ; do + "$@" || exit + n=$((n+1)) +done diff --git a/man/man1/chn.1df b/man/man1/chn.1df index 576e5425..5e9c702d 100644 --- a/man/man1/chn.1df +++ b/man/man1/chn.1df @@ -24,11 +24,12 @@ Zero is a valid count; in this case the input is passed untouched to output: $ chn 0 quo < msg Hello! .P -Don't confuse this with simply repeating a command. This happens to work: +Don't confuse this with simply repeating a command--use rep(1df) for that.. +This happens to do what you might expect: .P $ chn 5 sync .P -But this will not do what you expect: +But this won't: .P $ chn 5 echo foo .SH CAVEATS @@ -42,6 +43,6 @@ There's almost certainly a better way to do this, fixing one or both of the above issues, and possibly even in shell; maybe with curlier file descriptor logic to save unneeded open(2) syscalls. I smell `eval` usage on the horizon. .SH SEE ALSO -maybe(1df), try(1df) +maybe(1df), rep(1df), try(1df) .SH AUTHOR Tom Ryder diff --git a/man/man1/rep.1df b/man/man1/rep.1df new file mode 100644 index 00000000..8971f392 --- /dev/null +++ b/man/man1/rep.1df @@ -0,0 +1,15 @@ +.TH REP 1df "August 2017" "Manual page for rep" +.SH NAME +.B rep +\- run a command repeatedly +.SH USAGE +.B rep +COUNT +COMMAND [ARG1...] +.SH DESCRIPTION +Run the given command the specified number of times. Zero is a valid count; +nothing happens. +.SH SEE ALSO +chn(1df), maybe(1df), try(1df), watch(1) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From fe009ce561fa11049c81fb5843efa776214250e6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:46:35 +1200 Subject: Adjust formatting of man tl(1df) --- man/man1/tl.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/tl.1df b/man/man1/tl.1df index eee3bc98..0c686b8b 100644 --- a/man/man1/tl.1df +++ b/man/man1/tl.1df @@ -3,7 +3,8 @@ .B tl \- tag lines with a string prefix and/or suffix .SH USAGE -.B tl [-p PREFIX] [-s SUFFIX] [--] [FILE1 FILE2 ...] +.B tl +[-p PREFIX] [-s SUFFIX] [--] [FILE1 FILE2 ...] .SH DESCRIPTION Tag lines from files or stdin with a string prefix or suffix before writing them to stdout. Specifying neither prefix nor suffix is acceptable, in which -- cgit v1.2.3 From b3845bf95d3910ef98dcf66c9fcc3a823af8bbb7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:47:26 +1200 Subject: Formatting/extra element for man edda(1df) --- man/man1/edda.1df | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/man1/edda.1df b/man/man1/edda.1df index 8c71f3ec..0f968d8a 100644 --- a/man/man1/edda.1df +++ b/man/man1/edda.1df @@ -3,7 +3,8 @@ .B edda \- run ed(1) over multiple files .SH SYNOPSIS -.B edda FILE1 [FILE2...] +.B edda +FILE1 [FILE2...] < script.ed .SH DESCRIPTION Duplicate any data on stdin into a temporary file, and run ed(1) options over each of the files given as arguments. Example: -- cgit v1.2.3 From 65cfecabd0f6a1bcfc9b7691ab2cc1056e506c0d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:48:03 +1200 Subject: Correct typo in maybe(1df) --- man/man1/maybe.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/maybe.1df b/man/man1/maybe.1df index 3b89b09d..a8658c71 100644 --- a/man/man1/maybe.1df +++ b/man/man1/maybe.1df @@ -15,7 +15,7 @@ Like true(1) or false(1), but exits with success randomly with a given probability. Good for using in tests. Exits with 2 rather than 1 on usage errors. .P -The numerator default to 1 and the denominator to 2 for a roughly equal chance +The numerator defaults to 1 and the denominator to 2 for a roughly equal chance of success or failure. rndi(1df) is used for the randomness. .P $ maybe -- cgit v1.2.3 From ba554b771bed6b5d1b9497ea44a3c1e7c3c75f11 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 01:57:21 +1200 Subject: Add more explanation to README --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index f50583ce..e0a9e6b7 100644 --- a/README.markdown +++ b/README.markdown @@ -4,6 +4,10 @@ Dotfiles (Tom Ryder) This is my personal repository of configuration files and scripts for `$HOME`, including most of the settings that migrate well between machines. +This repository began as a simple way to share Vim and tmux configuration, but +over time a lot of scripts and shell configuration have been added, making it +into a personal suite of custom Unix tools. + Installation ------------ -- cgit v1.2.3 From 8153e126523f8396552fadb590980221abee0a2d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 02:03:00 +1200 Subject: Correct an error in README --- README.markdown | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index e0a9e6b7..722cc652 100644 --- a/README.markdown +++ b/README.markdown @@ -337,12 +337,10 @@ The configuration file is created with `m4(1)` to allow specifying a color theme. This is just because I use a different color for my work session. The default is a dark grey. -The configuration for Bash includes a `tmux` function designed to make `attach` -into the default command if no arguments are given and sessions do already -exist. The default command is normally `new-session`. - -My `~/.inputrc` file binds Alt+M to attach to or create a `tmux` session, and -Tmux in turn binds the same key combination to detach. +The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into +the default command if no arguments are given and sessions do already exist. My +`~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key +combination to detach. ### Vim -- cgit v1.2.3 From 9d09e0c78b4973a66c996863266f2f98cb225f02 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 02:03:56 +1200 Subject: Corrections around mi5(1df)/m4(1) --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 722cc652..9196f017 100644 --- a/README.markdown +++ b/README.markdown @@ -286,7 +286,7 @@ as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan. The configuration for GnuPG is intended to follow [RiseUp's OpenPGP best practices](https://riseup.net/en/security/message-security/openpgp/best-practices). -The configuration file is rebuilt using `m4(1)` and `make(1)` because it +The configuration file is rebuilt using `mi5(1df)` and `make(1)` because it requires hard-coding a path to the SKS keyserver certificate authority, and neither tilde nor `$HOME` expansion works for this. @@ -333,7 +333,7 @@ Note that the configuration presently uses a hard-coded 256-color colorscheme, and uses non-login shells, with an attempt to control the environment to stop shells thinking they have access to an X display. -The configuration file is created with `m4(1)` to allow specifying a color +The configuration file is created with `mi5(1df)` to allow specifying a color theme. This is just because I use a different color for my work session. The default is a dark grey. @@ -501,7 +501,7 @@ Installed by the `install-bin` target: it exits with success or failure. Good for quick tests. * `mex(1df)` makes given filenames in `$PATH` executable. * `mi5(1df)` pre-processes a crude but less painful macro expansion file - format into m4. + format into `m4` input. * `mftl(1df)` finds usable-looking targets in Makefiles. * `mkcp(1df)` creates a directory and copies preceding arguments into it. * `mkmv(1df)` creates a directory and moves preceding arguments into it. -- cgit v1.2.3 From 8c8d951054ab1b135f36bdc98b0fd5129f1cb641 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 02:05:00 +1200 Subject: Remove a lie --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 9196f017..996a7709 100644 --- a/README.markdown +++ b/README.markdown @@ -455,8 +455,7 @@ Installed by the `install-bin` target: * `bel(1df)` prints a terminal bell character. * `bl(1df)` generates a given number of blank lines. * `bp(1df)` runs `br(1df)` after prompting for an URL. -* `br(1df)` launches `$BROWSER`, or a more suitable application for an URL if - it knows of one. +* `br(1df)` launches `$BROWSER`. * `ca(1df)` prints a count of its given arguments. * `cf(1df)` prints a count of entries in a given directory. * `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as -- cgit v1.2.3 From 9f703c05aec8b392a858c60cf91491e3504897b8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 02:07:10 +1200 Subject: Add a period --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 996a7709..bf25a40d 100644 --- a/README.markdown +++ b/README.markdown @@ -511,7 +511,7 @@ Installed by the `install-bin` target: * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s `s_client` subcommand. * `p(1df)` prints concatenated standard input; `cat(1)` as it should always - have been + have been. * `pa(1df)` prints its arguments, one per line. * `pp(1df)` prints the full path of each argument using `$PWD`. * `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. -- cgit v1.2.3 From 2d7462c026ef3429103043e7f0ac590e076e316c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 12:32:17 +1200 Subject: Add some missing parentheses --- bin/mi5.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 2deec375..6e3a7ead 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -36,7 +36,7 @@ mac && NF { dst = "" # As long as there's a pair of opening and closing tags - while (ind = index(src, open) && index(src, shut) > ind) { + while ((ind = index(src, open)) && index(src, shut) > ind) { # Read up to opening tag into seg, shift from src seg = substr(src, 1, ind - 1) -- cgit v1.2.3 From 672968b2b630d18511ef7593cca488bec1d11069 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 12:45:40 +1200 Subject: Add some sample tests for mi5(1df) --- share/sample1.mi5 | 7 +++++++ share/sample2.mi5 | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 share/sample1.mi5 create mode 100644 share/sample2.mi5 diff --git a/share/sample1.mi5 b/share/sample1.mi5 new file mode 100644 index 00000000..686d7787 --- /dev/null +++ b/share/sample1.mi5 @@ -0,0 +1,7 @@ +<% + + define(`FOO', `foo') + +%> +FOO is <% FOO %>. Happy? Here it is again: <% FOO %>. +I hope this has been enlightening for you. diff --git a/share/sample2.mi5 b/share/sample2.mi5 new file mode 100644 index 00000000..6e964a23 --- /dev/null +++ b/share/sample2.mi5 @@ -0,0 +1,7 @@ +{{{ + + define(`BAR', `bar') + +}}} +BAR is {{{ BAR }}}. Happy? Here it is again: {{{ BAR }}}. +You need to change the mi5 delimiter for that to work. -- cgit v1.2.3 From 944982a3c2bc00cbcbf5a28057bcbe0e048d49bd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Jun 2017 15:15:44 +1200 Subject: Add missing paren --- man/man1/mi5.1df | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 8c9c1c5c..ca28e75b 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -36,7 +36,7 @@ Macros can be expanded as blocks: <% define(`FOO', `bar') - define(`BAZ', include(`include/quux.inc') + define(`BAZ', include(`include/quux.inc')) %> .P -- cgit v1.2.3 From 2ea2afc068dc7330c9696af54ff2dced157f47de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 4 Jun 2017 17:52:26 +1200 Subject: Significant improvements to mi5(1df) A clunkier and probably-slower but more accurate parser--won't stumble over quoted instances of the mi5(1df) delimiter within inline macro expansions. This removes one of the CAVEATS described in the manual page. Also allow specifying the quote and unquote strings and also the dnl string in m4, mostly for completeness' sake; the manual page warns against this as I think it's probably missing the point of mi5(1df) if you're getting to that point. --- bin/mi5.awk | 137 ++++++++++++++++++++++++++++++++++++++++-------------- man/man1/mi5.1df | 9 ++-- share/sample1.mi5 | 2 + 3 files changed, 108 insertions(+), 40 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 6e3a7ead..14f2ff2b 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -1,69 +1,136 @@ # Crude m4 preprocessor BEGIN { - mac = 0 + self = "mi5" + + # You can change any of these, but while changing these is still relatively + # sane... if (!length(open)) open = "<%" if (!length(shut)) shut = "%>" + + # ... changing these probably isn't, and should compel you to rethink your + # code, or quite possibly your entire life thus far. + if (!length(quote)) + quote = "`" + if (!length(unquote)) + unquote = "'" + if (!length(dnl)) + dnl = "dnl" +} + +# Fatal error function +function fatal(str) { + printf "%s: %s\n", self, str | "cat >&2" + exit(1) } # Print an m4 opener as the first byte -NR == 1 { printf "`" } +NR == 1 { printf "%s", quote } # Blocks -NF == 1 && $1 == open && !mac++ { - printf "'" +NF == 1 && $1 == open && !bmac++ { + printf "%s", unquote next } -NF == 1 && $1 == shut && mac-- { - printf "`" +NF == 1 && $1 == shut && bmac-- { + printf "%s", quote next } # If in a block, print each line with any content on it after stripping leading # and trailing whitespace -mac && NF { - sub(/^ */, "") - sub(/ *$/, "") +bmac && NF { + gsub(/(^ +| +$)/, "") print $0 "dnl" } # If not in a block, look for inlines to process -!mac { +!bmac { - # We'll empty one variable into another + # We'll parse one variable into another... src = $0 dst = "" - # As long as there's a pair of opening and closing tags - while ((ind = index(src, open)) && index(src, shut) > ind) { + # Crude and slow, clansman. Your parser was no better than that of a clumsy + # child. + for (i = 1; i <= length(src); ) { - # Read up to opening tag into seg, shift from src - seg = substr(src, 1, ind - 1) - src = substr(src, ind) + # Inline macro expansion: commented + if (iquo) { - # Escape quote closer and add to dst - gsub(/'/, "''`", seg) - dst = dst seg + # Look for end of comment and tip flag accordingly + if (substr(src, i, length(unquote)) == unquote) + iquo = 0 + } - # Read up to closing tag into seg, shift from src - ind = index(src, shut) - seg = substr(src, length(open) + 1, ind - length(shut) - 1) - src = substr(src, ind + length(shut)) + # Inline macro expansion + else if (imac) { - # Translate tags to quote open and close and add to dst - sub(/^ */, "'", seg) - sub(/ *$/, "`", seg) - dst = dst seg - } + # Close the current inline macro expansion if a close tag is found + # (in m4 terms: open a new quote), looking ahead past any spaces + # from this point first + for (j = i; substr(src, j, 1) ~ /[ \t]/; j++) + continue + if (substr(src, j, length(shut)) == shut) { + dst = dst quote + i = j + i += length(shut) + imac = 0 + continue + } + + # Look for start of comment and tip flag accordingly + if (substr(src, i, length(quote)) == quote) + iquo = 1 + } + + # Plain text mode + else { - # Escape quote closers in whatever's left - gsub(/'/, "''`", src) + # Open a new inline macro expansion if an open tag is found (in m4 + # terms: close the quote), and then look ahead past any spaces from + # that point afterward + if (substr(src, i, length(open)) == open) { + dst = dst unquote + imac = 1 + for (i += length(open); substr(src, i, 1) ~ /[ \t]/; i++) + continue + continue + } - # Tack that onto the end, and print it - dst = dst src - print dst + # Escape quote terminators + if (substr(src, i, length(unquote)) == unquote) { + + # Dear Mr. President. There are too many variables nowadays. + # Please eliminate three. I am NOT a crackpot. + dst = dst unquote unquote quote + + i += length(unquote) + continue + } + } + + # If we got down here, we can just add the next character and move on + dst = dst substr(src, i, 1) + i += 1 + } + + # If we're still in a macro expansion or quote by this point, something's + # wrong; say so and stop, rather than print anything silly. + if (iquo) + fatal("Unterminated inline quote"); + else if (imac) + fatal("Unterminated inline macro"); + else + print dst } -# Print an m4 closer and newline deleter as the last bytes -END { print "'dnl" } +# Print an m4 closer and newline deleter as the last bytes if we've correctly +# stopped all our blocks +END { + if (bmac) + fatal("Unterminated block macro"); + else + print unquote dnl +} diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index ca28e75b..04889b94 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -60,11 +60,10 @@ There's no way to escape the delimiters. .P Inline expansions cannot span multiple lines. Use blocks for that. .P -You can't include the closing delimiter %> anywhere within an inline expansion, -even quoted. The parser is too dumb to cope with that. -.P -Doesn't cope at all with `changequote'. If you need that, you should probably -write raw m4. +Doesn't cope at all with `changequote'. The ` and ' quote delimiters are +hardcoded. If you need to change them, you can change the "quote" and "unquote" +vars, but if you're getting to that point then you should probably write raw +m4. .SH SEE ALSO m4(1) .SH AUTHOR diff --git a/share/sample1.mi5 b/share/sample1.mi5 index 686d7787..1e134d8e 100644 --- a/share/sample1.mi5 +++ b/share/sample1.mi5 @@ -4,4 +4,6 @@ %> FOO is <% FOO %>. Happy? Here it is again: <% FOO %>. +If I quote it, though, it doesn't evaluate: <% `FOO' %>. I hope this has been enlightening for you. +I can safely comment the opening tags within an inline block, too, look: <% `<%' `%>' %>. Cool, huh? -- cgit v1.2.3 From 2d1e4227775cd24120d9559c80903011c8a0ce5e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 4 Jun 2017 17:59:31 +1200 Subject: Whoops, a couple more mi5(1df) man page fixes --- man/man1/mi5.1df | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 04889b94..6466f35d 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -60,10 +60,10 @@ There's no way to escape the delimiters. .P Inline expansions cannot span multiple lines. Use blocks for that. .P -Doesn't cope at all with `changequote'. The ` and ' quote delimiters are -hardcoded. If you need to change them, you can change the "quote" and "unquote" -vars, but if you're getting to that point then you should probably write raw -m4. +Doesn't cope at all with `changequote'. If you need to specify different ones +from this tool's point of view, you can change the "quote" and "unquote" vars +in the same way as "open" and "shut", but if you're getting to that point then +you should probably write raw m4. .SH SEE ALSO m4(1) .SH AUTHOR -- cgit v1.2.3 From 6d8f6ad10dd078042d578c030fc76acda8d54525 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 4 Jun 2017 18:04:13 +1200 Subject: Playing a little more golf --- bin/mi5.awk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 14f2ff2b..6042a46c 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -60,8 +60,7 @@ bmac && NF { if (iquo) { # Look for end of comment and tip flag accordingly - if (substr(src, i, length(unquote)) == unquote) - iquo = 0 + iquo = (substr(src, i, length(unquote)) != unquote) } # Inline macro expansion @@ -81,8 +80,7 @@ bmac && NF { } # Look for start of comment and tip flag accordingly - if (substr(src, i, length(quote)) == quote) - iquo = 1 + iquo = (substr(src, i, length(quote)) == quote) } # Plain text mode -- cgit v1.2.3 From 76cb4ce3315cce5c41d2e8a40417c92a386e697f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 4 Jun 2017 22:07:27 +1200 Subject: Remove unneeded FD ID --- bin/xrq.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xrq.awk b/bin/xrq.awk index 5c9f7e96..686cf677 100644 --- a/bin/xrq.awk +++ b/bin/xrq.awk @@ -8,7 +8,7 @@ BEGIN { # Check we have at least one resource name if (ARGC < 2) { - print "xrq: Need at least one resource name" | "cat 1>&2" + print "xrq: Need at least one resource name" | "cat >&2" exit(2) } -- cgit v1.2.3 From 0baaec5d7e47ef29ddbc89a435ef4c05bdd619a1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 4 Jun 2017 22:28:20 +1200 Subject: More tidying for mi5(1df) --- bin/mi5.awk | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index 6042a46c..fad03035 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -17,6 +17,9 @@ BEGIN { unquote = "'" if (!length(dnl)) dnl = "dnl" + + # We do not start in a block + bmac = 0 } # Fatal error function @@ -42,26 +45,27 @@ NF == 1 && $1 == shut && bmac-- { # and trailing whitespace bmac && NF { gsub(/(^ +| +$)/, "") - print $0 "dnl" + print $0 dnl } # If not in a block, look for inlines to process !bmac { - # We'll parse one variable into another... + # We'll parse one variable into another. src = $0 dst = "" + # Start off neither quoting nor macroing. + iquo = imac = 0 + # Crude and slow, clansman. Your parser was no better than that of a clumsy # child. for (i = 1; i <= length(src); ) { # Inline macro expansion: commented - if (iquo) { - - # Look for end of comment and tip flag accordingly + # Look for end of comment and tip flag accordingly + if (iquo) iquo = (substr(src, i, length(unquote)) != unquote) - } # Inline macro expansion else if (imac) { @@ -73,8 +77,7 @@ bmac && NF { continue if (substr(src, j, length(shut)) == shut) { dst = dst quote - i = j - i += length(shut) + i = j + length(shut) imac = 0 continue } @@ -110,8 +113,7 @@ bmac && NF { } # If we got down here, we can just add the next character and move on - dst = dst substr(src, i, 1) - i += 1 + dst = dst substr(src, i++, 1) } # If we're still in a macro expansion or quote by this point, something's -- cgit v1.2.3 From f263daf44788371ba171ff97cc800cfb4cba98ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 5 Jun 2017 14:11:34 +1200 Subject: Formatting tweak for grec(1df)/gred(1df) man pages --- man/man1/grec.1df | 3 ++- man/man1/gred.1df | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/man/man1/grec.1df b/man/man1/grec.1df index 8759aa33..b1f70193 100644 --- a/man/man1/grec.1df +++ b/man/man1/grec.1df @@ -3,7 +3,8 @@ .B grec \- saner name for grep -c .SH SYNOPSIS -.B grec PATTERN [FILE...] +.B grec +PATTERN [FILE...] .br .SH DESCRIPTION .B grec diff --git a/man/man1/gred.1df b/man/man1/gred.1df index 8fcc4d74..e3dbce87 100644 --- a/man/man1/gred.1df +++ b/man/man1/gred.1df @@ -3,7 +3,8 @@ .B gred \- saner name for grep -v .SH SYNOPSIS -.B gred PATTERN [FILE...] +.B gred +PATTERN [FILE...] .br .SH DESCRIPTION .B gred -- cgit v1.2.3 From aac97c272e442922e30973d42c7f45fa75873241 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 6 Jun 2017 14:57:43 +1200 Subject: Remove unneeded semicolons --- bin/mi5.awk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/mi5.awk b/bin/mi5.awk index fad03035..48d71657 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -119,9 +119,9 @@ bmac && NF { # If we're still in a macro expansion or quote by this point, something's # wrong; say so and stop, rather than print anything silly. if (iquo) - fatal("Unterminated inline quote"); + fatal("Unterminated inline quote") else if (imac) - fatal("Unterminated inline macro"); + fatal("Unterminated inline macro") else print dst } @@ -130,7 +130,7 @@ bmac && NF { # stopped all our blocks END { if (bmac) - fatal("Unterminated block macro"); + fatal("Unterminated block macro") else print unquote dnl } -- cgit v1.2.3 From 6c0c347db28783a3412c72bf9b7ef18b9926e8e1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 9 Jun 2017 23:32:36 +1200 Subject: Make dub(1df) smarter, add a caveat --- bin/dub.sh | 26 +++++++++++--------------- man/man1/dub.1df | 4 ++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/dub.sh b/bin/dub.sh index f42c5ac9..41ef88d3 100644 --- a/bin/dub.sh +++ b/bin/dub.sh @@ -1,4 +1,5 @@ # List the biggest files in a directory +self=dub # First optional argument is the directory, defaulting to the # current dir; second optional argument is the number of files to @@ -8,21 +9,16 @@ dir=${1:-.} lines=${2:-10} # Enter the target dir or bail cd -- "$dir" || exit -# Add files matching glob, shift them off if unexpanded (first and -# only entry doesn't exist) -set -- * -[ -e "$1" ] || shift - -# Add dot files, shift off the "." and ".." entries (sh(1) -# implementations seem to vary on whether they include these) -set -- .* "$@" -[ -e "$1" ] || shift -[ "$1" = . ] && shift -[ "$1" = .. ] && shift - -# Run du(1) with POSIX compatible flags -k for kilobyte unit and -# -s for total over the arguments -du -ks -- "$@" | +# Some find(1) devilry to deal with newlines as safely as possible. The idea is +# not even to touch them, and warn about their presence; better the results are +# wrong than malformed +nl=$(printf '\n/') +find . ! -name . -prune \( \ + -name '*'"${nl%/}"'*' \ + -exec sh -c ' + printf >&2 '\''%s: warning: skipped newline filename\n'\'' "$1" + ' _ "$self" \; \ + -o -exec du -ksx -- {} + \) | # Sort the first field (the sizes) numerically, in reverse sort -k1,1nr | diff --git a/man/man1/dub.1df b/man/man1/dub.1df index 52900a36..69a4c8e0 100644 --- a/man/man1/dub.1df +++ b/man/man1/dub.1df @@ -15,6 +15,10 @@ lists the biggest entries in a given directory, defaulting to the current directory. It defaults to printing 10 entries unless a second argument is given. +.SH CAVEATS +Skips filenames with newlines in them with an explicit warning to stderr, for +the least dangerous POSIX-compatible approach. Even so, you probably shouldn't +use this in critical scripts. .SH SEE ALSO du(1) .SH AUTHOR -- cgit v1.2.3 From 87f3cf69ae310bdf83e262f5212847b3c764ced7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 10 Jun 2017 15:34:07 +1200 Subject: Force integer for dub(1df) limit --- bin/dub.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dub.sh b/bin/dub.sh index 41ef88d3..c30749af 100644 --- a/bin/dub.sh +++ b/bin/dub.sh @@ -24,4 +24,4 @@ find . ! -name . -prune \( \ sort -k1,1nr | # Limit the output to the given number of lines -sed "$lines"q +sed "$((lines))"q -- cgit v1.2.3 From 491d52c57de52a1cdb15a8ee8fb66d97cdc34612 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 10 Jun 2017 16:19:28 +1200 Subject: Refactor urlh(1df) awk a bit --- bin/urlh.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/urlh.sh b/bin/urlh.sh index 5b5cab74..9f517fe9 100644 --- a/bin/urlh.sh +++ b/bin/urlh.sh @@ -17,13 +17,10 @@ unf | sd2u | # Use awk to find any values for the header case-insensitively -awk -v header="$header" ' -BEGIN { - FS=": *" - header = tolower(header) -} +awk -F ': *' -v header="$header" ' +BEGIN { header = tolower(header) } tolower($1) == header { - sub(/^[^ ]*: */, "") + sub(/^[^:]*: */, "") print } ' -- cgit v1.2.3 From 46ca7f1d06bb85931877d2e43d00146e19664d45 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 10 Jun 2017 20:51:36 +1200 Subject: Unset command_not_found_handle in Bash startup --- bash/bashrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bash/bashrc b/bash/bashrc index 166fc501..7748b864 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -27,6 +27,9 @@ unalias -a ((10#${BASH_VERSINFO[1]%%[!0-9]*} < 5)) && return +# Clear away command_not_found_handle if a system bashrc file set it up +unset -f command_not_found_handle + # Keep around 32K lines of history in file HISTFILESIZE=$((1 << 15)) -- cgit v1.2.3 From 4f481eab630d97376723da28719f517b7ad08c44 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 10 Jun 2017 23:46:52 +1200 Subject: Makefile refactor Tried using the POSIX make on OpenIndiana and it got confused by the implicit dependencies, being a little more explicit seems to have coaxed it into working. --- Makefile | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index b302c217..516ddf68 100644 --- a/Makefile +++ b/Makefile @@ -198,7 +198,16 @@ BINS = bin/ap \ bin/xrbg \ bin/xrq -BINS_MI5 = bin/chn.sh \ +BINS_M4 = bin/chn.m4 \ + bin/edda.m4 \ + bin/pst.m4 \ + bin/rndl.m4 \ + bin/swr.m4 \ + bin/tlcs.m4 \ + bin/try.m4 \ + bin/urlc.m4 + +BINS_SH = bin/chn.sh \ bin/edda.sh \ bin/pst.sh \ bin/rndl.sh \ @@ -226,23 +235,9 @@ all: $(BINS) git/gitconfig gnupg/gpg.conf clean distclean: rm -f -- \ $(BINS) \ + $(BINS_M4) \ + $(BINS_SH) \ $(GAMES) \ - bin/chn.sh \ - bin/chn.m4 \ - bin/edda.sh \ - bin/edda.m4 \ - bin/pst.sh \ - bin/pst.m4 \ - bin/rndl.sh \ - bin/rndl.m4 \ - bin/swr.sh \ - bin/swr.m4 \ - bin/tlcs.sh \ - bin/tlcs.m4 \ - bin/try.sh \ - bin/try.m4 \ - bin/urlc.sh \ - bin/urlc.m4 \ git/gitconfig \ git/gitconfig.m4 \ gnupg/gpg.conf \ @@ -279,7 +274,14 @@ clean distclean: .m4.sh: m4 < $< > $@ -$(BINS_MI5): include/mktd.m4 +bin/chn.sh: bin/chn.m4 include/mktd.m4 +bin/edda.sh: bin/edda.m4 include/mktd.m4 +bin/pst.sh: bin/pst.m4 include/mktd.m4 +bin/rndl.sh: bin/rndl.m4 include/mktd.m4 +bin/swr.sh: bin/swr.m4 include/mktd.m4 +bin/tlcs.sh: bin/tlcs.m4 include/mktd.m4 +bin/try.sh: bin/try.m4 include/mktd.m4 +bin/urlc.sh: bin/urlc.m4 include/mktd.m4 git/gitconfig: git/gitconfig.m4 m4 \ @@ -501,7 +503,7 @@ check: check-bin \ check-bash: sh check/bash.sh -check-bin: $(BINS_MI5) +check-bin: $(BINS_SH) sh check/bin.sh check-games: -- cgit v1.2.3 From bb1be1379fd1150a083ad18c2354807f1b54eaf1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 10 Jun 2017 23:52:14 +1200 Subject: Force silence for Vim syntax enabling Might just be a peculiarity of OpenIndiana's build, but it raises an error as it tries to load nonexistent syntax files otherwise --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 1c1f2b26..87cf7868 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -47,8 +47,8 @@ endif if has('syntax') " Use syntax highlighting with 100 lines of context - syntax enable - syntax sync minlines=100 + silent! syntax enable + silent! syntax sync minlines=100 " Use my custom color scheme if possible, otherwise I'm happy with whatever " the default is, and it usually cares about my background -- cgit v1.2.3 From fa721fe3803d25e08dd5e8c034bea37351b5256c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 11 Jun 2017 00:18:55 +1200 Subject: Cut down the installation instructions a bit Nobody but me is ever gonna try using these on a SunOS derivative anyway, and if they did odds are pretty good they know how to suck eggs --- README.markdown | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/README.markdown b/README.markdown index bf25a40d..143bdb48 100644 --- a/README.markdown +++ b/README.markdown @@ -19,14 +19,8 @@ Installation $ make -n install $ make install -For the default `all` target, you'll need `make(1)`, `m4(1)`, and a -POSIX-fearing environment, including `sh(1)`. This should work on most -GNU/Linux and BSD systems, and possibly on other UNIX types, but those are not -as thoroughly or frequently tested. - -If you're on a system where `/bin/sh` is not a POSIX shell (e.g. OpenSolaris), -you may need to check you have e.g. `/usr/xpg4/bin` at the front of your -`$PATH` at build time. +For the default `all` target, you'll need a POSIX-fearing userland, including +`make(1)` and `m4(1)`. The installation `Makefile` will overwrite things standing in the way of its installed files without backing them up, so read the output of `make -n -- cgit v1.2.3 From f5e024daa0ff5d497dfe62d259c0cfebf29aa363 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 12 Jun 2017 12:29:18 +1200 Subject: Add fnp(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/fnp.sh | 23 +++++++++++++++++++++++ man/man1/fnp.1df | 24 ++++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 bin/fnp.sh create mode 100644 man/man1/fnp.1df diff --git a/.gitignore b/.gitignore index 3f2aeb76..36c16182 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ bin/exm bin/fgscr bin/finc bin/fnl +bin/fnp bin/gms bin/grc bin/grec diff --git a/Makefile b/Makefile index 516ddf68..d782cd2b 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,7 @@ BINS = bin/ap \ bin/fgscr \ bin/finc \ bin/fnl \ + bin/fnp \ bin/gms \ bin/grc \ bin/grec \ diff --git a/README.markdown b/README.markdown index 143bdb48..574d3ec3 100644 --- a/README.markdown +++ b/README.markdown @@ -476,6 +476,8 @@ Installed by the `install-bin` target: `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary files, printing their paths and line counts. +* `fnp(1df)` prints the given files to stdout, each with a plaintext heading + with the filename in it. * `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the script `getmails` in the `getmail` suite, but runs the requests in parallel and does up to three silent retries using `try(1df)`. diff --git a/bin/fnp.sh b/bin/fnp.sh new file mode 100644 index 00000000..ec68e51f --- /dev/null +++ b/bin/fnp.sh @@ -0,0 +1,23 @@ +# Print input, but include filenames as headings + +# Assume stdin if no options given +[ "$#" -gt 0 ] || set -- - + +# Iterate through arguments +for arg ; do + + # We'll print the filename "-stdin-" rather than - just to be slightly more + # explicit + case $arg in + -) fn=-stdin- ;; + *) fn=$arg ;; + esac + + [ -n "$tail" ] && printf '\n' + tail=1 + + # Form the underline; is there a nicer way to do this in POSIX sh? + ul=$(printf %s "$fn"|tr '[:print:]' -) + printf '%s\n%s\n\n' "$fn" "$ul" + cat -- "$arg" +done diff --git a/man/man1/fnp.1df b/man/man1/fnp.1df new file mode 100644 index 00000000..dc8a07c4 --- /dev/null +++ b/man/man1/fnp.1df @@ -0,0 +1,24 @@ +.TH FNP 1df "June 2017" "Manual page for fnp" +.SH NAME +.B fnp +\- print input with filename headings +.SH SYNOPSIS +.B fnp +FILE1 [FILE2...] +.br +prog1 | +.B +fnp +.br +prog1 | +.B +fnp +FILE1 - FILE2 +.SH DESCRIPTION +.B fnp +prints concatenated standard input from files to standard output, prepending a +filename title with an underline made of hyphen characters to each one. +.SH SEE ALSO +p(1df), pp(1df), pph(1df) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 6d3f615be93e68e892f5c3a1576d8a6d191ba6ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 12 Jun 2017 12:31:19 +1200 Subject: Add comment to p(1df) --- bin/p.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/p.sh b/bin/p.sh index 5b59986e..fec69e95 100644 --- a/bin/p.sh +++ b/bin/p.sh @@ -1 +1,2 @@ -exec cat -- "${@:--}" +# cat(1) as it always should have been +cat -- "${@:--}" -- cgit v1.2.3 From 9aa820e885ad639f1518914db298455d6fec3177 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 13 Jun 2017 21:13:56 +1200 Subject: Refactor m4 macro names mi5(1df) means I can simplify these quite a bit now --- Makefile | 16 ++++++++++------ git/gitconfig.mi5 | 8 ++++---- gnupg/gpg.conf.mi5 | 4 ++-- tmux/tmux.conf.mi5 | 6 +++--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index d782cd2b..32a61ef0 100644 --- a/Makefile +++ b/Makefile @@ -286,16 +286,18 @@ bin/urlc.sh: bin/urlc.m4 include/mktd.m4 git/gitconfig: git/gitconfig.m4 m4 \ - -D DF_NAME=$(NAME) \ - -D DF_EMAIL=$(EMAIL) \ - -D DF_KEY=$(KEY) \ - -D DF_SENDMAIL=$(SENDMAIL) \ + -D NAME=$(NAME) \ + -D EMAIL=$(EMAIL) \ + -D KEY=$(KEY) \ + -D SENDMAIL=$(SENDMAIL) \ git/gitconfig.m4 > $@ KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf: gnupg/gpg.conf.m4 - m4 -D DF_HOME=$(HOME) -D DF_KEYSERVER=$(KEYSERVER) \ + m4 \ + -D HOME=$(HOME) \ + -D KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > $@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header @@ -308,7 +310,9 @@ TMUX_BG = colour237 TMUX_FG = colour248 tmux/tmux.conf: tmux/tmux.conf.m4 - m4 -D DF_TMUX_BG=$(TMUX_BG) -D DF_TMUX_FG=$(TMUX_FG) \ + m4 \ + -D BG=$(TMUX_BG) \ + -D FG=$(TMUX_FG) \ tmux/tmux.conf.m4 > $@ install: install-bin \ diff --git a/git/gitconfig.mi5 b/git/gitconfig.mi5 index bce64d6c..5a50c13c 100644 --- a/git/gitconfig.mi5 +++ b/git/gitconfig.mi5 @@ -52,13 +52,13 @@ [sendemail] confirm = compose - smtpServer = <% DF_SENDMAIL %> + smtpServer = <% SENDMAIL %> [status] short = true showUntrackedFiles = all [user] - name = <% DF_NAME %> - email = <% DF_EMAIL %> - signingKey = <% DF_KEY %> + name = <% NAME %> + email = <% EMAIL %> + signingKey = <% KEY %> diff --git a/gnupg/gpg.conf.mi5 b/gnupg/gpg.conf.mi5 index d8f14c09..c6793b64 100644 --- a/gnupg/gpg.conf.mi5 +++ b/gnupg/gpg.conf.mi5 @@ -22,11 +22,11 @@ fixed-list-mode keyid-format 0xlong # Use a pool of servers which support HKPS (encrypted key retrieval) -keyserver DF_KEYSERVER +keyserver <% KEYSERVER %> # Retrieve keys automatically; check the keyserver port cert; use whichever # server is proffered from the pool -keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% DF_HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem +keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem # Include trust/validity for UIDs in listings list-options show-uid-validity diff --git a/tmux/tmux.conf.mi5 b/tmux/tmux.conf.mi5 index 76d493c1..8893cd3e 100644 --- a/tmux/tmux.conf.mi5 +++ b/tmux/tmux.conf.mi5 @@ -110,15 +110,15 @@ set-option -g message-style "bg=colour18,fg=colour231" set-window-option -g mode-style "bg=colour18,fg=colour231" # Pane borders are always in the background color -set-option -g pane-border-style "fg=<% DF_TMUX_BG %>" -set-option -g pane-active-border-style "fg=<% DF_TMUX_BG %>" +set-option -g pane-border-style "fg=<% BG %>" +set-option -g pane-active-border-style "fg=<% BG %>" # Inactive windows have slightly washed-out system colours set-option -g window-style "bg=colour232,fg=colour248" set-option -g window-active-style "bg=colour0,fg=colour15" # The status bar has the defined background and foreground colours -set-option -g status-style "bg=<% DF_TMUX_BG %>,fg=<% DF_TMUX_FG %>" +set-option -g status-style "bg=<% BG %>,fg=<% FG %>" # Titles of windows default to black text with no embellishment set-window-option -g window-status-style "fg=colour16" -- cgit v1.2.3 From 40de9a6c860631fcbc933228850f74d4aa367258 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 14 Jun 2017 13:13:47 +1200 Subject: Switch to using awk for line counting in dub(1df) Seems a bit nicer, passing the variable in as data rather than code --- bin/dub.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/dub.sh b/bin/dub.sh index c30749af..2dfd77f0 100644 --- a/bin/dub.sh +++ b/bin/dub.sh @@ -4,7 +4,7 @@ self=dub # First optional argument is the directory, defaulting to the # current dir; second optional argument is the number of files to # show, defaulting to 20 -dir=${1:-.} lines=${2:-10} +dir=${1:-.} lim=${2:-10} # Enter the target dir or bail cd -- "$dir" || exit @@ -24,4 +24,4 @@ find . ! -name . -prune \( \ sort -k1,1nr | # Limit the output to the given number of lines -sed "$((lines))"q +awk -v lim="$lim" 'NR<=lim' -- cgit v1.2.3 From 061afca31e04df2f5483d863d3b7ea5443588a53 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 14 Jun 2017 14:56:30 +1200 Subject: Keep articles for only 180 days Otherwise the Newsbeuter cache gets silly--if I really love an article that I think might disappear, I should save it --- newsbeuter/config | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/newsbeuter/config b/newsbeuter/config index 48f4110a..affbaa43 100644 --- a/newsbeuter/config +++ b/newsbeuter/config @@ -1,7 +1,8 @@ -auto-reload yes -confirm-exit yes -reload-threads 5 -reload-time 30 +auto-reload yes +confirm-exit yes +keep-articles-days 180 +reload-threads 5 +reload-time 30 bind-key j next bind-key k prev -- cgit v1.2.3 From 98cb922f49580e9e991db0e3f1f311eebbd5ac63 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 08:26:45 +1200 Subject: Correct GTK3 rc path --- Makefile | 4 ++-- gtk/gtk-3.0/settings.ini | 2 ++ gtk/gtkrc-3.0/settings.ini | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 gtk/gtk-3.0/settings.ini delete mode 100644 gtk/gtkrc-3.0/settings.ini diff --git a/Makefile b/Makefile index 32a61ef0..182396db 100644 --- a/Makefile +++ b/Makefile @@ -385,9 +385,9 @@ install-gnupg: gnupg/gpg.conf cp -p -- gnupg/sks-keyservers.net/* $(HOME)/.gnupg/sks-keyservers.net install-gtk: - mkdir -p -- $(HOME)/.config/gtkrc-3.0 + mkdir -p -- $(HOME)/.config/gtk-3.0 cp -p -- gtk/gtkrc-2.0 $(HOME)/.gtkrc-2.0 - cp -p -- gtk/gtkrc-3.0/settings.ini $(HOME)/.config/gtkrc-3.0 + cp -p -- gtk/gtk-3.0/settings.ini $(HOME)/.config/gtk-3.0 install-i3: install-x mkdir -p -- $(HOME)/.i3 diff --git a/gtk/gtk-3.0/settings.ini b/gtk/gtk-3.0/settings.ini new file mode 100644 index 00000000..4f93dfe4 --- /dev/null +++ b/gtk/gtk-3.0/settings.ini @@ -0,0 +1,2 @@ +[Settings] +gtk-theme-name = Clearlooks-Phenix diff --git a/gtk/gtkrc-3.0/settings.ini b/gtk/gtkrc-3.0/settings.ini deleted file mode 100644 index 4f93dfe4..00000000 --- a/gtk/gtkrc-3.0/settings.ini +++ /dev/null @@ -1,2 +0,0 @@ -[Settings] -gtk-theme-name = Clearlooks-Phenix -- cgit v1.2.3 From 051e1c22e9e29931068e342acad8ce690fa2a9a9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 09:43:12 +1200 Subject: Restore previous TMUX_BG/FG vars Bad decision --- Makefile | 4 ++-- tmux/tmux.conf.mi5 | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 182396db..50c1b939 100644 --- a/Makefile +++ b/Makefile @@ -311,8 +311,8 @@ TMUX_FG = colour248 tmux/tmux.conf: tmux/tmux.conf.m4 m4 \ - -D BG=$(TMUX_BG) \ - -D FG=$(TMUX_FG) \ + -D TMUX_BG=$(TMUX_BG) \ + -D TMUX_FG=$(TMUX_FG) \ tmux/tmux.conf.m4 > $@ install: install-bin \ diff --git a/tmux/tmux.conf.mi5 b/tmux/tmux.conf.mi5 index 8893cd3e..671523dc 100644 --- a/tmux/tmux.conf.mi5 +++ b/tmux/tmux.conf.mi5 @@ -110,15 +110,15 @@ set-option -g message-style "bg=colour18,fg=colour231" set-window-option -g mode-style "bg=colour18,fg=colour231" # Pane borders are always in the background color -set-option -g pane-border-style "fg=<% BG %>" -set-option -g pane-active-border-style "fg=<% BG %>" +set-option -g pane-border-style "fg=<% TMUX_BG %>" +set-option -g pane-active-border-style "fg=<% TMUX_BG %>" # Inactive windows have slightly washed-out system colours set-option -g window-style "bg=colour232,fg=colour248" set-option -g window-active-style "bg=colour0,fg=colour15" # The status bar has the defined background and foreground colours -set-option -g status-style "bg=<% BG %>,fg=<% FG %>" +set-option -g status-style "bg=<% TMUX_BG %>,fg=<% TMUX_FG %>" # Titles of windows default to black text with no embellishment set-window-option -g window-status-style "fg=colour16" -- cgit v1.2.3 From 33bf5e3e5ffc127854d77ddd648b6451cf3e96ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 13:54:28 +1200 Subject: Add missing `exit` call to igex(1df) --- bin/igex.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/igex.sh b/bin/igex.sh index 09f1206f..b8ef3092 100644 --- a/bin/igex.sh +++ b/bin/igex.sh @@ -3,6 +3,7 @@ # There should be at least two arguments if [ "$#" -eq 0 ] ; then printf >&2 'igs: Need an ignore list x,y,z and a command\n'; + exit 2 fi # The list of values to ignore is the first argument; add a trailing comma for -- cgit v1.2.3 From 94341e6d65c4ef4c7645f95ad40ee42f835c6069 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 13:59:47 +1200 Subject: Clean up some exit statuses --- bin/fnl.sh | 2 +- bin/shb.sh | 6 +++--- bin/xgo.sh | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/fnl.sh b/bin/fnl.sh index 8d771adb..86e582f1 100644 --- a/bin/fnl.sh +++ b/bin/fnl.sh @@ -3,7 +3,7 @@ # Check we have at least one argument if [ "$#" -eq 0 ] ; then printf >&2 'fnl: Command needed\n' - return 2 + exit 2 fi # Create a temporary directory; note that we *don't* clean it up on exit diff --git a/bin/shb.sh b/bin/shb.sh index 7d31876d..d0279ce3 100644 --- a/bin/shb.sh +++ b/bin/shb.sh @@ -1,10 +1,10 @@ # Use PATH to build a shebang for a script given on stdin self=shb -# Need at least two arguments +# Need at least one argument if [ "$#" -lt 1 ] ; then printf >&2 '%s: Need interpreter command\n' "$self" - exit 1 + exit 2 fi # First argument is the name of the interpreter @@ -23,4 +23,4 @@ set -- "$intp" "$@" printf '#!%s\n' "$*" # Emit the rest of the input -cat +cat - diff --git a/bin/xgo.sh b/bin/xgo.sh index 4d7cf922..3fb11fde 100644 --- a/bin/xgo.sh +++ b/bin/xgo.sh @@ -3,6 +3,7 @@ # Check arguments if [ "$#" -eq 0 ] ; then printf >&2 'xgo: At least one URL required\n' + exit 2 fi # Iterate over the URL arguments -- cgit v1.2.3 From 1d19ff7522f5d2f140c20810ae73fec1faeecafc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 14:01:11 +1200 Subject: Make han(1df) exit, not return --- bin/han.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/han.bash b/bin/han.bash index 97dc3a19..3c4f6637 100644 --- a/bin/han.bash +++ b/bin/han.bash @@ -5,10 +5,10 @@ self=han # due to leading zeroes and trailing letters in some 2.x version numbers (e.g. # 2.05a). # shellcheck disable=SC2128 -[ -n "$BASH_VERSINFO" ] || return +[ -n "$BASH_VERSINFO" ] || exit ((BASH_VERSINFO[0] == 2)) && ((10#${BASH_VERSINFO[1]%%[![:digit:]]*} < 5)) && - return + exit # Figure out the options with which we can call help; Bash >=4.0 has an -m # option which prints the help output in a man-page like format -- cgit v1.2.3 From bdb24d2c0d2cd697a81ee244ae3b6be7d148555e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 14:08:24 +1200 Subject: Stop tmux status line from forking so much I'd completely forgotten about this. Does away with the username, but I can live with that --- tmux/tmux.conf.mi5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux/tmux.conf.mi5 b/tmux/tmux.conf.mi5 index 671523dc..27ae1417 100644 --- a/tmux/tmux.conf.mi5 +++ b/tmux/tmux.conf.mi5 @@ -71,7 +71,7 @@ bind-key s choose-session set-option -g status-left '[#S] ' # Username, hostname, and the current date on the right side of the status bar -set-option -g status-right ' [#(whoami)@#H] #(date +"%F %T")' +set-option -g status-right ' [#H] %F %T' # Update the status bar every second set-option -g status-interval 1 -- cgit v1.2.3 From 73da0681ef299948f77c3e1c3452145012f31a3e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 14:56:14 +1200 Subject: Remove color/colour templating from tmux.conf tmux 2.4 added support for globs, which makes all of this templating nastiness go away: A user who wants custom settings (such as me on my work system) can just drop overrides into ~/.tmux.conf.d/something.conf and go home. --- .gitignore | 2 - Makefile | 8 ---- README.markdown | 4 -- tmux/tmux.conf | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tmux/tmux.conf.mi5 | 130 --------------------------------------------------- 5 files changed, 134 insertions(+), 144 deletions(-) create mode 100644 tmux/tmux.conf delete mode 100644 tmux/tmux.conf.mi5 diff --git a/.gitignore b/.gitignore index 36c16182..c4a552f8 100644 --- a/.gitignore +++ b/.gitignore @@ -160,6 +160,4 @@ gnupg/gpg.conf gnupg/gpg.conf.m4 include/mktd.m4 man/man7/dotfiles.7df -tmux/tmux.conf -tmux/tmux.conf.m4 urxvt/ext/select diff --git a/Makefile b/Makefile index 50c1b939..20d14b28 100644 --- a/Makefile +++ b/Makefile @@ -245,8 +245,6 @@ clean distclean: gnupg/gpg.conf.m4 \ include/mktd.m4 \ man/man8/dotfiles.7df \ - tmux/tmux.conf \ - tmux/tmux.conf.m4 \ urxvt/ext/select .awk: @@ -309,12 +307,6 @@ MAILDIR = $(HOME)/Mail TMUX_BG = colour237 TMUX_FG = colour248 -tmux/tmux.conf: tmux/tmux.conf.m4 - m4 \ - -D TMUX_BG=$(TMUX_BG) \ - -D TMUX_FG=$(TMUX_FG) \ - tmux/tmux.conf.m4 > $@ - install: install-bin \ install-curl \ install-ex \ diff --git a/README.markdown b/README.markdown index 574d3ec3..36add541 100644 --- a/README.markdown +++ b/README.markdown @@ -327,10 +327,6 @@ Note that the configuration presently uses a hard-coded 256-color colorscheme, and uses non-login shells, with an attempt to control the environment to stop shells thinking they have access to an X display. -The configuration file is created with `mi5(1df)` to allow specifying a color -theme. This is just because I use a different color for my work session. The -default is a dark grey. - The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into the default command if no arguments are given and sessions do already exist. My `~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key diff --git a/tmux/tmux.conf b/tmux/tmux.conf new file mode 100644 index 00000000..4acf6a3d --- /dev/null +++ b/tmux/tmux.conf @@ -0,0 +1,134 @@ +# Strip out a lot of machine and X11 dependent crap from the initial +# environment +set-environment -gru COLORFGBG +set-environment -gru COLORTERM +set-environment -gru DISPLAY +set-environment -gru SSH_CLIENT +set-environment -gru SSH_CONNECTION +set-environment -gru SSH_TTY +set-environment -gru WINDOWID + +# Otherwise, use the environment we had when we started; don't touch it during +# a session unless I specifically ask +set-option -g update-environment '' + +# Setting this makes each new pane a non-login shell, which suits me better +set-option -g default-command "$SHELL" + +# Expect a 256-color terminal +set-option -g default-terminal 'screen-256color' + +# Change the prefix to ^A rather than the default of ^B, because I'm a godless +# GNU Screen refugee, and also I like using ^B in my shell and in Vim more +unbind-key C-b +set-option -g prefix C-a +bind-key a send-prefix + +# Repeating the prefix switches to the last window and back, a GNU Screen +# feature that's hardwired into my brain now +bind-key C-a last-window + +# Quick ways to kill single windows and the whole server +bind-key '/' confirm-before 'kill-window' +bind-key '\' confirm-before 'kill-server' + +# Slightly more intuitive way to split windows +bind-key '_' split-window -v +bind-key '|' split-window -h + +# Switch to the last active pane +bind-key Tab last-pane + +# Use the vi mode for tmux interaction behaviour in copy and choice modes +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send -X begin-selection +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel + +# Detach with Alt-M, no prefix required +bind-key -n M-m detach + +# Vim-like pane resizing +bind-key -r '+' resize-pane -U 5 +bind-key -r '-' resize-pane -D 5 +bind-key -r '<' resize-pane -L 5 +bind-key -r '>' resize-pane -R 5 + +# Vim-like pane switching +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R + +# Join and break panes +bind-key J choose-window "join-pane -h -s '%%'" +bind-key B break-pane -d + +# Select only sessions in the choose-tree menu, not the whole tree of sessions +# and windows, I prefer to drill down +bind-key s choose-session + +# Session title on the left side of the status bar +set-option -g status-left '[#S] ' + +# Username, hostname, and the current date on the right side of the status bar +set-option -g status-right ' [#H] %F %T' + +# Update the status bar every second +set-option -g status-interval 1 + +# The first window in a session has index 1, rather than 0 +set-option -g base-index 1 + +# Don't worry about timeouts for key combinations, as I don't use Escape as +# meta and prefer things to be snappier +set-option -g escape-time 0 + +# Keep plenty of history +set-option -g history-limit 100000 + +# Don't interfere with my system clipboard +set-option -g set-clipboard off + +# Only force individual windows to the smallest attached terminal size, not +# whole sessions +set-window-option -g aggressive-resize on + +# If I don't set a title on a window, use the program name for the window title +set-window-option -g automatic-rename on + +# However, don't let terminal escape sequences rename my windows +set-window-option -g allow-rename off + +# Window titles are the window index, a colon, the window or command name, and +# any activity or alert indicators +set-window-option -g window-status-format "#I:#W#F" + +# Message dialogs are white on blue +set-option -g message-style "bg=colour18,fg=colour231" + +# Window choosers are white on blue +set-window-option -g mode-style "bg=colour18,fg=colour231" + +# Pane borders are always in the background color +set-option -g pane-border-style "fg=colour237" +set-option -g pane-active-border-style "fg=colour237" + +# Inactive windows have slightly washed-out system colours +set-option -g window-style "bg=colour232,fg=colour248" +set-option -g window-active-style "bg=colour0,fg=colour15" + +# The status bar has the defined background and foreground colours +set-option -g status-style "bg=colour237,fg=colour248" + +# Titles of windows default to black text with no embellishment +set-window-option -g window-status-style "fg=colour16" + +# The title of the active window is in white rather than black +set-window-option -g window-status-current-style "fg=colour231" + +# A window with a bell has a title with a red background until cleared +set-window-option -g window-status-bell-style "bg=colour9" + +# Source any configuration in the subdir if there is any +if-shell 'set -- "$HOME"/.tmux.conf.d/*;test -e "$1"' \ + 'source-file ~/.tmux.conf.d/*.conf' diff --git a/tmux/tmux.conf.mi5 b/tmux/tmux.conf.mi5 deleted file mode 100644 index 27ae1417..00000000 --- a/tmux/tmux.conf.mi5 +++ /dev/null @@ -1,130 +0,0 @@ -# Strip out a lot of machine and X11 dependent crap from the initial -# environment -set-environment -gru COLORFGBG -set-environment -gru COLORTERM -set-environment -gru DISPLAY -set-environment -gru SSH_CLIENT -set-environment -gru SSH_CONNECTION -set-environment -gru SSH_TTY -set-environment -gru WINDOWID - -# Otherwise, use the environment we had when we started; don't touch it during -# a session unless I specifically ask -set-option -g update-environment '' - -# Setting this makes each new pane a non-login shell, which suits me better -set-option -g default-command "$SHELL" - -# Expect a 256-color terminal -set-option -g default-terminal 'screen-256color' - -# Change the prefix to ^A rather than the default of ^B, because I'm a godless -# GNU Screen refugee, and also I like using ^B in my shell and in Vim more -unbind-key C-b -set-option -g prefix C-a -bind-key a send-prefix - -# Repeating the prefix switches to the last window and back, a GNU Screen -# feature that's hardwired into my brain now -bind-key C-a last-window - -# Quick ways to kill single windows and the whole server -bind-key '/' confirm-before 'kill-window' -bind-key '\' confirm-before 'kill-server' - -# Slightly more intuitive way to split windows -bind-key '_' split-window -v -bind-key '|' split-window -h - -# Switch to the last active pane -bind-key Tab last-pane - -# Use the vi mode for tmux interaction behaviour in copy and choice modes -set-window-option -g mode-keys vi -bind-key -T copy-mode-vi v send -X begin-selection -bind-key -T copy-mode-vi y send -X copy-selection-and-cancel - -# Detach with Alt-M, no prefix required -bind-key -n M-m detach - -# Vim-like pane resizing -bind-key -r '+' resize-pane -U 5 -bind-key -r '-' resize-pane -D 5 -bind-key -r '<' resize-pane -L 5 -bind-key -r '>' resize-pane -R 5 - -# Vim-like pane switching -bind-key h select-pane -L -bind-key j select-pane -D -bind-key k select-pane -U -bind-key l select-pane -R - -# Join and break panes -bind-key J choose-window "join-pane -h -s '%%'" -bind-key B break-pane -d - -# Select only sessions in the choose-tree menu, not the whole tree of sessions -# and windows, I prefer to drill down -bind-key s choose-session - -# Session title on the left side of the status bar -set-option -g status-left '[#S] ' - -# Username, hostname, and the current date on the right side of the status bar -set-option -g status-right ' [#H] %F %T' - -# Update the status bar every second -set-option -g status-interval 1 - -# The first window in a session has index 1, rather than 0 -set-option -g base-index 1 - -# Don't worry about timeouts for key combinations, as I don't use Escape as -# meta and prefer things to be snappier -set-option -g escape-time 0 - -# Keep plenty of history -set-option -g history-limit 100000 - -# Don't interfere with my system clipboard -set-option -g set-clipboard off - -# Only force individual windows to the smallest attached terminal size, not -# whole sessions -set-window-option -g aggressive-resize on - -# If I don't set a title on a window, use the program name for the window title -set-window-option -g automatic-rename on - -# However, don't let terminal escape sequences rename my windows -set-window-option -g allow-rename off - -# Window titles are the window index, a colon, the window or command name, and -# any activity or alert indicators -set-window-option -g window-status-format "#I:#W#F" - -# Message dialogs are white on blue -set-option -g message-style "bg=colour18,fg=colour231" - -# Window choosers are white on blue -set-window-option -g mode-style "bg=colour18,fg=colour231" - -# Pane borders are always in the background color -set-option -g pane-border-style "fg=<% TMUX_BG %>" -set-option -g pane-active-border-style "fg=<% TMUX_BG %>" - -# Inactive windows have slightly washed-out system colours -set-option -g window-style "bg=colour232,fg=colour248" -set-option -g window-active-style "bg=colour0,fg=colour15" - -# The status bar has the defined background and foreground colours -set-option -g status-style "bg=<% TMUX_BG %>,fg=<% TMUX_FG %>" - -# Titles of windows default to black text with no embellishment -set-window-option -g window-status-style "fg=colour16" - -# The title of the active window is in white rather than black -set-window-option -g window-status-current-style "fg=colour231" - -# A window with a bell has a title with a red background until cleared -set-window-option -g window-status-bell-style "bg=colour9" -- cgit v1.2.3 From 982762fb0cbdbfab1c3a778432c0a25d1574684c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 15:06:57 +1200 Subject: Remove now-unused TMUX_BG/FG vars --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 20d14b28..3b552fc1 100644 --- a/Makefile +++ b/Makefile @@ -304,9 +304,6 @@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header MAILDIR = $(HOME)/Mail -TMUX_BG = colour237 -TMUX_FG = colour248 - install: install-bin \ install-curl \ install-ex \ -- cgit v1.2.3 From 229d834928c053378578befa56367a96ab845f6b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 15:13:53 +1200 Subject: Use single quotes for expansions --- tmux/tmux.conf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 4acf6a3d..c469ea76 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -13,7 +13,7 @@ set-environment -gru WINDOWID set-option -g update-environment '' # Setting this makes each new pane a non-login shell, which suits me better -set-option -g default-command "$SHELL" +set-option -g default-command '$SHELL' # Expect a 256-color terminal set-option -g default-terminal 'screen-256color' @@ -60,7 +60,7 @@ bind-key k select-pane -U bind-key l select-pane -R # Join and break panes -bind-key J choose-window "join-pane -h -s '%%'" +bind-key J choose-window 'join-pane -h -s "%%"' bind-key B break-pane -d # Select only sessions in the choose-tree menu, not the whole tree of sessions @@ -101,33 +101,33 @@ set-window-option -g allow-rename off # Window titles are the window index, a colon, the window or command name, and # any activity or alert indicators -set-window-option -g window-status-format "#I:#W#F" +set-window-option -g window-status-format '#I:#W#F' # Message dialogs are white on blue -set-option -g message-style "bg=colour18,fg=colour231" +set-option -g message-style 'bg=colour18,fg=colour231' # Window choosers are white on blue -set-window-option -g mode-style "bg=colour18,fg=colour231" +set-window-option -g mode-style 'bg=colour18,fg=colour231' # Pane borders are always in the background color -set-option -g pane-border-style "fg=colour237" -set-option -g pane-active-border-style "fg=colour237" +set-option -g pane-border-style 'fg=colour237' +set-option -g pane-active-border-style 'fg=colour237' # Inactive windows have slightly washed-out system colours -set-option -g window-style "bg=colour232,fg=colour248" -set-option -g window-active-style "bg=colour0,fg=colour15" +set-option -g window-style 'bg=colour232,fg=colour248' +set-option -g window-active-style 'bg=colour0,fg=colour15' # The status bar has the defined background and foreground colours -set-option -g status-style "bg=colour237,fg=colour248" +set-option -g status-style 'bg=colour237,fg=colour248' # Titles of windows default to black text with no embellishment -set-window-option -g window-status-style "fg=colour16" +set-window-option -g window-status-style 'fg=colour16' # The title of the active window is in white rather than black -set-window-option -g window-status-current-style "fg=colour231" +set-window-option -g window-status-current-style 'fg=colour231' # A window with a bell has a title with a red background until cleared -set-window-option -g window-status-bell-style "bg=colour9" +set-window-option -g window-status-bell-style 'bg=colour9' # Source any configuration in the subdir if there is any if-shell 'set -- "$HOME"/.tmux.conf.d/*;test -e "$1"' \ -- cgit v1.2.3 From 73340e3fc3467c21257638979c670754ddd1fbda Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 15:19:53 +1200 Subject: Add an idea --- IDEAS.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 3b0f1c75..f267be12 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -12,3 +12,6 @@ Ideas processes and mkfifo(1). * Write something like hcat(1df) or tcat(1df) that includes filename headings for each concatenated file. +* I can probably get rid of all that nasty templated shell by writing + something that wraps around td(1df) and generates shell script to run, and + calls that via `eval`. -- cgit v1.2.3 From 44ebad54de0b77f93ff35c4d4920010ce3dca0aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 17:18:07 +1200 Subject: Simplify directory source-file --- tmux/tmux.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index c469ea76..09ba0251 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -130,5 +130,4 @@ set-window-option -g window-status-current-style 'fg=colour231' set-window-option -g window-status-bell-style 'bg=colour9' # Source any configuration in the subdir if there is any -if-shell 'set -- "$HOME"/.tmux.conf.d/*;test -e "$1"' \ - 'source-file ~/.tmux.conf.d/*.conf' +source-file -q ~/.tmux.conf.d/*.conf -- cgit v1.2.3 From 7c3f9cc6352a3352d80bec81501f223e2941a840 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 17:27:25 +1200 Subject: Switch to a maintained tmux Vim plugin --- .gitmodules | 2 +- vim/bundle/tmux | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 49bda51f..7b563654 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ url = https://sanctum.geek.nz/clone/targets.vim.git [submodule "vim/bundle/tmux"] path = vim/bundle/tmux - url = https://sanctum.geek.nz/code/vim-tmux.git + url = https://sanctum.geek.nz/clone/vim-tmux.git [submodule "vim/bundle/unimpaired"] path = vim/bundle/unimpaired url = https://sanctum.geek.nz/clone/vim-unimpaired.git diff --git a/vim/bundle/tmux b/vim/bundle/tmux index 663130a0..91b58c3f 160000 --- a/vim/bundle/tmux +++ b/vim/bundle/tmux @@ -1 +1 @@ -Subproject commit 663130a00e6d96b8e5d56051e8fe01d89521e317 +Subproject commit 91b58c3f0ded09b42566944c665176c53bbc010a -- cgit v1.2.3 From 9e83c417c509cd0ce94fc7be2bdb1eb85f01fa3d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Jun 2017 18:12:24 +1200 Subject: Remove Nagios and Tmux submodules Would be better to make this a rebased branch, if I version it at all really. No sense slowing Vim startup down a bit and making things complex for software that's only on a minority of my machines. --- .gitmodules | 6 ------ vim/bundle/nagios | 1 - vim/bundle/tmux | 1 - 3 files changed, 8 deletions(-) delete mode 160000 vim/bundle/nagios delete mode 160000 vim/bundle/tmux diff --git a/.gitmodules b/.gitmodules index 7b563654..5f908d04 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,9 +13,6 @@ [submodule "vim/bundle/lion"] path = vim/bundle/lion url = https://sanctum.geek.nz/clone/vim-lion.git -[submodule "vim/bundle/nagios"] - path = vim/bundle/nagios - url = https://sanctum.geek.nz/code/vim-nagios.git [submodule "vim/bundle/pathogen"] path = vim/bundle/pathogen url = https://sanctum.geek.nz/clone/vim-pathogen.git @@ -31,9 +28,6 @@ [submodule "vim/bundle/targets"] path = vim/bundle/targets url = https://sanctum.geek.nz/clone/targets.vim.git -[submodule "vim/bundle/tmux"] - path = vim/bundle/tmux - url = https://sanctum.geek.nz/clone/vim-tmux.git [submodule "vim/bundle/unimpaired"] path = vim/bundle/unimpaired url = https://sanctum.geek.nz/clone/vim-unimpaired.git diff --git a/vim/bundle/nagios b/vim/bundle/nagios deleted file mode 160000 index 3a9d5c4a..00000000 --- a/vim/bundle/nagios +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3a9d5c4a1428d193a4d2db97f042fa9afccdd26a diff --git a/vim/bundle/tmux b/vim/bundle/tmux deleted file mode 160000 index 91b58c3f..00000000 --- a/vim/bundle/tmux +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 91b58c3f0ded09b42566944c665176c53bbc010a -- cgit v1.2.3 From 789be63677aab5efa526dc7144283bac91b7a757 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 16 Jun 2017 20:39:59 +1200 Subject: Allow setting a prompt mode for the shell --- bash/bashrc.d/prompt.bash | 4 ++-- ksh/kshrc.d/prompt.ksh | 4 ++-- zsh/zshrc.d/prompt.zsh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index f64355f7..4dede32b 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -249,5 +249,5 @@ prompt() { esac } -# Start with full-fledged prompt -prompt on +# Default to a full-featured prompt, but use PROMPT_MODE if that's set +prompt "${PROMPT_MODE:-on}" diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 1d4db926..1aa05ae3 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -234,5 +234,5 @@ function prompt { esac } -# Start with full-fledged prompt -prompt on +# Default to a full-featured prompt, but use PROMPT_MODE if that's set +prompt "${PROMPT_MODE:-on}" diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index 446e336e..6ff82cec 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -207,5 +207,5 @@ prompt() { esac } -# Start with full-fledged prompt -prompt on +# Default to a full-featured prompt, but use PROMPT_MODE if that's set +prompt "${PROMPT_MODE:-on}" -- cgit v1.2.3 From 352a33c76a2833d353c707d95d7561f93a03cb8a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 18 Jun 2017 16:18:17 +1200 Subject: Refactor mpd/ncmpcpp stuff completely This has been neglected. Switch to per-user mpd process instantiated on login via .profile.d. Cut back ncmpcpp config until I have time to write one that's compatible with 0.8. --- Makefile | 8 +++++++- lint/sh.sh | 3 ++- mpd/mpdconf | 15 +++++++++++++++ mpd/profile.d/mpd.sh | 2 ++ ncmpcpp/config | 25 +------------------------ 5 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 mpd/mpdconf create mode 100644 mpd/profile.d/mpd.sh diff --git a/Makefile b/Makefile index 3b552fc1..65e85ffc 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ install-ksh \ install-less \ install-login-shell \ + install-mpd \ install-mutt \ install-mysql \ install-ncmcpp \ @@ -386,12 +387,17 @@ install-less: cp -p -- less/lesskey $(HOME)/.lesskey lesskey +install-mpd: install-sh + mkdir -p -- $(HOME)/.profile.d $(HOME)/.mpd $(HOME)/.mpd/playlists + cp -p .. mpd/profile.d/mpd.sh $(HOME)/.profile.d + cp -p -- mpd/mpdconf $(HOME)/.mpdconf + install-mutt: mkdir -p -- $(HOME)/.muttrc.d $(HOME)/.cache/mutt cp -p -- mutt/muttrc $(HOME)/.muttrc cp -p -- mutt/muttrc.d/src $(HOME)/.muttrc.d -install-ncmcpp: +install-ncmcpp: install-mpd mkdir -p -- $(HOME)/.ncmpcpp cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp diff --git a/lint/sh.sh b/lint/sh.sh index 632585bf..ccf4cc7f 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1 +1,2 @@ -find sh -type f -print -exec shellcheck -e SC1090 -s sh -- {} + +find sh ksh/shrc.d mpd/profile.d \ + -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/mpd/mpdconf b/mpd/mpdconf new file mode 100644 index 00000000..3dca8b6d --- /dev/null +++ b/mpd/mpdconf @@ -0,0 +1,15 @@ +bind_to_address "~/.mpd/socket" + +db_file "~/.mpd/database" +log_file "~/.mpd/log" + +music_directory "/mnt/media/shares/music" +playlist_directory "~/.mpd/playlists" +pid_file "~/.mpd/pid" +state_file "~/.mpd/state" +sticker_file "~/.mpd/sticker.sql" + +audio_output { + type "pulse" + name "PulseAudio" +} diff --git a/mpd/profile.d/mpd.sh b/mpd/profile.d/mpd.sh new file mode 100644 index 00000000..e8ab36c6 --- /dev/null +++ b/mpd/profile.d/mpd.sh @@ -0,0 +1,2 @@ +# Start an mpd process if one isn't already running +[ -s "$HOME"/.mpd/pid ] || mpd diff --git a/ncmpcpp/config b/ncmpcpp/config index eb4f2120..7e865a8f 100644 --- a/ncmpcpp/config +++ b/ncmpcpp/config @@ -2,30 +2,7 @@ ncmpcpp_directory = "~/.ncmpcpp" # Server specifics -mpd_host = "localhost" -mpd_port = "6600" -mpd_communication_mode = "notifications" -mpd_connection_timeout = "5" -mpd_crossfade_time = "5" +mpd_host = "~/.mpd/socket" # No mouse, it confuses tmux/urxvt, and I never use it anyway mouse_support = "no" - -# Visualization -visualizer_fifo_path = "/tmp/mpd.fifo" -visualizer_in_stereo = "yes" -visualizer_look = "*|" -visualizer_output_name = "FIFO" -visualizer_sync_interval = "30" -visualizer_type = "spectrum" - -# Use columns everywhere -browser_display_mode = "columns" -playlist_display_mode = "columns" -playlist_editor_display_mode = "columns" -search_engine_display_mode = "columns" -song_columns_list_format = "(40)[]{t|f} (25)[blue]{a} (25)[red]{b} (10)[green]{lr}" - -# Don't let me actually delete anything -allow_physical_directories_deletion = "no" -allow_physical_files_deletion = "no" -- cgit v1.2.3 From 9988f4033dd0af225e65b631e585032c57e15e11 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 18 Jun 2017 16:24:18 +1200 Subject: Break plenv stuff into its own target --- Makefile | 7 ++++++- plenv/profile.d/plenv.sh | 5 +++++ plenv/shrc.d/plenv.sh | 17 +++++++++++++++++ sh/profile.d/plenv.sh | 5 ----- sh/shrc.d/plenv.sh | 17 ----------------- 5 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 plenv/profile.d/plenv.sh create mode 100644 plenv/shrc.d/plenv.sh delete mode 100644 sh/profile.d/plenv.sh delete mode 100644 sh/shrc.d/plenv.sh diff --git a/Makefile b/Makefile index 65e85ffc..36273e54 100644 --- a/Makefile +++ b/Makefile @@ -389,7 +389,7 @@ install-less: install-mpd: install-sh mkdir -p -- $(HOME)/.profile.d $(HOME)/.mpd $(HOME)/.mpd/playlists - cp -p .. mpd/profile.d/mpd.sh $(HOME)/.profile.d + cp -p .. mpd/profile.d/* $(HOME)/.profile.d cp -p -- mpd/mpdconf $(HOME)/.mpdconf install-mutt: @@ -423,6 +423,11 @@ install-perlcritic: install-perltidy: cp -p -- perltidy/perltidyrc $(HOME)/.perltidyrc +install-plenv: + mkdir -p -- $(HOME)/.profile.d/ $(HOME)/.shrc.d + cp -p -- plenv/profile.d/* $(HOME)/.profile.d + cp -p -- plenv/shrc.d/* $(HOME)/.shrc.d + install-psql: cp -p -- psql/psqlrc $(HOME)/.psqlrc diff --git a/plenv/profile.d/plenv.sh b/plenv/profile.d/plenv.sh new file mode 100644 index 00000000..b2b491e1 --- /dev/null +++ b/plenv/profile.d/plenv.sh @@ -0,0 +1,5 @@ +# Add plenv to PATH and MANPATH if it appears to be in use +[ -d "$HOME"/.plenv ] || return +PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH +MANPATH=$HOME/.plenv/versions/$(perl -e 'print substr($^V,1)')/man:$MANPATH +export MANPATH diff --git a/plenv/shrc.d/plenv.sh b/plenv/shrc.d/plenv.sh new file mode 100644 index 00000000..6e03618e --- /dev/null +++ b/plenv/shrc.d/plenv.sh @@ -0,0 +1,17 @@ +# POSIX-compatible version of the plenv Bash shell wrapper +[ -d "$HOME"/.plenv ] || return +plenv() { + case $1 in + rehash) + shift + eval "$(plenv sh-rehash "$@")" + ;; + shell) + shift + eval "$(plenv sh-shell "$@")" + ;; + *) + command plenv "$@" + ;; + esac +} diff --git a/sh/profile.d/plenv.sh b/sh/profile.d/plenv.sh deleted file mode 100644 index b2b491e1..00000000 --- a/sh/profile.d/plenv.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Add plenv to PATH and MANPATH if it appears to be in use -[ -d "$HOME"/.plenv ] || return -PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH -MANPATH=$HOME/.plenv/versions/$(perl -e 'print substr($^V,1)')/man:$MANPATH -export MANPATH diff --git a/sh/shrc.d/plenv.sh b/sh/shrc.d/plenv.sh deleted file mode 100644 index 6e03618e..00000000 --- a/sh/shrc.d/plenv.sh +++ /dev/null @@ -1,17 +0,0 @@ -# POSIX-compatible version of the plenv Bash shell wrapper -[ -d "$HOME"/.plenv ] || return -plenv() { - case $1 in - rehash) - shift - eval "$(plenv sh-rehash "$@")" - ;; - shell) - shift - eval "$(plenv sh-shell "$@")" - ;; - *) - command plenv "$@" - ;; - esac -} -- cgit v1.2.3 From 4722948a5657d3a2596d408d551ab03c5085d0ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 18 Jun 2017 16:30:14 +1200 Subject: More segmentation/tidying --- Makefile | 11 +++++++---- keychain/profile.d/keychain.sh | 5 +++++ keychain/shrc.d/keychain.sh | 4 ++++ mpd/profile.d/mpd.sh | 1 + sh/profile.d/keychain.sh | 5 ----- sh/shrc.d/keychain.sh | 4 ---- 6 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 keychain/profile.d/keychain.sh create mode 100644 keychain/shrc.d/keychain.sh delete mode 100644 sh/profile.d/keychain.sh delete mode 100644 sh/shrc.d/keychain.sh diff --git a/Makefile b/Makefile index 36273e54..d498f4c6 100644 --- a/Makefile +++ b/Makefile @@ -383,12 +383,16 @@ install-i3: install-x mkdir -p -- $(HOME)/.i3 cp -p -- i3/* $(HOME)/.i3 +install-keychain: install-sh + cp -p -- keychain/profile.d/* $(HOME)/.profile.d + cp -p -- keychain/shrc.d/* $(HOME)/.shrc.d + install-less: cp -p -- less/lesskey $(HOME)/.lesskey lesskey install-mpd: install-sh - mkdir -p -- $(HOME)/.profile.d $(HOME)/.mpd $(HOME)/.mpd/playlists + mkdir -p -- $(HOME)/.mpd/playlists cp -p .. mpd/profile.d/* $(HOME)/.profile.d cp -p -- mpd/mpdconf $(HOME)/.mpdconf @@ -409,7 +413,7 @@ install-mysql: cp -p -- mysql/my.cnf $(HOME)/.my.cnf install-ksh: check-ksh install-sh - mkdir -p -- $(HOME)/.shrc.d $(HOME)/.kshrc.d + mkdir -p -- $(HOME)/.kshrc.d cp -p -- ksh/shrc.d/* $(HOME)/.shrc.d cp -p -- ksh/kshrc $(HOME)/.kshrc cp -p -- ksh/kshrc.d/* $(HOME)/.kshrc.d @@ -423,8 +427,7 @@ install-perlcritic: install-perltidy: cp -p -- perltidy/perltidyrc $(HOME)/.perltidyrc -install-plenv: - mkdir -p -- $(HOME)/.profile.d/ $(HOME)/.shrc.d +install-plenv: install-sh cp -p -- plenv/profile.d/* $(HOME)/.profile.d cp -p -- plenv/shrc.d/* $(HOME)/.shrc.d diff --git a/keychain/profile.d/keychain.sh b/keychain/profile.d/keychain.sh new file mode 100644 index 00000000..f3d25c62 --- /dev/null +++ b/keychain/profile.d/keychain.sh @@ -0,0 +1,5 @@ +# keychain setup +command -v keychain >/dev/null 2>&1 || return +eval "$(TERM=${TERM:-ansi} keychain \ + --eval --ignore-missing --quick --quiet \ + id_dsa id_rsa id_ecsda)" diff --git a/keychain/shrc.d/keychain.sh b/keychain/shrc.d/keychain.sh new file mode 100644 index 00000000..9a732384 --- /dev/null +++ b/keychain/shrc.d/keychain.sh @@ -0,0 +1,4 @@ +# If GPG_AGENT_INFO is set, update GPG_TTY for clean use of pinentry(1) etc +[ -n "$GPG_AGENT_INFO" ] || return +GPG_TTY=$(command -p tty) || return +export GPG_TTY diff --git a/mpd/profile.d/mpd.sh b/mpd/profile.d/mpd.sh index e8ab36c6..daa55af6 100644 --- a/mpd/profile.d/mpd.sh +++ b/mpd/profile.d/mpd.sh @@ -1,2 +1,3 @@ # Start an mpd process if one isn't already running +command mpd >/dev/null 2>&1 || return [ -s "$HOME"/.mpd/pid ] || mpd diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh deleted file mode 100644 index f3d25c62..00000000 --- a/sh/profile.d/keychain.sh +++ /dev/null @@ -1,5 +0,0 @@ -# keychain setup -command -v keychain >/dev/null 2>&1 || return -eval "$(TERM=${TERM:-ansi} keychain \ - --eval --ignore-missing --quick --quiet \ - id_dsa id_rsa id_ecsda)" diff --git a/sh/shrc.d/keychain.sh b/sh/shrc.d/keychain.sh deleted file mode 100644 index 9a732384..00000000 --- a/sh/shrc.d/keychain.sh +++ /dev/null @@ -1,4 +0,0 @@ -# If GPG_AGENT_INFO is set, update GPG_TTY for clean use of pinentry(1) etc -[ -n "$GPG_AGENT_INFO" ] || return -GPG_TTY=$(command -p tty) || return -export GPG_TTY -- cgit v1.2.3 From f372b831ed58b0c1abf41e90ac2560508e849960 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 18 Jun 2017 16:35:55 +1200 Subject: Update check/lint sh --- check/sh.sh | 8 +++++++- lint/sh.sh | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/check/sh.sh b/check/sh.sh index 53d8c4b6..c5a86955 100644 --- a/check/sh.sh +++ b/check/sh.sh @@ -1,4 +1,10 @@ -for sh in sh/* sh/profile.d/* sh/shrc.d/* ; do +for sh in \ + sh/* sh/profile.d/* sh/shrc.d/* \ + keychain/profile.d/* keychain/shrc.d/* \ + ksh/shrc.d/* \ + mpd/profile.d/* \ + plenv/profile.d/* plenv/shrc.d/* \ +; do [ -f "$sh" ] || continue sh -n "$sh" || exit done diff --git a/lint/sh.sh b/lint/sh.sh index ccf4cc7f..89704c0b 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1,2 +1,6 @@ -find sh ksh/shrc.d mpd/profile.d \ +find sh \ + keychain/profile.d keychain/shrc.d \ + ksh/shrc.d \ + mpd/profile.d \ + plenv/profile.d plenv/shrc.d \ -type f -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 From e71182ce0b1076f52799534bfed023c75e03e412 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 19 Jun 2017 00:28:06 +1200 Subject: Remove user@ prefix from prompt --- README.markdown | 16 ++++++++-------- bash/bashrc.d/prompt.bash | 4 ++-- ksh/kshrc.d/prompt.ksh | 4 ++-- sh/shrc.d/prompt.sh | 4 ++-- zsh/zshrc.d/prompt.zsh | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.markdown b/README.markdown index 36add541..bd4d482a 100644 --- a/README.markdown +++ b/README.markdown @@ -141,20 +141,20 @@ after testing `BASH_VERSINFO` appropriately. A terminal session with my prompt looks something like this: ~$ ssh remote - tom@remote:~$ cd .dotfiles - tom@remote:~/.dotfiles(master+!)$ git status + remote:~$ cd .dotfiles + remote:~/.dotfiles(master+!)$ git status M README.markdown M bash/bashrc.d/prompt.bash A init - tom@remote:~/.dotfiles(master+!)$ foobar + remote:~/.dotfiles(master+!)$ foobar foobar: command not found - tom@remote:~/.dotfiles(master+!)<127>$ sleep 5 & + remote:~/.dotfiles(master+!)<127>$ sleep 5 & [1] 28937 - tom@remote:~/.dotfiles(master+!){1}$ + remote:~/.dotfiles(master+!){1}$ -The username and hostname are elided if not connected via SSH. The working -directory with tilde abbreviation for `$HOME` is always shown. The rest of the -prompt expands based on context to include these elements in this order: +The hostname is elided if not connected via SSH. The working directory with +tilde abbreviation for `$HOME` is always shown. The rest of the prompt expands +based on context to include these elements in this order: * Whether in a Git repository if applicable, and punctuation to show repository status including reference to upstreams at a glance. Subversion diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 4dede32b..782af287 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -15,7 +15,7 @@ prompt() { # Basic prompt shape depends on whether we're in SSH or not PS1= if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then - PS1=$PS1'\u@\h:' + PS1=$PS1'\h:' fi PS1=$PS1'\w' @@ -86,7 +86,7 @@ prompt() { PS3='? ' PS4='+ ' if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then - PS1=$(id -nu)'@'$(hostname -s)'$ ' + PS1=$(hostname -s)'$ ' fi ;; diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 1aa05ae3..866cf79e 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -15,7 +15,7 @@ function prompt { # Basic prompt shape depends on whether we're in SSH or not PS1= if [[ -n $SSH_CLIENT ]] || [[ -n $SSH_CONNECTION ]] ; then - PS1=$PS1'$USER@${HOSTNAME%%.*}:' + PS1=$PS1'${HOSTNAME%%.*}:' fi # Add sub-commands; working directory with ~ abbreviation, VCS, job @@ -193,7 +193,7 @@ function prompt { PS3='? ' PS4='+ ' if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then - PS1=$(id -nu)'@'$(hostname -s)'$ ' + PS1=$(hostname -s)'$ ' fi ;; diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh index f1b67fb4..6f1e8e1f 100644 --- a/sh/shrc.d/prompt.sh +++ b/sh/shrc.d/prompt.sh @@ -5,7 +5,7 @@ unset PS1 PS2 PS3 PS4 PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' # If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the -# username and hostname in PS1 too. +# hostname in PS1 too. if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then - PS1=$(id -nu)'@'$(hostname)'$ ' + PS1=$(hostname)'$ ' fi diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index 6ff82cec..7c695e25 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -11,7 +11,7 @@ prompt() { # Basic prompt shape depends on whether we're in SSH or not PS1= if [[ -n $SSH_CLIENT ]] || [[ -n $SSH_CONNECTION ]] ; then - PS1=$PS1'%n@%m:' + PS1=$PS1'%m:' fi PS1=$PS1'%~' @@ -49,7 +49,7 @@ prompt() { PS3='? ' PS4='+ ' if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then - PS1=$(id -nu)'@'$(hostname -s)'$ ' + PS1=$(hostname -s)'$ ' fi ;; -- cgit v1.2.3 From 28249853f3c77c4f50b64b4f45c2d5a2c800c34f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 19 Jun 2017 12:46:06 +1200 Subject: Clean up drakon(6df) a bit --- games/drakon.awk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/games/drakon.awk b/games/drakon.awk index b8d72888..ce619585 100644 --- a/games/drakon.awk +++ b/games/drakon.awk @@ -1,14 +1,14 @@ # TyPe lIkE AnDoR DrAkOn fRoM AnCiEnT DoMaInS Of mYsTeRy # { - len = length - line = "" - toggle = 0 + len = length($0) + lin = "" + tog = 0 for (i = 1; i <= len; i++) { - char = substr($0, i, 1) - if (char ~ /[[:alpha:]]/) - char = (toggle = !toggle) ? tolower(char) : toupper(char) - line = line char + chr = substr($0, i, 1) + if (chr ~ /[[:alpha:]]/) + chr = (tog = !tog) ? tolower(chr) : toupper(chr) + lin = lin chr } - print line + print lin } -- cgit v1.2.3 From b68feacb05cef1ecc41fe55460a8e1028cedb12a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 23 Jun 2017 08:28:00 +1200 Subject: Add ed() options file check --- sh/shrc.d/ed.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index a2b7818e..e6b6eee8 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -1,3 +1,7 @@ +# Our ~/.profile should already have made a directory with the supported +# options for us; if not, we won't be wrapping ed(1) with a function at all +[ -d "$HOME"/.cache/sh/opt/ed ] || return + # Define function proper ed() { -- cgit v1.2.3 From a62fb7bac4a43c105c54fd19511b7fe9ae6cc706 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 23 Jun 2017 08:28:11 +1200 Subject: Fix up an error message --- sh/shrc.d/hgrep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/hgrep.sh b/sh/shrc.d/hgrep.sh index fe297ab3..9d7542b4 100644 --- a/sh/shrc.d/hgrep.sh +++ b/sh/shrc.d/hgrep.sh @@ -9,7 +9,7 @@ hgrep() { return 2 fi if [ -z "$HISTFILE" ] ; then - printf >&2 'hgrep(): No HISTFILE\n' + printf >&2 'hgrep(): HISTFILE unset or null\n' return 2 fi grep "$@" "$HISTFILE" -- cgit v1.2.3 From 507989e6476732224836d9a948713ce283893563 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 23 Jun 2017 20:05:13 +1200 Subject: Add a simple wgetrc Mostly use cURL admittedly, but these look sensible --- Makefile | 4 ++++ wget/wgetrc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 wget/wgetrc diff --git a/Makefile b/Makefile index d498f4c6..38d54d07 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ install-vim-gui-config \ install-vim-pathogen \ install-vim-plugins \ + install-wget \ install-x \ install-zsh \ check \ @@ -483,6 +484,9 @@ install-vim-pathogen: install-vim-plugins mkdir -p -- $(HOME)/.vim/autoload ln -fs -- ../bundle/pathogen/autoload/pathogen.vim $(HOME)/.vim/autoload +install-wget: + cp -p -- wget/wgetrc $(HOME)/.wgetrc + install-x: check-xinit mkdir -p -- \ $(HOME)/.config \ diff --git a/wget/wgetrc b/wget/wgetrc new file mode 100644 index 00000000..eb3f20ba --- /dev/null +++ b/wget/wgetrc @@ -0,0 +1,14 @@ +# No, no, dig UP, stupid +no_parent = on + +# Don't take no for an answer +retry_connrefused = on + +# It's the only thing that works against the machines +robots = off + +# Shorten default timeout +timeout = 60 + +# Reduce default number of attempts +tries = 3 -- cgit v1.2.3 From e9d23be08cd4c755c9c0bdba1f585144f1338ef2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 24 Jun 2017 12:21:18 +1200 Subject: Add a caveat to trs(1df) --- bin/trs.awk | 2 +- man/man1/trs.1df | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/trs.awk b/bin/trs.awk index 5966c520..8d0a1ef0 100644 --- a/bin/trs.awk +++ b/bin/trs.awk @@ -1,4 +1,4 @@ -# Substitute one string for another in input (no regex) +# Substitute one string for another in input (no newlines, no regex) BEGIN { # Name self self = "trs" diff --git a/man/man1/trs.1df b/man/man1/trs.1df index fa5d2d19..93b2cad3 100644 --- a/man/man1/trs.1df +++ b/man/man1/trs.1df @@ -19,5 +19,7 @@ implementations. It is thereby the string complement for tr(1). The first argument cannot be a null string. The second argument can be blank (but must still be specified) to implicitly delete all occurrences of the string. +.SH CAVEATS +It can't replace newlines. .SH AUTHOR Tom Ryder -- cgit v1.2.3 From 3cc9a3d4d72c0335895f2bf9678eac2b24d425ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 24 Jun 2017 16:21:33 +1200 Subject: Use short hostname in default prompt --- sh/shrc.d/prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh index 6f1e8e1f..30e4e9d8 100644 --- a/sh/shrc.d/prompt.sh +++ b/sh/shrc.d/prompt.sh @@ -7,5 +7,5 @@ PS1='$ ' PS2='> ' PS3='? ' PS4='+ ' # If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the # hostname in PS1 too. if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then - PS1=$(hostname)'$ ' + PS1=$(hostname -s)'$ ' fi -- cgit v1.2.3 From 33fd4598238bc74e23c80d0cd6234f3702327e25 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 25 Jun 2017 01:23:26 +1200 Subject: Remove deprecated keyserver options > gpg: keyserver option 'check-cert' is obsolete > gpg: keyserver option 'ca-certfile' is unknown > gpg (GnuPG) 2.1.18 > libgcrypt 1.7.6-beta > Copyright (C) 2017 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > > Home: /home/tom/.gnupg > Supported algorithms: > Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA > Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, > CAMELLIA128, CAMELLIA192, CAMELLIA256 > Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 > Compression: Uncompressed, ZIP, ZLIB, BZIP2 --- Makefile | 4 +-- gnupg/gpg.conf.mi5 | 2 +- gnupg/sks-keyservers.net/README.markdown | 9 ------ gnupg/sks-keyservers.net/crl.pem | 27 ------------------ gnupg/sks-keyservers.net/sks-keyservers.netCA.pem | 32 ---------------------- .../sks-keyservers.netCA.pem.asc | 16 ----------- 6 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 gnupg/sks-keyservers.net/README.markdown delete mode 100644 gnupg/sks-keyservers.net/crl.pem delete mode 100644 gnupg/sks-keyservers.net/sks-keyservers.netCA.pem delete mode 100644 gnupg/sks-keyservers.net/sks-keyservers.netCA.pem.asc diff --git a/Makefile b/Makefile index 38d54d07..d28bf613 100644 --- a/Makefile +++ b/Makefile @@ -296,7 +296,6 @@ KEYSERVER = hkps://hkps.pool.sks-keyservers.net gnupg/gpg.conf: gnupg/gpg.conf.m4 m4 \ - -D HOME=$(HOME) \ -D KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > $@ @@ -371,9 +370,8 @@ install-git: git/gitconfig cp -p -- git/gitconfig $(HOME)/.gitconfig install-gnupg: gnupg/gpg.conf - mkdir -m 0700 -p -- $(HOME)/.gnupg $(HOME)/.gnupg/sks-keyservers.net + mkdir -m 0700 -p -- $(HOME)/.gnupg cp -p -- gnupg/*.conf $(HOME)/.gnupg - cp -p -- gnupg/sks-keyservers.net/* $(HOME)/.gnupg/sks-keyservers.net install-gtk: mkdir -p -- $(HOME)/.config/gtk-3.0 diff --git a/gnupg/gpg.conf.mi5 b/gnupg/gpg.conf.mi5 index c6793b64..1617a979 100644 --- a/gnupg/gpg.conf.mi5 +++ b/gnupg/gpg.conf.mi5 @@ -26,7 +26,7 @@ keyserver <% KEYSERVER %> # Retrieve keys automatically; check the keyserver port cert; use whichever # server is proffered from the pool -keyserver-options auto-key-retrieve check-cert no-honor-keyserver-url ca-certfile=<% HOME %>/.gnupg/sks-keyservers.net/sks-keyservers.netCA.pem +keyserver-options auto-key-retrieve no-honor-keyserver-url # Include trust/validity for UIDs in listings list-options show-uid-validity diff --git a/gnupg/sks-keyservers.net/README.markdown b/gnupg/sks-keyservers.net/README.markdown deleted file mode 100644 index bb19e80e..00000000 --- a/gnupg/sks-keyservers.net/README.markdown +++ /dev/null @@ -1,9 +0,0 @@ -sks-keyservers.net CA, CRL, and signature -========================================= - -These files are downloaded from links on the [sks-keyservers.net][1] overview -page. I've included both their signature file and the revocation list, but it's -your responsibility to make sure that everything here is verified to your -satisfaction. - -[1]: https://sks-keyservers.net/overview-of-pools.php diff --git a/gnupg/sks-keyservers.net/crl.pem b/gnupg/sks-keyservers.net/crl.pem deleted file mode 100644 index ce8cd7a8..00000000 --- a/gnupg/sks-keyservers.net/crl.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN X509 CRL----- -MIIEhzCCAm8CAQEwDQYJKoZIhvcNAQELBQAwXDELMAkGA1UEBhMCTk8xDTALBgNV -BAgMBE9zbG8xHjAcBgNVBAoMFXNrcy1rZXlzZXJ2ZXJzLm5ldCBDQTEeMBwGA1UE -AwwVc2tzLWtleXNlcnZlcnMubmV0IENBFw0xNjA4MDgxOTMwMjdaFw0xNzAyMDQx -OTMwMjdaMIIBzDASAgEBFw0xMjEwMDkwMTAyMDVaMBICAQIXDTEyMTAwOTAxMDIw -NVowEgIBAxcNMTQwNTAxMTEyMDU2WjASAgEEFw0xMjEwMDkwMTAyMDVaMBICAQgX -DTE0MDUwNjE4MjQzMVowEgIBDBcNMTQwNjI4MTI0NTU2WjASAgERFw0xNDA0MjYx -MjU4MjdaMBICARMXDTEzMTExMzE5MzczM1owEgIBFBcNMTQwNDI5MTczNDA0WjAS -AgEYFw0xNDA1MDYxODIyMDVaMBICASEXDTE0MDUwMjEyNDQ1MlowEgIBIhcNMTQw -NDI5MTczNDA0WjASAgEjFw0xMzExMTMxOTM3MzNaMBICASQXDTE0MDUwNzIwMTIy -OFowEgIBKBcNMTQwNDI5MjAwNjAyWjASAgEpFw0xNDA0MjYxNDI0MjRaMBICASsX -DTE0MDUwMzE0NDgwNlowEgIBLRcNMTQwNDMwMDgxNTU4WjASAgEuFw0xNDA0MzAw -ODE2MTdaMBICAS8XDTE0MDQyNjEzMDIxNlowEgIBMxcNMTQwNDI5MTczNjIwWjAS -AgE0Fw0xNDA1MTIxODQwNThaMBICAWsXDTE1MTEyNTE5MjkyNlqgDzANMAsGA1Ud -FAQEAgIQJzANBgkqhkiG9w0BAQsFAAOCAgEAKbyM6U6B+RleyuF4O1t/G7SVhvHl -Yc6bqeV4zNj6B2j9Qw9YtO14USsxVw7RKZPhNvzSJhgBxxRtAOks0tVuGOkjN57V -qMc9Hiwd/d5WQOkDvaJv44yT5tUq3NhaV8c8bQzeogjXW4h5I0+YsLT84phAnwXK -Gj95A50vmjXZX7zUbS0TT6GVMjI0RBUIoRu5Ueax4gyX9WOKu0RQ4gZONzlYvbMk -exX+VWD9JWaA3pWKsxyUrRnDR1e7tUsnDXsh3i5krQinEQ1JYf3/lpGWMOygJV40 -9L0PhZB7cX4xDV2Vg0kBfKU7gr/C0uEF9fZJut8tqwe2LKj54dYa3ktX9Jbjq53F -WZthON6mMJxtTtjAdWyhQbbM+zy7hOE3cc4aivm9ZAXl30UNBWlPQsJRk3hTScMd -ye+A9RDRmG68qsoIWbTn/W5PBdiQ+MIxzO8fYwzs8yywQ1/VHHvbS1q0YC1PNono -6ayc9vHbghGc/RK67BTa1Oj9fqOVgy4XVxzPPzl4JAc4b6ELASS3owzuwUE8CrxP -drmYWn5ZII+w+0DNn9H5lPasxR5RQ/qPW7T5a8xpuNz+Uj/X4Baedl2DU4wzSP1m -nvntH0EgqgVXKFpxUT94CSRSiSOReElUZ17j7v28d8IhHCW3rou/JFxMgTIqmIg4 -jyCyTTMl3V9xWCw= ------END X509 CRL----- diff --git a/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem b/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem deleted file mode 100644 index 24a2ad2e..00000000 --- a/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFizCCA3OgAwIBAgIJAK9zyLTPn4CPMA0GCSqGSIb3DQEBBQUAMFwxCzAJBgNV -BAYTAk5PMQ0wCwYDVQQIDARPc2xvMR4wHAYDVQQKDBVza3Mta2V5c2VydmVycy5u -ZXQgQ0ExHjAcBgNVBAMMFXNrcy1rZXlzZXJ2ZXJzLm5ldCBDQTAeFw0xMjEwMDkw -MDMzMzdaFw0yMjEwMDcwMDMzMzdaMFwxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARP -c2xvMR4wHAYDVQQKDBVza3Mta2V5c2VydmVycy5uZXQgQ0ExHjAcBgNVBAMMFXNr -cy1rZXlzZXJ2ZXJzLm5ldCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC -ggIBANdsWy4PXWNUCkS3L//nrd0GqN3dVwoBGZ6w94Tw2jPDPifegwxQozFXkG6I -6A4TK1CJLXPvfz0UP0aBYyPmTNadDinaB9T4jIwd4rnxl+59GiEmqkN3IfPsv5Jj -MkKUmJnvOT0DEVlEaO1UZIwx5WpfprB3mR81/qm4XkAgmYrmgnLXd/pJDAMk7y1F -45b5zWofiD5l677lplcIPRbFhpJ6kDTODXh/XEdtF71EAeaOdEGOvyGDmCO0GWqS -FDkMMPTlieLA/0rgFTcz4xwUYj/cD5e0ZBuSkYsYFAU3hd1cGfBue0cPZaQH2HYx -Qk4zXD8S3F4690fRhr+tki5gyG6JDR67aKp3BIGLqm7f45WkX1hYp+YXywmEziM4 -aSbGYhx8hoFGfq9UcfPEvp2aoc8u5sdqjDslhyUzM1v3m3ZGbhwEOnVjljY6JJLx -MxagxnZZSAY424ZZ3t71E/Mn27dm2w+xFRuoy8JEjv1d+BT3eChM5KaNwrj0IO/y -u8kFIgWYA1vZ/15qMT+tyJTfyrNVV/7Df7TNeWyNqjJ5rBmt0M6NpHG7CrUSkBy9 -p8JhimgjP5r0FlEkgg+lyD+V79H98gQfVgP3pbJICz0SpBQf2F/2tyS4rLm+49rP -fcOajiXEuyhpcmzgusAj/1FjrtlynH1r9mnNaX4e+rLWzvU5AgMBAAGjUDBOMB0G -A1UdDgQWBBTkwyoJFGfYTVISTpM8E+igjdq28zAfBgNVHSMEGDAWgBTkwyoJFGfY -TVISTpM8E+igjdq28zAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4ICAQAR -OXnYwu3g1ZjHyley3fZI5aLPsaE17cOImVTehC8DcIphm2HOMR/hYTTL+V0G4P+u -gH+6xeRLKSHMHZTtSBIa6GDL03434y9CBuwGvAFCMU2GV8w92/Z7apkAhdLToZA/ -X/iWP2jeaVJhxgEcH8uPrnSlqoPBcKC9PrgUzQYfSZJkLmB+3jEa3HKruy1abJP5 -gAdQvwvcPpvYRnIzUc9fZODsVmlHVFBCl2dlu/iHh2h4GmL4Da2rRkUMlbVTdioB -UYIvMycdOkpH5wJftzw7cpjsudGas0PARDXCFfGyKhwBRFY7Xp7lbjtU5Rz0Gc04 -lPrhDf0pFE98Aw4jJRpFeWMjpXUEaG1cq7D641RpgcMfPFvOHY47rvDTS7XJOaUT -BwRjmDt896s6vMDcaG/uXJbQjuzmmx3W2Idyh3s5SI0GTHb0IwMKYb4eBUIpQOnB -cE77VnCYqKvN1NVYAqhWjXbY7XasZvszCRcOG+W3FqNaHOK/n/0ueb0uijdLan+U -f4p1bjbAox8eAOQS/8a3bzkJzdyBNUKGx1BIK2IBL9bn/HravSDOiNRSnZ/R3l9G -ZauX0tu7IIDlRCILXSyeazu0aj/vdT3YFQXPcvt5Fkf5wiNTo53f72/jYEJd6qph -WrpoKqrwGwTpRUCMhYIUt65hsTxCiJJ5nKe39h46sg== ------END CERTIFICATE----- diff --git a/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem.asc b/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem.asc deleted file mode 100644 index 5f11bc56..00000000 --- a/gnupg/sks-keyservers.net/sks-keyservers.netCA.pem.asc +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIcBAABCgAGBQJUCZzxAAoJEPw7F94F4Tag/Z8P/jUOTbsCYT+bG7L+/D9s1KCz -G2H9X4fV/fBeeAFWjgV6iNBEzZuFx9FYxmECyR1JzRektfWa3JR+rt2pipGO2UQ2 -Il2Ti6K7mVNyEnsgfq5otky7UDewmW+p5u1I7PNVcnHmArE7EueX5WB1vYhY2faY -B4xsFuaLacQVIz9JFyKiTGu0WSkpnlByaCoMPJgifwwGhPNK8X23isKDY8U9hahh -xWHRf/57Z+g407d6dEG/1ax8ELf68KRLGalZv9fOcZfRbFT4JV4bq/rsZuNptAqf -8A5RDnsgXFyIgDptWnYYpra/HCPNOKdL/TxcASTsEH6s9NNw9mvNpE//JWYMV4FM -N6h9aTezSEwAnD781JrPPZ8BlpRYWtnd3UaSbBbOdb6mze0Oh39yvYEcEO8edvC1 -RLH5OJyJIIkkO46B8cYBtokjRlcAeBgFf5GLlwdh6zGcERqsTRHtA8FmLbl1v3w1 -Xj1tUAoex27ke+z+QKBOp06t6eeNavDeN0/jDidSPQ4Q6QVy8KP9eeMDAQkd9+1F -aCMvSxEkbuiy05grzQC0jqOXAIVwfu33kcFr2Z7boxVNEjM/ng6Ty4WXWWWbADaH -nXGamvmUrCiODMRl4DYTB65H27tSv2J9j8WyA+IiokJOglH63nyJJy+XWbRmlgmI -+ds5RCeuq2/uVOGhSP7t -=O9Kt ------END PGP SIGNATURE----- -- cgit v1.2.3 From 49baf42cff246ae9bc96baab66b9233003eb9bb0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 25 Jun 2017 14:29:08 +1200 Subject: Add install-conf target Allows you to have a ~/.dotfiles.conf specifying targets to run in addition to `install`, e.g. `install-tmux` for applicable machines. Won't document this one just yet. --- ISSUES.markdown | 1 + Makefile | 3 +++ install/install-conf.sh | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 install/install-conf.sh diff --git a/ISSUES.markdown b/ISSUES.markdown index a69e07df..7dcaa770 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -23,3 +23,4 @@ Known issues my own stuff in there * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting +* Document `install-conf` target once I'm sure it's not a dumb idea diff --git a/Makefile b/Makefile index d28bf613..1a2cc44c 100644 --- a/Makefile +++ b/Makefile @@ -315,6 +315,9 @@ install: install-bin \ install-readline \ install-vim +install-conf: + sh install/install-conf.sh + install-abook: mkdir -p -- $(HOME)/.abook cp -p -- abook/abookrc $(HOME)/.abook diff --git a/install/install-conf.sh b/install/install-conf.sh new file mode 100644 index 00000000..f50cde73 --- /dev/null +++ b/install/install-conf.sh @@ -0,0 +1,10 @@ +# Read extra targets from an optional ~/.dotfiles.conf file +if [ -e "$HOME"/.dotfiles.conf ] ; then + while read -r line ; do + case $line in + '#'*|'') ;; + *) set -- "$@" "$line" ;; + esac + done < "$HOME"/.dotfiles.conf +fi +make install "$@" -- cgit v1.2.3 From 9f12be85f7e2cb1e7afb4db2225193f50df8fe60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 25 Jun 2017 14:34:59 +1200 Subject: Correct silly error in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1a2cc44c..8818e524 100644 --- a/Makefile +++ b/Makefile @@ -395,7 +395,7 @@ install-less: install-mpd: install-sh mkdir -p -- $(HOME)/.mpd/playlists - cp -p .. mpd/profile.d/* $(HOME)/.profile.d + cp -p -- mpd/profile.d/* $(HOME)/.profile.d cp -p -- mpd/mpdconf $(HOME)/.mpdconf install-mutt: -- cgit v1.2.3 From fa1760125f5ed03d8a96fbeb4967cc38665c51c1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 25 Jun 2017 17:25:38 +1200 Subject: Add an issue about XDG --- ISSUES.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/ISSUES.markdown b/ISSUES.markdown index 7dcaa770..fb31fadb 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -24,3 +24,4 @@ Known issues * Completion for custom functions e.g. `sd` should ideally respect `completion-ignore-case` setting * Document `install-conf` target once I'm sure it's not a dumb idea +* Need to decide whether I care about XDG, and implement it if I do -- cgit v1.2.3 From 75c6240bc0bd6368cc8b470572062db360c07670 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 25 Jun 2017 23:45:57 +1200 Subject: Remove unneeded `command` prefix --- bin/tm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tm.sh b/bin/tm.sh index 774dccb1..d5422869 100644 --- a/bin/tm.sh +++ b/bin/tm.sh @@ -5,7 +5,7 @@ if [ "$#" -gt 0 ] ; then : # If a session exists, just attach to it -elif command tmux has-session 2>/dev/null ; then +elif tmux has-session 2>/dev/null ; then set -- attach-session -d # Create a new session with an appropriate name -- cgit v1.2.3 From bc204d546eacaf82ced744838cd5a06ff8bcdde0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 26 Jun 2017 23:29:07 +1200 Subject: Allow MYSQL_* my.cnf vars Experimental --- .gitignore | 2 ++ Makefile | 9 +++++++++ mysql/my.cnf | 6 ------ mysql/my.cnf.mi5 | 11 +++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) delete mode 100644 mysql/my.cnf create mode 100644 mysql/my.cnf.mi5 diff --git a/.gitignore b/.gitignore index c4a552f8..34a350ba 100644 --- a/.gitignore +++ b/.gitignore @@ -160,4 +160,6 @@ gnupg/gpg.conf gnupg/gpg.conf.m4 include/mktd.m4 man/man7/dotfiles.7df +mysql/my.cnf +mysql/my.cnf.m4 urxvt/ext/select diff --git a/Makefile b/Makefile index 8818e524..e513d045 100644 --- a/Makefile +++ b/Makefile @@ -247,6 +247,8 @@ clean distclean: gnupg/gpg.conf.m4 \ include/mktd.m4 \ man/man8/dotfiles.7df \ + mysql/my.cnf \ + mysql/my.cnf.m4 \ urxvt/ext/select .awk: @@ -303,6 +305,13 @@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o $@ +mysql/my.cnf: mysql/my.cnf.m4 + m4 \ + -D MYSQL_HOST=$(MYSQL_HOST) \ + -D MYSQL_USER=$(MYSQL_USER) \ + -D MYSQL_PASSWORD=$(MYSQL_PASSWORD) \ + mysql/my.cnf.m4 > $@ + MAILDIR = $(HOME)/Mail install: install-bin \ diff --git a/mysql/my.cnf b/mysql/my.cnf deleted file mode 100644 index 900cf1a9..00000000 --- a/mysql/my.cnf +++ /dev/null @@ -1,6 +0,0 @@ -[mysql] -default-character-set=utf8 -no-auto-rehash -prompt='(\u@\h:\d) mysql> ' -safe-updates -skip-pager diff --git a/mysql/my.cnf.mi5 b/mysql/my.cnf.mi5 new file mode 100644 index 00000000..810f5165 --- /dev/null +++ b/mysql/my.cnf.mi5 @@ -0,0 +1,11 @@ +[mysql] +default-character-set=utf8 +no-auto-rehash +prompt='(\u@\h:\d) mysql> ' +safe-updates +skip-pager + +[client] +<% ifdef(`MYSQL_HOST', ``host='MYSQL_HOST', `dnl') %> +<% ifdef(`MYSQL_USER', ``user='MYSQL_USER', `dnl') %> +<% ifdef(`MYSQL_PASSWORD', ``password='MYSQL_PASSWORD', `dnl') %> -- cgit v1.2.3 From 2a1fc90e1a137625b0c9365cb8b752f10f657d78 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 26 Jun 2017 23:32:37 +1200 Subject: Add dependency to install-mysql target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e513d045..83d68893 100644 --- a/Makefile +++ b/Makefile @@ -420,7 +420,7 @@ install-newsbeuter: mkdir -p -- $(HOME)/.config/newsbeuter $(HOME)/.local/share/newsbeuter cp -p -- newsbeuter/config $(HOME)/.config/newsbeuter -install-mysql: +install-mysql: mysql/my.cnf cp -p -- mysql/my.cnf $(HOME)/.my.cnf install-ksh: check-ksh install-sh -- cgit v1.2.3 From 2c64dade10d0899284a4b7ef6f3464ff5dfd7cf7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 26 Jun 2017 23:40:10 +1200 Subject: Revert "Allow MYSQL_* my.cnf vars" This reverts commit bc204d546eacaf82ced744838cd5a06ff8bcdde0. Scratch that; this approach doesn't work because if the strings are empty from the Makefile macro, m4 still considers them defined. A different approach is needed here. --- .gitignore | 2 -- Makefile | 11 +---------- mysql/my.cnf | 6 ++++++ mysql/my.cnf.mi5 | 11 ----------- 4 files changed, 7 insertions(+), 23 deletions(-) create mode 100644 mysql/my.cnf delete mode 100644 mysql/my.cnf.mi5 diff --git a/.gitignore b/.gitignore index 34a350ba..c4a552f8 100644 --- a/.gitignore +++ b/.gitignore @@ -160,6 +160,4 @@ gnupg/gpg.conf gnupg/gpg.conf.m4 include/mktd.m4 man/man7/dotfiles.7df -mysql/my.cnf -mysql/my.cnf.m4 urxvt/ext/select diff --git a/Makefile b/Makefile index 83d68893..8818e524 100644 --- a/Makefile +++ b/Makefile @@ -247,8 +247,6 @@ clean distclean: gnupg/gpg.conf.m4 \ include/mktd.m4 \ man/man8/dotfiles.7df \ - mysql/my.cnf \ - mysql/my.cnf.m4 \ urxvt/ext/select .awk: @@ -305,13 +303,6 @@ man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header cat man/man7/dotfiles.7df.header README.markdown | \ pandoc -sS -t man -o $@ -mysql/my.cnf: mysql/my.cnf.m4 - m4 \ - -D MYSQL_HOST=$(MYSQL_HOST) \ - -D MYSQL_USER=$(MYSQL_USER) \ - -D MYSQL_PASSWORD=$(MYSQL_PASSWORD) \ - mysql/my.cnf.m4 > $@ - MAILDIR = $(HOME)/Mail install: install-bin \ @@ -420,7 +411,7 @@ install-newsbeuter: mkdir -p -- $(HOME)/.config/newsbeuter $(HOME)/.local/share/newsbeuter cp -p -- newsbeuter/config $(HOME)/.config/newsbeuter -install-mysql: mysql/my.cnf +install-mysql: cp -p -- mysql/my.cnf $(HOME)/.my.cnf install-ksh: check-ksh install-sh diff --git a/mysql/my.cnf b/mysql/my.cnf new file mode 100644 index 00000000..900cf1a9 --- /dev/null +++ b/mysql/my.cnf @@ -0,0 +1,6 @@ +[mysql] +default-character-set=utf8 +no-auto-rehash +prompt='(\u@\h:\d) mysql> ' +safe-updates +skip-pager diff --git a/mysql/my.cnf.mi5 b/mysql/my.cnf.mi5 deleted file mode 100644 index 810f5165..00000000 --- a/mysql/my.cnf.mi5 +++ /dev/null @@ -1,11 +0,0 @@ -[mysql] -default-character-set=utf8 -no-auto-rehash -prompt='(\u@\h:\d) mysql> ' -safe-updates -skip-pager - -[client] -<% ifdef(`MYSQL_HOST', ``host='MYSQL_HOST', `dnl') %> -<% ifdef(`MYSQL_USER', ``user='MYSQL_USER', `dnl') %> -<% ifdef(`MYSQL_PASSWORD', ``password='MYSQL_PASSWORD', `dnl') %> -- cgit v1.2.3 From 7061c9394180c556aab154ad876f4acc81d60236 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 27 Jun 2017 00:15:38 +1200 Subject: Add missing -v to `command` call This was causing a new mpd process on each login. --- mpd/profile.d/mpd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpd/profile.d/mpd.sh b/mpd/profile.d/mpd.sh index daa55af6..5a14aef2 100644 --- a/mpd/profile.d/mpd.sh +++ b/mpd/profile.d/mpd.sh @@ -1,3 +1,3 @@ # Start an mpd process if one isn't already running -command mpd >/dev/null 2>&1 || return +command -v mpd >/dev/null 2>&1 || return [ -s "$HOME"/.mpd/pid ] || mpd -- cgit v1.2.3 From e821cd82714b5218baa7123387a1cc792546fb73 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 27 Jun 2017 09:36:51 +1200 Subject: Inline some switch cases --- ksh/kshrc.d/prompt.ksh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 866cf79e..c5f3ee1b 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -30,9 +30,7 @@ function prompt { (*'MIRBSD KSH'*) ksh=mksh ;; esac case ${SHELL##*/} in - ('') ;; - (ksh) ;; - ("$ksh") ;; + (''|ksh|"$ksh") ;; (*) PS1=$ksh:$PS1 ;; esac -- cgit v1.2.3 From a5483bdce6c553c6908c447cd6b6d7a89d61e22c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Jun 2017 00:07:11 +1200 Subject: Add id_ed25519 keys to keychain --- keychain/profile.d/keychain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keychain/profile.d/keychain.sh b/keychain/profile.d/keychain.sh index f3d25c62..c0319d49 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_dsa id_rsa id_ecsda id_ed25519)" -- cgit v1.2.3 From a9e25e51ca3c96d3b5bfc86ab5a45c5bee818152 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 29 Jun 2017 17:46:34 +1200 Subject: Add oii(1df) --- .gitignore | 3 +++ Makefile | 4 ++++ README.markdown | 1 + bin/oii.mi5 | 19 +++++++++++++++++++ man/man1/oii.1df | 21 +++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 bin/oii.mi5 create mode 100644 man/man1/oii.1df diff --git a/.gitignore b/.gitignore index c4a552f8..bf219412 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,9 @@ bin/motd bin/murl bin/mw bin/nlbr +bin/oii +bin/oii.sh +bin/oii.m4 bin/onl bin/osc bin/p diff --git a/Makefile b/Makefile index 8818e524..2adc814b 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,7 @@ BINS = bin/ap \ bin/murl \ bin/mw \ bin/nlbr \ + bin/oii \ bin/onl \ bin/osc \ bin/pa \ @@ -203,6 +204,7 @@ BINS = bin/ap \ BINS_M4 = bin/chn.m4 \ bin/edda.m4 \ + bin/oii.m4 \ bin/pst.m4 \ bin/rndl.m4 \ bin/swr.m4 \ @@ -212,6 +214,7 @@ BINS_M4 = bin/chn.m4 \ BINS_SH = bin/chn.sh \ bin/edda.sh \ + bin/oii.sh \ bin/pst.sh \ bin/rndl.sh \ bin/swr.sh \ @@ -277,6 +280,7 @@ clean distclean: bin/chn.sh: bin/chn.m4 include/mktd.m4 bin/edda.sh: bin/edda.m4 include/mktd.m4 +bin/oii.sh: bin/oii.m4 include/mktd.m4 bin/pst.sh: bin/pst.m4 include/mktd.m4 bin/rndl.sh: bin/rndl.m4 include/mktd.m4 bin/swr.sh: bin/swr.m4 include/mktd.m4 diff --git a/README.markdown b/README.markdown index bd4d482a..c99dcf6d 100644 --- a/README.markdown +++ b/README.markdown @@ -499,6 +499,7 @@ Installed by the `install-bin` target: * `motd(1df)` shows the system MOTD. * `mw(1df)` prints alphabetic space-delimited words from the input one per line. +* `oii(1df)` runs a command on input only if there is any. * `onl(1df)` crunches input down to one printable line. * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s `s_client` subcommand. diff --git a/bin/oii.mi5 b/bin/oii.mi5 new file mode 100644 index 00000000..51f37fb4 --- /dev/null +++ b/bin/oii.mi5 @@ -0,0 +1,19 @@ +# Only run a command on input if there was at least one byte +self=oii + +# Need at least a command name +if [ "$#" -eq 0 ] ; then + printf >&2 '%s: Need a command\n' "$self" + exit 2 +fi + +<% +include(`include/mktd.m4') +%> + +# There is probably a way better way to do this than writing the whole file to +# disk and then reading it off again, but until I think of something better, +# this works and is byte-safe. +cat - > "$td"/in +[ -s "$td"/in ] || exit +"$@" < "$td"/in diff --git a/man/man1/oii.1df b/man/man1/oii.1df new file mode 100644 index 00000000..f5bb2678 --- /dev/null +++ b/man/man1/oii.1df @@ -0,0 +1,21 @@ +.TH OII 1df "June 2017" "Manual page for oii" +.SH NAME +.B oii +\- run a command on input only if there's at least one byte of input +.SH USAGE +.B oii +CMD [ARGS ...] < file +.br +program | +.B oii +CMD [ARGS ...] +.SH DESCRIPTION +Run the given program passing in stdin but only if at least one byte of input +is actually received, rather like the -E switch to mail(1) behaves on +bsd-mailx. If no input is received, exit silently with an error status. +.SH CAVEATS +It's slow, and doesn't work as a pipe. The entire input is written to disk and +then tested for filesize before being re-emitted. There's almost certainly a +more efficient way to do this while still remaining byte-safe. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From 519ff211bf1d21841a91bb82845f828f5412eb47 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Jun 2017 04:45:14 +1200 Subject: Double-quote shell config in tmux Otherwise it shows up as '$SHELL' in window titles --- tmux/tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 09ba0251..4e277515 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -13,7 +13,7 @@ set-environment -gru WINDOWID set-option -g update-environment '' # Setting this makes each new pane a non-login shell, which suits me better -set-option -g default-command '$SHELL' +set-option -g default-command "$SHELL" # Expect a 256-color terminal set-option -g default-terminal 'screen-256color' -- cgit v1.2.3 From 7859b833eab9ed32d2b438e1b5cc534b830118db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Jun 2017 10:27:06 +1200 Subject: Remove env(1) sorting Not worth the potential confusion. If I want nice sorted information I can either pipe it through sort myself, or use `declare -px` in Bash. --- sh/shrc.d/env.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 sh/shrc.d/env.sh diff --git a/sh/shrc.d/env.sh b/sh/shrc.d/env.sh deleted file mode 100644 index 4fa980f2..00000000 --- a/sh/shrc.d/env.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Sort the output of env(1) for me -env() { - if [ "$#" -eq 0 ] ; then - command env | sort - else - command env "$@" - fi -} -- cgit v1.2.3 From 340bcb5e3869f732a0545c9d091defc1d5449d74 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Jun 2017 11:44:37 +1200 Subject: Remove README mention of env() function Removed in 7859b83 --- README.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.markdown b/README.markdown index c99dcf6d..0f134be4 100644 --- a/README.markdown +++ b/README.markdown @@ -203,8 +203,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: * `bc()` silences startup messages from GNU `bc(1)`. * `ed()` tries to get verbose error messages, a prompt, and a Readline environment for `ed(1)`. -* `env()` sorts the output of `env(1)` if it was invoked with no arguments, - just for convenience when running it interactively. * `gdb()` silences startup messages from `gdb(1)`. * `gpg()` quietens `gpg(1)` down for most commands. * `grep()` tries to apply color and other options good for interactive use if -- cgit v1.2.3 From c776e528d5206a0af61302965258b6a4b2498cbf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 16:54:43 +1200 Subject: Grizzle about Pandoc --- ISSUES.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ISSUES.markdown b/ISSUES.markdown index fb31fadb..37803dcc 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -4,9 +4,9 @@ Known issues * man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on that system; need to find some way of finding which manual directories should be searched at runtime, if there is one. -* OpenBSD doesn't have a `pandoc` package at all. It would be nice to find - some way of converting the README.markdown into a palatable troff format - with some more readily available (and preferably less heavyweight) tool. +* pandoc(1) is awesome, but heavy as hell and requires Haskell. A more + lightweight recipe to make an acceptable man page out of the README would + be great. * The checks gscr(1df) makes to determine where it is are a bit naïve (don't work with bare repos) and could probably be improved with some appropriate git-reflog(1) calls -- cgit v1.2.3 From a8ab2cfec48cea3dd1fdf1013eec4a95423e92db Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 17:12:57 +1200 Subject: Solve Pandoc issue by not building page at all --- .gitignore | 1 - ISSUES.markdown | 3 - Makefile | 9 - README.markdown | 10 +- man/man7/dotfiles.7df | 947 +++++++++++++++++++++++++++++++++++++++++++ man/man7/dotfiles.7df.header | 3 - 6 files changed, 950 insertions(+), 23 deletions(-) create mode 100644 man/man7/dotfiles.7df delete mode 100644 man/man7/dotfiles.7df.header diff --git a/.gitignore b/.gitignore index bf219412..21d294c4 100644 --- a/.gitignore +++ b/.gitignore @@ -162,5 +162,4 @@ git/gitconfig.m4 gnupg/gpg.conf gnupg/gpg.conf.m4 include/mktd.m4 -man/man7/dotfiles.7df urxvt/ext/select diff --git a/ISSUES.markdown b/ISSUES.markdown index 37803dcc..48007919 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -4,9 +4,6 @@ Known issues * man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on that system; need to find some way of finding which manual directories should be searched at runtime, if there is one. -* pandoc(1) is awesome, but heavy as hell and requires Haskell. A more - lightweight recipe to make an acceptable man page out of the README would - be great. * The checks gscr(1df) makes to determine where it is are a bit naïve (don't work with bare repos) and could probably be improved with some appropriate git-reflog(1) calls diff --git a/Makefile b/Makefile index 2adc814b..22d5ac8e 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ install-bin \ install-bin-man \ install-curl \ - install-dotfiles-man \ install-dunst \ install-ex \ install-finger \ @@ -303,10 +302,6 @@ gnupg/gpg.conf: gnupg/gpg.conf.m4 -D KEYSERVER=$(KEYSERVER) \ gnupg/gpg.conf.m4 > $@ -man/man7/dotfiles.7df: README.markdown man/man7/dotfiles.7df.header - cat man/man7/dotfiles.7df.header README.markdown | \ - pandoc -sS -t man -o $@ - MAILDIR = $(HOME)/Mail install: install-bin \ @@ -348,10 +343,6 @@ install-bin-man: install-curl: cp -p -- curl/curlrc $(HOME)/.curlrc -install-dotfiles-man: man/man7/dotfiles.7df - mkdir -p -- $(HOME)/.local/share/man/man7 - cp -p -- man/man7/*.7df $(HOME)/.local/share/man/man7 - install-dunst: install-x mkdir -p -- $(HOME)/.config/dunst cp -p -- dunst/dunstrc $(HOME)/.config/dunst diff --git a/README.markdown b/README.markdown index 0f134be4..30e94d10 100644 --- a/README.markdown +++ b/README.markdown @@ -565,13 +565,9 @@ Manuals ------- The `install-bin` and `install-games` targets install manuals for each script -they install. There's also an `install-dotfiles-man` target that uses -`pandoc(1)` to reformat this document as a manual page for section 7 -(`dotfiles(7df)`) if you want that. I haven't made that install by default, -because `pandoc(1)` is a bit heavy. - -If you want to use the manuals, you may need to add `~/.local/share/man` to -your `~/.manpath` or `/etc/manpath` configuration, depending on your system. +they install. If you want to use the manuals, you may need to add +`~/.local/share/man` to your `~/.manpath` or `/etc/manpath` configuration, +depending on your system. Testing ------- diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df new file mode 100644 index 00000000..831af06d --- /dev/null +++ b/man/man7/dotfiles.7df @@ -0,0 +1,947 @@ +.\" Automatically generated by Pandoc 1.17.2 +.\" +.TH "DOTFILES" "7" "June 2016" "Tom Ryder's personal scripts and configuration" "" +.hy +.SH Dotfiles (Tom Ryder) +.PP +This is my personal repository of configuration files and scripts for +\f[C]$HOME\f[], including most of the settings that migrate well between +machines. +.PP +This repository began as a simple way to share Vim and tmux +configuration, but over time a lot of scripts and shell configuration +have been added, making it into a personal suite of custom Unix tools. +.SS Installation +.IP +.nf +\f[C] +$\ git\ clone\ https://sanctum.geek.nz/code/dotfiles.git\ ~/.dotfiles +$\ cd\ ~/.dotfiles +$\ git\ submodule\ init +$\ git\ submodule\ update +$\ make +$\ make\ \-n\ install +$\ make\ install +\f[] +.fi +.PP +For the default \f[C]all\f[] target, you'll need a POSIX\-fearing +userland, including \f[C]make(1)\f[] and \f[C]m4(1)\f[]. +.PP +The installation \f[C]Makefile\f[] will overwrite things standing in the +way of its installed files without backing them up, so read the output +of \f[C]make\ \-n\ install\f[] before running \f[C]make\ install\f[] to +make sure you aren't going to lose anything unexpected. +If you're still not sure, install it in a temporary directory so you can +explore: +.IP +.nf +\f[C] +$\ tmpdir=$(mktemp\ \-d) +$\ make\ install\ HOME="$tmpdir" +$\ env\ \-i\ HOME="$tmpdir"\ TERM="$TERM"\ "$SHELL"\ \-l +\f[] +.fi +.PP +The default \f[C]install\f[] target will install these targets and all +their dependencies. +Note that you don't actually have to have any of this except \f[C]sh\f[] +installed. +.IP \[bu] 2 +\f[C]install\-bin\f[] +.IP \[bu] 2 +\f[C]install\-bin\-man\f[] +.IP \[bu] 2 +\f[C]install\-curl\f[] +.IP \[bu] 2 +\f[C]install\-ex\f[] +.IP \[bu] 2 +\f[C]install\-git\f[] +.IP \[bu] 2 +\f[C]install\-gnupg\f[] +.IP \[bu] 2 +\f[C]install\-less\f[] +.IP \[bu] 2 +\f[C]install\-login\-shell\f[] +.IP \[bu] 2 +\f[C]install\-readline\f[] +.IP \[bu] 2 +\f[C]install\-vim\f[] +.PP +The \f[C]install\-login\-shell\f[] looks at your \f[C]SHELL\f[] +environment variable and tries to figure out which shell's configuration +files to install, falling back on \f[C]install\-sh\f[]. +.PP +The remaining dotfiles can be installed with the other +\f[C]install\-*\f[] targets. +Try \f[C]awk\ \-f\ bin/mftl.awk\ Makefile\f[] in the project's root +directory to see a list. +.SS Tools +.PP +Configuration is included for: +.IP \[bu] 2 +Bourne\-style POSIX shells, sharing a \f[C]\&.profile\f[], an +\f[C]ENV\f[] file, and some helper functions: +.RS 2 +.IP \[bu] 2 +GNU Bash (https://www.gnu.org/software/bash/) (2.05a or higher) +.IP \[bu] 2 +Korn shell (http://www.kornshell.com/) (\f[C]ksh93\f[], \f[C]pdksh\f[], +\f[C]mksh\f[]) +.IP \[bu] 2 +Z shell (https://www.zsh.org/) +.RE +.IP \[bu] 2 +Abook (http://abook.sourceforge.net/) \[en] curses address book program +.IP \[bu] 2 +cURL (https://curl.haxx.se/) \[en] Command\-line tool for transferring +data with URL syntax +.IP \[bu] 2 +Dunst (http://knopwob.org/dunst/) \[en] A lightweight X11 notification +daemon that works with \f[C]libnotify\f[] +.IP \[bu] 2 +\f[C]finger(1)\f[] \[en] User information lookup program +.IP \[bu] 2 +Git (https://git-scm.com/) \[en] Distributed version control system +.IP \[bu] 2 +GnuPG (https://www.gnupg.org/) \[en] GNU Privacy Guard, for private +communication and file encryption +.IP \[bu] 2 +GTK+ (https://www.gtk.org/) \[en] GIMP Toolkit, for graphical user +interface elements +.IP \[bu] 2 +i3 (https://i3wm.org/) \[en] Tiling window manager +.IP \[bu] 2 +less (https://www.gnu.org/software/less/) \[en] Terminal pager +.IP \[bu] 2 +Mutt (http://www.mutt.org/) \[en] Terminal mail user agent +.IP \[bu] 2 +\f[C]mysql(1)\f[] (https://linux.die.net/man/1/mysql) \[en] +Command\-line MySQL client +.IP \[bu] 2 +Ncmpcpp (https://rybczak.net/ncmpcpp/) \[en] ncurses music player client +.IP \[bu] 2 +Newsbeuter (https://www.newsbeuter.org/) \[en] Terminal RSS/Atom feed +reader +.IP \[bu] 2 +\f[C]psql(1)\f[] (https://linux.die.net/man/1/psql) \[en] Command\-line +PostgreSQL client +.IP \[bu] 2 +Perl::Critic (http://perlcritic.com/) \[en] static source code analysis +engine for Perl +.IP \[bu] 2 +Perl::Tidy (http://perltidy.sourceforge.net/) \[en] Perl indenter and +reformatter +.IP \[bu] 2 +Readline (https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) +\[en] GNU library for user input used by Bash, MySQL, and others +.IP \[bu] 2 +rxvt\-unicode (http://software.schmorp.de/pkg/rxvt-unicode.html) \[en] +Fork of the rxvt terminal emulator with Unicode support +.IP \[bu] 2 +Subversion (https://subversion.apache.org/) \[en] Apache Subversion, a +version control system +.IP \[bu] 2 +tmux (https://tmux.github.io/) \[en] Terminal multiplexer similar to GNU +Screen +.IP \[bu] 2 +Vim (http://www.vim.org/) \[en] Vi IMproved, a text editor +.IP \[bu] 2 +X11 (https://www.x.org/wiki/) \[en] Windowing system with network +transparency for Unix +.PP +The configurations for shells, GnuPG, Mutt, tmux, and Vim are the most +expansive, and most likely to be of interest. +The i3 configuration is mostly changed to make window switching behave +like Vim windows and tmux panes do, and there's a fair few resources +defined for rxvt\-unicode. +.SS Shell +.PP +My \f[C]\&.profile\f[] and other files in \f[C]sh\f[] are written in +POSIX shell script, so they should work in most \f[C]sh(1)\f[] +implementations. +Individual scripts called by \f[C]\&.profile\f[] are saved in +\f[C]\&.profile.d\f[] and iterated on login for ease of management. +Most of these boil down to exporting variables appropriate to the system +and the software it has available. +.PP +Configuration that should be sourced for all POSIX\-fearing interactive +shells is kept in \f[C]~/.shrc\f[], with subscripts read from +\f[C]~/.shrc.d\f[]. +There's a shim in \f[C]~/.shinit\f[] to act as \f[C]ENV\f[]. +I make an effort to target POSIX for my functions and scripts where I +can so that the same files can be loaded for all shells. +.PP +On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, +preferably \f[C]ksh93\f[] if it's available. +.PP +As I occasionally have work on very old internal systems, my Bash is +written to work with any version 2.05a or +newer (http://wiki.bash-hackers.org/scripting/bashchanges). +This is why I use older syntax for certain things such as appending +items to arrays: +.IP +.nf +\f[C] +array[${#array[\@]}]=$item +\f[] +.fi +.PP +Compare this to the much nicer syntax available since 3.1\-alpha1, which +actually works for arrays with sparse indices, unlike the above syntax: +.IP +.nf +\f[C] +array+=("$item") +\f[] +.fi +.PP +Where I do use features that are only available in versions of Bash +newer than 2.05a, such as newer \f[C]shopt\f[] options or +\f[C]PROMPT_DIRTRIM\f[], they are only run after testing +\f[C]BASH_VERSINFO\f[] appropriately. +.SS Prompt +.PP +A terminal session with my prompt looks something like this: +.IP +.nf +\f[C] +~$\ ssh\ remote +remote:~$\ cd\ .dotfiles +remote:~/.dotfiles(master+!)$\ git\ status +\ M\ README.markdown +M\ \ bash/bashrc.d/prompt.bash +A\ \ init +remote:~/.dotfiles(master+!)$\ foobar +foobar:\ command\ not\ found +remote:~/.dotfiles(master+!)<127>$\ sleep\ 5\ & +[1]\ 28937 +remote:~/.dotfiles(master+!){1}$ +\f[] +.fi +.PP +The hostname is elided if not connected via SSH. +The working directory with tilde abbreviation for \f[C]$HOME\f[] is +always shown. +The rest of the prompt expands based on context to include these +elements in this order: +.IP \[bu] 2 +Whether in a Git repository if applicable, and punctuation to show +repository status including reference to upstreams at a glance. +Subversion support can also be enabled (I need it at work), in which +case a \f[C]git:\f[] or \f[C]svn:\f[] prefix is added appropriately. +.IP \[bu] 2 +The number of running background jobs, if non\-zero. +.IP \[bu] 2 +The exit status of the last command, if non\-zero. +.PP +You can set \f[C]PROMPT_COLOR\f[], \f[C]PROMPT_PREFIX\f[], and +\f[C]PROMPT_SUFFIX\f[] too, which all do about what you'd expect. +.PP +If you start up Bash, Ksh, or Zsh and it detects that it's not normally +your \f[C]$SHELL\f[], the prompt will display an appropriate prefix. +.PP +This is all managed within the \f[C]prompt\f[] function. +There's some mildly hacky logic on \f[C]tput\f[] codes included such +that it should work correctly for most common terminals using both +\f[C]termcap(5)\f[] and \f[C]terminfo(5)\f[], including *BSD systems. +It's also designed to degrade gracefully for eight\-color and no\-color +terminals. +.SS Functions +.PP +If a function can be written in POSIX \f[C]sh\f[] without too much +hackery, I put it in \f[C]sh/shrc.d\f[] to be loaded by any POSIX +interactive shell. +Those include: +.IP \[bu] 2 +Four functions for using a \[lq]marked\[rq] directory, which I find a +more manageable concept than the \f[C]pushd\f[]/\f[C]popd\f[] directory +stack: +.RS 2 +.IP \[bu] 2 +\f[C]md()\f[] marks a given (or the current) directory. +.IP \[bu] 2 +\f[C]gd()\f[] goes to the marked directory. +.IP \[bu] 2 +\f[C]pmd()\f[] prints the marked directory. +.IP \[bu] 2 +\f[C]xd()\f[] swaps the current and marked directories. +.RE +.IP \[bu] 2 +Ten other directory management and navigation functions: +.RS 2 +.IP \[bu] 2 +\f[C]bd()\f[] changes into a named ancestor of the current directory. +.IP \[bu] 2 +\f[C]gt()\f[] changes into a directory or into a file's directory. +.IP \[bu] 2 +\f[C]lgt()\f[] runs \f[C]gt()\f[] on the first result from a +\f[C]loc(1df)\f[] search. +.IP \[bu] 2 +\f[C]mkcd()\f[] creates a directory and changes into it. +.IP \[bu] 2 +\f[C]pd()\f[] changes to the argument's parent directory. +.IP \[bu] 2 +\f[C]rd()\f[] replaces the first instance of its first argument with its +second argument in \f[C]$PWD\f[], emulating a feature of the Zsh +\f[C]cd\f[] builtin that I like. +.IP \[bu] 2 +\f[C]scr()\f[] creates a temporary directory and changes into it. +.IP \[bu] 2 +\f[C]sd()\f[] changes into a sibling of the current directory. +.IP \[bu] 2 +\f[C]ud()\f[] changes into an indexed ancestor of a directory. +.IP \[bu] 2 +\f[C]vr()\f[] tries to change to the root directory of a source control +repository. +.RE +.IP \[bu] 2 +\f[C]bc()\f[] silences startup messages from GNU \f[C]bc(1)\f[]. +.IP \[bu] 2 +\f[C]ed()\f[] tries to get verbose error messages, a prompt, and a +Readline environment for \f[C]ed(1)\f[]. +.IP \[bu] 2 +\f[C]env()\f[] sorts the output of \f[C]env(1)\f[] if it was invoked +with no arguments, just for convenience when running it interactively. +.IP \[bu] 2 +\f[C]gdb()\f[] silences startup messages from \f[C]gdb(1)\f[]. +.IP \[bu] 2 +\f[C]gpg()\f[] quietens \f[C]gpg(1)\f[] down for most commands. +.IP \[bu] 2 +\f[C]grep()\f[] tries to apply color and other options good for +interactive use if available. +.IP \[bu] 2 +\f[C]hgrep()\f[] allows searching \f[C]$HISTFILE\f[]. +.IP \[bu] 2 +\f[C]keychain()\f[] keeps \f[C]$GPG_TTY\f[] up to date if a GnuPG agent +is available. +.IP \[bu] 2 +\f[C]ls()\f[] tries to apply color and other options good for +interactive use if available. +.RS 2 +.IP \[bu] 2 +\f[C]la()\f[] runs \f[C]ls\ \-A\f[] if it can, or \f[C]ls\ \-a\f[] +otherwise. +.IP \[bu] 2 +\f[C]ll()\f[] runs \f[C]ls\ \-Al\f[] if it can, or \f[C]ls\ \-al\f[] +otherwise. +.RE +.IP \[bu] 2 +\f[C]path()\f[] manages the contents of \f[C]PATH\f[] conveniently. +.IP \[bu] 2 +\f[C]scp()\f[] tries to detect forgotten hostnames in \f[C]scp(1)\f[] +command calls. +.IP \[bu] 2 +\f[C]sudo()\f[] forces \f[C]\-H\f[] for \f[C]sudo(8)\f[] calls so that +\f[C]$HOME\f[] is never preserved; I hate having \f[C]root\f[]\-owned +files in my home directory. +.IP \[bu] 2 +\f[C]tree()\f[] colorizes GNU \f[C]tree(1)\f[] output if possible +(without having \f[C]LS_COLORS\f[] set). +.IP \[bu] 2 +\f[C]x()\f[] is a one\-key shortcut for \f[C]exec\ startx\f[]. +.PP +There are a few other little tricks defined for other shells providing +non\-POSIX features, as compatibility allows: +.IP \[bu] 2 +\f[C]keep()\f[] stores ad\-hoc shell functions and variables (Bash, Korn +Shell 93, Z shell). +.IP \[bu] 2 +\f[C]prompt()\f[] sets up my interactive prompt (Bash, Korn Shell, Z +shell). +.IP \[bu] 2 +\f[C]pushd()\f[] adds a default destination of \f[C]$HOME\f[] to the +\f[C]pushd\f[] builtin (Bash). +.IP \[bu] 2 +\f[C]vared()\f[] allows interactively editing a variable with Readline, +emulating a Zsh function I like by the same name (Bash). +.IP \[bu] 2 +\f[C]ver()\f[] prints the current shell's version information (Bash, +Korn Shell, Z shell). +.SS Completion +.PP +I find the \f[C]bash\-completion\f[] package a bit too heavy for my +tastes, and turn it off using a stub file installed in +\f[C]~/.config/bash_completion\f[]. +The majority of the time I just want to complete paths anyway, and this +makes for a quicker startup without a lot of junk functions in my Bash +namespace. +.PP +I do make some exceptions with completions defined in +\f[C]\&.bash_completion.d\f[] files, for things I really do get tired of +typing repeatedly: +.IP \[bu] 2 +Bash builtins: commands, help topics, shell options, variables, etc. +.IP \[bu] 2 +\f[C]find(1)\f[]'s more portable options +.IP \[bu] 2 +\f[C]ftp(1)\f[] hostnames from \f[C]~/.netrc\f[] +.IP \[bu] 2 +\f[C]git(1)\f[] subcommands, remotes, branches, tags, and addable files +.IP \[bu] 2 +\f[C]gpg(1)\f[] long options +.IP \[bu] 2 +\f[C]make(1)\f[] targets read from a \f[C]Makefile\f[] +.IP \[bu] 2 +\f[C]man(1)\f[] page titles +.IP \[bu] 2 +\f[C]pass(1)\f[] entries +.IP \[bu] 2 +\f[C]ssh(1)\f[] hostnames from \f[C]~/.ssh/config\f[] +.PP +For commands that pretty much always want to operate on text, such as +text file or stream editors, I exclude special file types and extensions +I know are binary. +I don't actually read the file, so this is more of a heuristic thing, +and sometimes it will get things wrong. +.PP +I also add completions for my own scripts and functions where useful. +The completions are dynamically loaded if Bash is version 4.0 or +greater. +Otherwise, they're all loaded on startup. +.SS Korn shell +.PP +These are experimental; they are mostly used to tinker with MirBSD +\f[C]mksh\f[], AT&T \f[C]ksh93\f[], and OpenBSD \f[C]pdksh\f[]. +All shells in this family default to a yellow prompt if detected. +.SS Zsh +.PP +These are experimental; I do not like Zsh much at the moment. +The files started as a joke (\f[C]exec\ bash\f[]). +\f[C]zsh\f[] shells default to having a prompt coloured cyan. +.SS GnuPG +.PP +The configuration for GnuPG is intended to follow RiseUp's OpenPGP best +practices (https://riseup.net/en/security/message-security/openpgp/best-practices). +The configuration file is rebuilt using \f[C]mi5(1df)\f[] and +\f[C]make(1)\f[] because it requires hard\-coding a path to the SKS +keyserver certificate authority, and neither tilde nor \f[C]$HOME\f[] +expansion works for this. +.SS Mutt +.PP +My mail is kept in individual Maildirs under \f[C]~/Mail\f[], with +\f[C]inbox\f[] being where most unfiltered mail is sent. +I use Getmail (http://pyropus.ca/software/getmail/), +maildrop (https://www.courier-mta.org/maildrop/), and +MSMTP (http://msmtp.sourceforge.net/); the configurations for these are +not included here. +I sign whenever I have some indication that the recipient might be using +a PGP implementation, and I encrypt whenever I have a public key +available for them. +The GnuPG and S/MIME interfacing is done with +GPGme (https://www.gnupg.org/related_software/gpgme/), rather than +defining commands for each crypto operation. +I wrote an article about this +setup (https://sanctum.geek.nz/arabesque/linux-crypto-email/) if it +sounds appealing. +.PP +You'll need Abook (http://abook.sourceforge.net/) installed if you want +to use the \f[C]query_command\f[] I have defined, and +msmtp (http://msmtp.sourceforge.net/) for the \f[C]sendmail\f[] command. +.SS rxvt\-unicode +.PP +I've butchered the URxvt Perl extensions +\f[C]selection\-to\-clipboard\f[] and \f[C]selection\f[] into a single +\f[C]select\f[] extension in \f[C]~/.urxvt/ext\f[], which is the only +extension I define in \f[C]~/.Xresources\f[]. +.PP +The included \f[C]\&.Xresources\f[] file assumes that \f[C]urxvt\f[] can +use 256 colors and Perl extensions. +If you're missing functionality, try changing \f[C]perl\-ext\-common\f[] +to \f[C]default\f[]. +.PP +My choice of font is Ubuntu Mono (http://font.ubuntu.com/), but the file +should allow falling back to the more common Deja Vu Sans +Mono (https://dejavu-fonts.github.io/). +I've found Terminus (http://terminus-font.sourceforge.net/) works well +too, but bitmap fonts are not really my cup of tea. +The Lohit Kannada font bit is purely to make ಠ_ಠ work correctly. +( ͡° ͜ʖ ͡°) seems to work out of the box. +.SS tmux +.PP +These are just generally vi\-friendly settings, not much out of the +ordinary. +Note that the configuration presently uses a hard\-coded 256\-color +colorscheme, and uses non\-login shells, with an attempt to control the +environment to stop shells thinking they have access to an X display. +.PP +The shell scripts in \f[C]bin\f[] include \f[C]tm(1df)\f[], a shortcut +to make \f[C]attach\f[] into the default command if no arguments are +given and sessions do already exist. +My \f[C]~/.inputrc\f[] file binds Alt+M to run that, and Tmux in turn +binds the same key combination to detach. +.SS Vim +.PP +The majority of the \f[C]\&.vimrc\f[] file is just setting options, with +a few mappings. +I try not to deviate too much from the Vim defaults behaviour in terms +of interactive behavior and keybindings. +.PP +The configuration is extensively commented, mostly because I was reading +through it one day and realised I'd forgotten what half of it did. +Plugins are loaded using \@tpope's +pathogen.vim (https://github.com/tpope/vim-pathogen). +.SS Scripts +.PP +Where practical, I make short scripts into POSIX (but not Bourne) +\f[C]sh(1)\f[], \f[C]awk(1)\f[], or \f[C]sed(1)\f[] scripts in +\f[C]~/.local/bin\f[]. +I try to use shell functions only when I actually need to, which tends +to be when I need to tinker with the namespace of the user's current +shell. +.PP +Installed by the \f[C]install\-bin\f[] target: +.IP \[bu] 2 +Three SSH\-related scripts: +.RS 2 +.IP \[bu] 2 +\f[C]sls(1df)\f[] prints hostnames read from a \f[C]ssh_config(5)\f[] +file. +It uses \f[C]slsf(1df)\f[] to read each one. +.IP \[bu] 2 +\f[C]sra(1df)\f[] runs a command on multiple hosts read from +\f[C]sls(1df)\f[] and prints output. +.IP \[bu] 2 +\f[C]sta(1df)\f[] runs a command on multiple hosts read from +\f[C]sls(1df)\f[] and prints the hostname if the command returns zero. +.RE +.IP \[bu] 2 +Five URL\-related shortcut scripts: +.RS 2 +.IP \[bu] 2 +\f[C]hurl(1df)\f[] extracts values of \f[C]href\f[] attributes of +\f[C]\f[] tags, sorts them uniquely, and writes them to +\f[C]stdout\f[]; it requires pup (https://github.com/ericchiang/pup). +.IP \[bu] 2 +\f[C]murl(1df)\f[] converts Markdown documents to HTML with +\f[C]pandoc(1)\f[] and runs the output through \f[C]hurl(1df)\f[]. +.IP \[bu] 2 +\f[C]urlc(1df)\f[] accepts a list of URLs on \f[C]stdin\f[] and writes +error messages to \f[C]stderr\f[] if any of the URLs are broken, +redirecting, or are insecure and have working secure versions; requires +\f[C]curl(1)\f[]. +.IP \[bu] 2 +\f[C]urlh(1df)\f[] prints the values for a given HTTP header from a HEAD +response. +.IP \[bu] 2 +\f[C]urlmt(1df)\f[] prints the MIME type from the \f[C]Content\-Type\f[] +header as retrieved by \f[C]urlh(1df)\f[]. +.RE +.IP \[bu] 2 +Three RFC\-related shortcut scripts: +.RS 2 +.IP \[bu] 2 +\f[C]rfcf(1df)\f[] fetches ASCII RFCs from the IETF website. +.IP \[bu] 2 +\f[C]rfct(1df)\f[] formats ASCII RFCs. +.IP \[bu] 2 +\f[C]rfcr(1df)\f[] does both, displaying in a pager if appropriate, like +a \f[C]man(1)\f[] reader for RFCs. +.RE +.IP \[bu] 2 +Five toy random\-number scripts (not for sensitive/dead\-serious use): +.RS 2 +.IP \[bu] 2 +\f[C]rndi(1df)\f[] gets a random integer within two bounds. +.IP \[bu] 2 +\f[C]rnds(1df)\f[] attempts to get an optional random seed for +\f[C]rndi(1df)\f[]. +.IP \[bu] 2 +\f[C]rnda(1df)\f[] uses \f[C]rndi(1df)\f[] to choose a random argument. +.IP \[bu] 2 +\f[C]rndf(1df)\f[] uses \f[C]rnda(1df)\f[] to choose a random file from +a directory. +.IP \[bu] 2 +\f[C]rndl(1df)\f[] uses \f[C]rndi(1df)\f[] to choose a random line from +files. +.RE +.IP \[bu] 2 +Four file formatting scripts: +.RS 2 +.IP \[bu] 2 +\f[C]d2u(1df)\f[] converts DOS line endings in files to UNIX ones. +.IP \[bu] 2 +\f[C]u2d(1df)\f[] converts UNIX line endings in files to DOS ones. +.IP \[bu] 2 +\f[C]stbl(1df)\f[] strips a trailing blank line from the files in its +arguments. +.IP \[bu] 2 +\f[C]stws(1df)\f[] strips trailing spaces from the ends of lines of the +files in its arguments. +.RE +.IP \[bu] 2 +Seven stream formatting scripts: +.RS 2 +.IP \[bu] 2 +\f[C]sd2u(1df)\f[] converts DOS line endings in streams to UNIX ones. +.IP \[bu] 2 +\f[C]su2d(1df)\f[] converts UNIX line endings in streams to DOS ones. +.IP \[bu] 2 +\f[C]slow(1df)\f[] converts uppercase to lowercase. +.IP \[bu] 2 +\f[C]supp(1df)\f[] converts lowercase to uppercase. +.IP \[bu] 2 +\f[C]tl(1df)\f[] tags input lines with a prefix or suffix, basically a +\f[C]sed(1)\f[] shortcut. +.IP \[bu] 2 +\f[C]tlcs(1df)\f[] executes a command and uses \f[C]tl(1df)\f[] to tag +stdout and stderr lines, and color them if you want. +.IP \[bu] 2 +\f[C]unf(1df)\f[] joins lines with leading spaces to the previous line. +Intended for unfolding HTTP headers, but it should work for most RFC 822 +formats. +.RE +.IP \[bu] 2 +Six simple aggregators for numbers: +.RS 2 +.IP \[bu] 2 +\f[C]max(1df)\f[] prints the maximum. +.IP \[bu] 2 +\f[C]mean(1df)\f[] prints the mean. +.IP \[bu] 2 +\f[C]med(1df)\f[] prints the median. +.IP \[bu] 2 +\f[C]min(1df)\f[] prints the minimum. +.IP \[bu] 2 +\f[C]mode(1df)\f[] prints the first encountered mode. +.IP \[bu] 2 +\f[C]tot(1df)\f[] totals the set. +.RE +.IP \[bu] 2 +Three quick\-and\-dirty HTML tools: +.RS 2 +.IP \[bu] 2 +\f[C]htenc(1df)\f[] encodes. +.IP \[bu] 2 +\f[C]htdec(1df)\f[] decodes. +.IP \[bu] 2 +\f[C]htrec(1df)\f[] wraps \f[C]a\f[] tags around URLs. +.RE +.IP \[bu] 2 +Two internet message quoting tools: +.RS 2 +.IP \[bu] 2 +\f[C]quo(1df)\f[] indents with quoting right angle\-brackets. +.IP \[bu] 2 +\f[C]wro(1df)\f[] adds a quote attribution header to its input. +.RE +.IP \[bu] 2 +Six Git\-related tools: +.RS 2 +.IP \[bu] 2 +\f[C]fgscr(1df)\f[] finds Git repositories in a directory root and +scrubs them with \f[C]gscr(1df)\f[]. +.IP \[bu] 2 +\f[C]grc(1df)\f[] quietly tests whether the given directory appears to +be a Git repository with pending changes. +.IP \[bu] 2 +\f[C]gscr(1df)\f[] scrubs Git repositories. +.IP \[bu] 2 +\f[C]isgr(1df)\f[] quietly tests whether the given directory appears to +be a Git repository. +.IP \[bu] 2 +\f[C]jfc(1df)\f[] adds and commits lazily to a Git repository. +.IP \[bu] 2 +\f[C]jfcd(1df)\f[] watches a directory for changes and runs +\f[C]jfc(1df)\f[] if it sees any. +.RE +.IP \[bu] 2 +Two time duration functions: +.RS 2 +.IP \[bu] 2 +\f[C]hms(1df)\f[] converts seconds to \f[C]hh:mm:ss\f[] or +\f[C]mm:ss\f[] timestamps. +.IP \[bu] 2 +\f[C]sec(1df)\f[] converts \f[C]hh:mm:ss\f[] or \f[C]mm:ss\f[] +timestamps to seconds. +.RE +.IP \[bu] 2 +Three pipe interaction tools: +.RS 2 +.IP \[bu] 2 +\f[C]pst(1df)\f[] runs an interactive program on data before passing it +along a pipeline. +.IP \[bu] 2 +\f[C]ped(1df)\f[] runs \f[C]pst(1df)\f[] with \f[C]$EDITOR\f[] or +\f[C]ed(1)\f[]. +.IP \[bu] 2 +\f[C]pvi(1df)\f[] runs \f[C]pvi(1df)\f[] with \f[C]$VISUAL\f[] or +\f[C]vi(1)\f[]. +.RE +.IP \[bu] 2 +\f[C]ap(1df)\f[] reads arguments for a given command from the standard +input, prompting if appropriate. +.IP \[bu] 2 +\f[C]apf(1df)\f[] prepends arguments to a command with ones read from a +file, intended as a framework for shell wrappers or functions. +.IP \[bu] 2 +\f[C]ax(1df)\f[] evaluates an awk expression given on the command line; +this is intended as a quick way to test how Awk would interpret a given +expression. +.IP \[bu] 2 +\f[C]bcq(1df)\f[] runs \f[C]bc(1)\f[], quieting it down if need be. +.IP \[bu] 2 +\f[C]bel(1df)\f[] prints a terminal bell character. +.IP \[bu] 2 +\f[C]bl(1df)\f[] generates a given number of blank lines. +.IP \[bu] 2 +\f[C]bp(1df)\f[] runs \f[C]br(1df)\f[] after prompting for an URL. +.IP \[bu] 2 +\f[C]br(1df)\f[] launches \f[C]$BROWSER\f[]. +.IP \[bu] 2 +\f[C]ca(1df)\f[] prints a count of its given arguments. +.IP \[bu] 2 +\f[C]cf(1df)\f[] prints a count of entries in a given directory. +.IP \[bu] 2 +\f[C]cfr(1df)\f[] does the same as \f[C]cf(1df)\f[], but recurses into +subdirectories as well. +.IP \[bu] 2 +\f[C]chc(1df)\f[] caches the output of a command. +.IP \[bu] 2 +\f[C]chn(1df)\f[] runs a filter over its input a given number of times. +.IP \[bu] 2 +\f[C]clog(1df)\f[] is a tiny timestamped log system. +.IP \[bu] 2 +\f[C]clrd(1df)\f[] sets up a per\-line file read, clearing the screen +first. +.IP \[bu] 2 +\f[C]clwr(1df)\f[] sets up a per\-line file write, clearing the screen +before each line. +.IP \[bu] 2 +\f[C]csmw(1df)\f[] prints an English list of monospace\-quoted words +read from the input. +.IP \[bu] 2 +\f[C]dam(1df)\f[] buffers all its input before emitting it as output. +.IP \[bu] 2 +\f[C]ddup(1df)\f[] removes duplicate lines from unsorted input. +.IP \[bu] 2 +\f[C]dmp(1df)\f[] copies a pass(1) entry selected by \f[C]dmenu(1)\f[] +to the X CLIPBOARD. +.IP \[bu] 2 +\f[C]dub(1df)\f[] lists the biggest entries in a directory. +.IP \[bu] 2 +\f[C]edda(1df)\f[] provides a means to run \f[C]ed(1)\f[] over a set of +files preserving any options, mostly useful for scripts. +.IP \[bu] 2 +\f[C]eds(1df)\f[] edits executable script files in \f[C]EDSPATH\f[], +defaulting to \f[C]~/.local/bin\f[], for personal scripting snippets. +.IP \[bu] 2 +\f[C]exm(1df)\f[] works around a screen\-clearing quirk of Vim's +\f[C]ex\f[] mode. +.IP \[bu] 2 +\f[C]finc(1df)\f[] counts the number of results returned from a set of +given \f[C]find(1)\f[] conditions. +.IP \[bu] 2 +\f[C]fnl(1df)\f[] runs a command and saves its output and error into +temporary files, printing their paths and line counts. +.IP \[bu] 2 +\f[C]fnp(1df)\f[] prints the given files to stdout, each with a +plaintext heading with the filename in it. +.IP \[bu] 2 +\f[C]gms(1df)\f[] runs a set of \f[C]getmailrc\f[] files; does much the +same thing as the script \f[C]getmails\f[] in the \f[C]getmail\f[] +suite, but runs the requests in parallel and does up to three silent +retries using \f[C]try(1df)\f[]. +.IP \[bu] 2 +\f[C]grec(1df)\f[] is a more logically\-named \f[C]grep\ \-c\f[]. +.IP \[bu] 2 +\f[C]gred(1df)\f[] is a more logically\-named \f[C]grep\ \-v\f[]. +.IP \[bu] 2 +\f[C]gwp(1df)\f[] searches for alphanumeric words in a similar way to +\f[C]grep(1)\f[]. +.IP \[bu] 2 +\f[C]han(1df)\f[] provides a \f[C]keywordprg\f[] for Vim's Bash script +filetype that will look for \f[C]help\f[] topics. +You could use it from the shell too. +.IP \[bu] 2 +\f[C]igex(1df)\f[] wraps around a command to allow you to ignore error +conditions that don't actually worry you, exiting with 0 anyway. +.IP \[bu] 2 +\f[C]ix(1df)\f[] posts its input to the ix.io pastebin. +.IP \[bu] 2 +\f[C]jfp(1df)\f[] prints its input, excluding any shebang on the first +line only. +.IP \[bu] 2 +\f[C]loc(1df)\f[] is a quick\-search wrapped around \f[C]find(1)\f[]. +.IP \[bu] 2 +\f[C]maybe(1df)\f[] is like \f[C]true(1)\f[] or \f[C]false(1)\f[]; given +a probability of success, it exits with success or failure. +Good for quick tests. +.IP \[bu] 2 +\f[C]mex(1df)\f[] makes given filenames in \f[C]$PATH\f[] executable. +.IP \[bu] 2 +\f[C]mi5(1df)\f[] pre\-processes a crude but less painful macro +expansion file format into \f[C]m4\f[] input. +.IP \[bu] 2 +\f[C]mftl(1df)\f[] finds usable\-looking targets in Makefiles. +.IP \[bu] 2 +\f[C]mkcp(1df)\f[] creates a directory and copies preceding arguments +into it. +.IP \[bu] 2 +\f[C]mkmv(1df)\f[] creates a directory and moves preceding arguments +into it. +.IP \[bu] 2 +\f[C]motd(1df)\f[] shows the system MOTD. +.IP \[bu] 2 +\f[C]mw(1df)\f[] prints alphabetic space\-delimited words from the input +one per line. +.IP \[bu] 2 +\f[C]oii(1df)\f[] runs a command on input only if there is any. +.IP \[bu] 2 +\f[C]onl(1df)\f[] crunches input down to one printable line. +.IP \[bu] 2 +\f[C]osc(1df)\f[] implements a \f[C]netcat(1)\f[]\-like wrapper for +\f[C]openssl(1)\f[]'s \f[C]s_client\f[] subcommand. +.IP \[bu] 2 +\f[C]p(1df)\f[] prints concatenated standard input; \f[C]cat(1)\f[] as +it should always have been. +.IP \[bu] 2 +\f[C]pa(1df)\f[] prints its arguments, one per line. +.IP \[bu] 2 +\f[C]pp(1df)\f[] prints the full path of each argument using +\f[C]$PWD\f[]. +.IP \[bu] 2 +\f[C]pph(1df)\f[] runs \f[C]pp(1df)\f[] and includes a leading +\f[C]$HOSTNAME:\f[]. +.IP \[bu] 2 +\f[C]paz(1df)\f[] print its arguments terminated by NULL chars. +.IP \[bu] 2 +\f[C]pit(1df)\f[] runs its input through a pager if its standard output +looks like a terminal. +.IP \[bu] 2 +\f[C]plmu(1df)\f[] retrieves a list of installed modules from +\f[C]plenv\f[] (https://github.com/tokuhirom/plenv), filters out any +modules in \f[C]~/.plenv/non\-cpan\-modules\f[], and updates them all. +.IP \[bu] 2 +\f[C]pwg(1df)\f[] generates just one decent password with +\f[C]pwgen(1)\f[]. +.IP \[bu] 2 +\f[C]rep(1df)\f[] repeats a command a given number of times. +.IP \[bu] 2 +\f[C]rgl(1df)\f[] is a very crude interactive \f[C]grep(1)\f[] loop. +.IP \[bu] 2 +\f[C]shb(1df)\f[] attempts to build shebang lines for scripts from the +system paths. +.IP \[bu] 2 +\f[C]sqs(1df)\f[] chops off query strings from filenames, usually +downloads. +.IP \[bu] 2 +\f[C]sshi(1df)\f[] prints human\-readable SSH connection details. +.IP \[bu] 2 +\f[C]stex(1df)\f[] strips extensions from filenames. +.IP \[bu] 2 +\f[C]sue(8df)\f[] execs \f[C]sudoedit(8)\f[] as the owner of all the +file arguments given, perhaps in cases where you may not necessarily +have \f[C]root\f[] \f[C]sudo(8)\f[] privileges. +.IP \[bu] 2 +\f[C]swr(1df)\f[] allows you to run commands locally specifying remote +files in \f[C]scp(1)\f[]'s HOST:PATH format. +.IP \[bu] 2 +\f[C]td(1df)\f[] manages a to\-do file for you with \f[C]$EDITOR\f[] and +\f[C]git(1)\f[]; I used to use Taskwarrior, but found it too complex and +buggy. +.IP \[bu] 2 +\f[C]tm(1df)\f[] runs \f[C]tmux(1)\f[] with +\f[C]attach\-session\ \-d\f[] if a session exists, and +\f[C]new\-session\f[] if it doesn't. +.IP \[bu] 2 +\f[C]trs(1df)\f[] replaces strings (not regular expression) in its +input. +.IP \[bu] 2 +\f[C]try(1df)\f[] repeats a command up to a given number of times until +it succeeds, only printing error output if all three attempts failed. +Good for tolerating blips or temporary failures in \f[C]cron(8)\f[] +scripts. +.IP \[bu] 2 +\f[C]umake(1df)\f[] iterates upwards through the directory tree from +\f[C]$PWD\f[] until it finds a Makefile for which to run +\f[C]make(1)\f[] with the given arguments. +.IP \[bu] 2 +\f[C]uts(1df)\f[] gets the current UNIX timestamp in an unorthodox way +that should work on all POSIX\-compliant operating systems. +.IP \[bu] 2 +\f[C]vest(1df)\f[] runs \f[C]test(1)\f[] but fails with explicit output +via \f[C]vex(1df)\f[]. +.IP \[bu] 2 +\f[C]vex(1df)\f[] runs a command and prints \f[C]true\f[] or +\f[C]false\f[] explicitly to \f[C]stdout\f[] based on the exit value. +.IP \[bu] 2 +\f[C]xrbg(1df)\f[] applies the same randomly\-selected background to +each X screen. +.IP \[bu] 2 +\f[C]xrq(1df)\f[] gets the values of specific resources out of +\f[C]xrdb\ \-query\f[] output. +.PP +There's some silly stuff in \f[C]install\-games\f[]: +.IP \[bu] 2 +\f[C]aaf(6df)\f[] gets a random ASCII Art +Farts (http://www.asciiartfarts.com/) comic. +.IP \[bu] 2 +\f[C]acq(6df)\f[] allows you to interrogate AC, the interplanetary +computer. +.IP \[bu] 2 +\f[C]aesth(6df)\f[] converts English letters to their fullwidth CJK +analogues, for AESTHETIC PURPOSES. +.IP \[bu] 2 +\f[C]squ(6df)\f[] makes a reduced Latin square out of each line of +input. +.IP \[bu] 2 +\f[C]kvlt(6df)\f[] translates input to emulate a style of typing unique +to black metal communities on the internet. +.IP \[bu] 2 +\f[C]rndn(6df)\f[] implements an esoteric random number generation +algorithm. +.IP \[bu] 2 +\f[C]strik(6df)\f[] outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. +.IP \[bu] 2 +\f[C]rot13(6df)\f[] rotates the Latin letters in its input. +.IP \[bu] 2 +\f[C]xyzzy(6df)\f[] teleports to a marked location on the filesystem. +.IP \[bu] 2 +\f[C]zs(6df)\f[] prepends \[lq]z\[rq] case\-appropriately to every +occurrence of \[lq]s\[rq] in the text on its standard input. +.SS Manuals +.PP +The \f[C]install\-bin\f[] and \f[C]install\-games\f[] targets install +manuals for each script they install. +There's also an \f[C]install\-dotfiles\-man\f[] target that uses +\f[C]pandoc(1)\f[] to reformat this document as a manual page for +section 7 (\f[C]dotfiles(7df)\f[]) if you want that. +I haven't made that install by default, because \f[C]pandoc(1)\f[] is a +bit heavy. +.PP +If you want to use the manuals, you may need to add +\f[C]~/.local/share/man\f[] to your \f[C]~/.manpath\f[] or +\f[C]/etc/manpath\f[] configuration, depending on your system. +.SS Testing +.PP +You can check that both sets of shell scripts are syntactically correct +with \f[C]make\ check\-bash\f[], \f[C]make\ check\-sh\f[], or +\f[C]make\ check\f[] for everything including the scripts in +\f[C]bin\f[] and \f[C]games\f[]. +There's no proper test suite for the actual functionality (yet). +.PP +If you have ShellCheck (https://www.shellcheck.net/) and/or +Perl::Critic (http://perlcritic.com/), there's a \f[C]lint\f[] target +for the shell script files and Perl files respectively. +The files don't need to pass that check to be installed. +.SS Known issues +.PP +See ISSUES.markdown. +.SS License +.PP +Public domain; see the included \f[C]UNLICENSE\f[] file. +It's just configuration and simple scripts, so do whatever you like with +it if any of it's useful to you. +If you're feeling generous, please join and/or donate to a free software +advocacy group, and let me know you did it because of this project: +.IP \[bu] 2 +Free Software Foundation (https://www.fsf.org/) +.IP \[bu] 2 +Software in the Public Interest (https://www.spi-inc.org/) +.IP \[bu] 2 +FreeBSD Foundation (https://www.freebsdfoundation.org/) +.IP \[bu] 2 +OpenBSD Foundation (http://www.openbsdfoundation.org/) +.SH AUTHORS +Tom Ryder. diff --git a/man/man7/dotfiles.7df.header b/man/man7/dotfiles.7df.header deleted file mode 100644 index cc8aef57..00000000 --- a/man/man7/dotfiles.7df.header +++ /dev/null @@ -1,3 +0,0 @@ -% DOTFILES(7) Tom Ryder's personal scripts and configuration -% Tom Ryder -% June 2016 -- cgit v1.2.3 From a2e6c142769658ae48458c3b4c5dfd9cd00be87a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 18:13:20 +1200 Subject: Work around no options terminal in POSIX chmod(1) --- bin/mex.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/mex.sh b/bin/mex.sh index 0b3d6c7e..cf4e07e7 100644 --- a/bin/mex.sh +++ b/bin/mex.sh @@ -37,7 +37,11 @@ for name ; do # If the "found" variable was defined to something, we'll try to change its # permissions if [ -n "$found" ] ; then - chmod +x -- "$found" || ex=1 + case $found in + /*) ;; + *) found=$PWD/$found ;; + esac + chmod +x "$found" || ex=1 # If not, we'll report that we couldn't find it, and flag an error for the # exit status -- cgit v1.2.3 From b6dcf69a979a6502b97f4b18837d5889d8d31ab6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 20:11:44 +1200 Subject: First attempt at pks(6df) I've got a better idea, though --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + games/pks.awk | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man6/pks.6df | 21 +++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 games/pks.awk create mode 100644 man/man6/pks.6df diff --git a/.gitignore b/.gitignore index 21d294c4..ce1910c3 100644 --- a/.gitignore +++ b/.gitignore @@ -151,6 +151,7 @@ games/chkl games/dr games/drakon games/kvlt +games/pks games/rndn games/rot13 games/squ diff --git a/Makefile b/Makefile index 22d5ac8e..28a58805 100644 --- a/Makefile +++ b/Makefile @@ -228,6 +228,7 @@ GAMES = games/aaf \ games/dr \ games/drakon \ games/kvlt \ + games/pks \ games/rndn \ games/rot13 \ games/squ \ diff --git a/README.markdown b/README.markdown index 30e94d10..830ca51d 100644 --- a/README.markdown +++ b/README.markdown @@ -554,6 +554,7 @@ There's some silly stuff in `install-games`: * `squ(6df)` makes a reduced Latin square out of each line of input. * `kvlt(6df)` translates input to emulate a style of typing unique to black metal communities on the internet. +* `pks(6df)` laughs at a randomly selected word. * `rndn(6df)` implements an esoteric random number generation algorithm. * `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. * `rot13(6df)` rotates the Latin letters in its input. diff --git a/games/pks.awk b/games/pks.awk new file mode 100644 index 00000000..ff316fb9 --- /dev/null +++ b/games/pks.awk @@ -0,0 +1,81 @@ +# Ha, ha, ha! Awk! + +# Print either two or three "has" and the given word, capitalized +function haha(wr) { + + # Two or three "has"? Important decisions here folks + srand() + hr = int(rand()*2+1) + for (ha = "Ha"; hi < hr; hi++) + ha = ha ", ha" + + # Capitalise the word + wr = toupper(substr(wr,1,1)) substr(wr,2) + + # Return the laughter and the word + return ha "! " wr "!" +} + +# Ha, ha! Failure! +function fail(str, ex) { + af = 1 + print haha(str) | "cat >&2" + exit(ex) +} + +# Process arguments +BEGIN { + + # If no arguments, assume a dictionary file + if (ARGC == 1) { + ARGC = 2 + if ("DICT" in ENVIRON) + ARGV[1] = ENVIRON["DICT"] + else + ARGV[1] = "/usr/share/dict/words" + } + + # Check the user hasn't tried stdin + for (ai = 1; ai < ARGC; ai++) + if (ARGV[ai] == "-") + fail("standard input", 2) + + # Count the number of lines in the files (pass 1) + for (ai = 1; ai < ARGC; ai++) + while (getline < ARGV[ai]) + lc++ + + # If all files were empty, we can't go on + if (lc == 0) + fail("no data", 1) + + # Pick a random line number + srand() + lr = int(lc*rand()+1) +} + +# Iterate over the file until we get to the selected line (pass 2) +NR >= lr { + + # Find the first word-looking thing + for (i = 1; !wr && i <= NF; i++) + if (tolower($i) ~ /[[:lower:]]/) + wr = $i + + # Strip trailing possessives + sub(/'s*$/, "", wr) + + # No word? Uh, better keep going + if (!length(wr)) + next + + # Ha, ha! Suboptimal! + print haha(wr) + exit(0) +} + +# Ha, ha, ha! Incompetent! +END { + if (!af && !length(wr)) + fail("error", 1) +} diff --git a/man/man6/pks.6df b/man/man6/pks.6df new file mode 100644 index 00000000..03ab7251 --- /dev/null +++ b/man/man6/pks.6df @@ -0,0 +1,21 @@ +.TH PKS 6df "July 2017" "Manual page for pks" +.SH NAME +.B pks +\- select and laugh at a random word from a system dictionary or fileset +.SH USAGE +.B pks +.br +.B pks +FILE1 FILE2 +.br +DICT=$HOME/dict +.B pks +.SH DESCRIPTION +.B pks +picks a random word from a set of files and laughs at it. If no files are +given, it defaults to /usr/share/dict/words, or the value of DICT (ha, ha!) if +specified in the environment. +.SH SEE ALSO + +.SH AUTHOR +Tom Ryder -- cgit v1.2.3 From dbc1be0317ad5e70afb895648f4d6c8f0fbc1080 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 21:22:28 +1200 Subject: Better implementation of pks(6df) Needs a lot of random numbers, but only one pass --- games/pks.awk | 75 ++++++++++++++------------------------------------------ man/man6/pks.6df | 12 ++++++--- 2 files changed, 28 insertions(+), 59 deletions(-) diff --git a/games/pks.awk b/games/pks.awk index ff316fb9..c490e8dc 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -1,28 +1,5 @@ # Ha, ha, ha! Awk! -# Print either two or three "has" and the given word, capitalized -function haha(wr) { - - # Two or three "has"? Important decisions here folks - srand() - hr = int(rand()*2+1) - for (ha = "Ha"; hi < hr; hi++) - ha = ha ", ha" - - # Capitalise the word - wr = toupper(substr(wr,1,1)) substr(wr,2) - - # Return the laughter and the word - return ha "! " wr "!" -} - -# Ha, ha! Failure! -function fail(str, ex) { - af = 1 - print haha(str) | "cat >&2" - exit(ex) -} - # Process arguments BEGIN { @@ -35,47 +12,33 @@ BEGIN { ARGV[1] = "/usr/share/dict/words" } - # Check the user hasn't tried stdin - for (ai = 1; ai < ARGC; ai++) - if (ARGV[ai] == "-") - fail("standard input", 2) - - # Count the number of lines in the files (pass 1) - for (ai = 1; ai < ARGC; ai++) - while (getline < ARGV[ai]) - lc++ - - # If all files were empty, we can't go on - if (lc == 0) - fail("no data", 1) - - # Pick a random line number + # Seed the random number generator srand() - lr = int(lc*rand()+1) } -# Iterate over the file until we get to the selected line (pass 2) -NR >= lr { +# Iterate over the lines, randomly assigning the first field of each one with a +# decreasing probability; this method +rand() * NR < 1 { wr = $1 } + +# Ha, ha, ha! Incompetent! +END { - # Find the first word-looking thing - for (i = 1; !wr && i <= NF; i++) - if (tolower($i) ~ /[[:lower:]]/) - wr = $i + # Check that we processed at least one line + if (!NR) + exit 1 # Strip trailing possessives sub(/'s*$/, "", wr) - # No word? Uh, better keep going - if (!length(wr)) - next + # Two or three "has"? Important decisions here folks + srand() + hr = int(rand()*2+1) + for (ha = "Ha"; hi < hr; hi++) + ha = ha ", ha" - # Ha, ha! Suboptimal! - print haha(wr) - exit(0) -} + # Capitalise the word + wr = toupper(substr(wr,1,1)) substr(wr,2) -# Ha, ha, ha! Incompetent! -END { - if (!af && !length(wr)) - fail("error", 1) + # Return the laughter and the word + printf "%s! %s!\n", ha, wr } diff --git a/man/man6/pks.6df b/man/man6/pks.6df index 03ab7251..30ae4ba1 100644 --- a/man/man6/pks.6df +++ b/man/man6/pks.6df @@ -8,13 +8,19 @@ .B pks FILE1 FILE2 .br +program | +.B pks +- +.br DICT=$HOME/dict .B pks .SH DESCRIPTION .B pks -picks a random word from a set of files and laughs at it. If no files are -given, it defaults to /usr/share/dict/words, or the value of DICT (ha, ha!) if -specified in the environment. +picks the first word from a random line on a set of files and laughs at it. If +no files are given, it defaults to /usr/share/dict/words, or the value of DICT +(ha, ha!) if specified in the environment. +.P +A hyphen character "-" can be given as an argument to select standard input. .SH SEE ALSO .SH AUTHOR -- cgit v1.2.3 From 7adef2006aaff89db93c87fd1470a688fb1d4907 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 21:49:27 +1200 Subject: Reimplement rndl(1df) in Awk Removes the need for the temporary file. Also refactor pks(6df) to accommodate it. --- .gitignore | 2 -- Makefile | 3 --- bin/rndl.awk | 29 +++++++++++++++++++++++++++++ bin/rndl.mi5 | 38 -------------------------------------- games/pks.awk | 10 +++++----- man/man1/rndl.1df | 2 +- 6 files changed, 35 insertions(+), 49 deletions(-) create mode 100644 bin/rndl.awk delete mode 100644 bin/rndl.mi5 diff --git a/.gitignore b/.gitignore index ce1910c3..7e2ae706 100644 --- a/.gitignore +++ b/.gitignore @@ -95,8 +95,6 @@ bin/rnda bin/rndf bin/rndi bin/rndl -bin/rndl.sh -bin/rndl.m4 bin/rnds bin/sd2u bin/sec diff --git a/Makefile b/Makefile index 28a58805..a5af63a9 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,6 @@ BINS_M4 = bin/chn.m4 \ bin/edda.m4 \ bin/oii.m4 \ bin/pst.m4 \ - bin/rndl.m4 \ bin/swr.m4 \ bin/tlcs.m4 \ bin/try.m4 \ @@ -215,7 +214,6 @@ BINS_SH = bin/chn.sh \ bin/edda.sh \ bin/oii.sh \ bin/pst.sh \ - bin/rndl.sh \ bin/swr.sh \ bin/tlcs.sh \ bin/try.sh \ @@ -282,7 +280,6 @@ bin/chn.sh: bin/chn.m4 include/mktd.m4 bin/edda.sh: bin/edda.m4 include/mktd.m4 bin/oii.sh: bin/oii.m4 include/mktd.m4 bin/pst.sh: bin/pst.m4 include/mktd.m4 -bin/rndl.sh: bin/rndl.m4 include/mktd.m4 bin/swr.sh: bin/swr.m4 include/mktd.m4 bin/tlcs.sh: bin/tlcs.m4 include/mktd.m4 bin/try.sh: bin/try.m4 include/mktd.m4 diff --git a/bin/rndl.awk b/bin/rndl.awk new file mode 100644 index 00000000..8359af90 --- /dev/null +++ b/bin/rndl.awk @@ -0,0 +1,29 @@ +# Print a random line from input + +# Process arguments +BEGIN { + + # Name self + self = "rndl" + + # Seed the random number generator + "rnds 2>/dev/null" | getline seed + srand(seed) +} + +# Iterate over the lines, randomly assigning the first field of each one with a +# decreasing probability +rand() * NR < 1 { ln = $0 } + +# Check and print +END { + + # Check that we processed at least one line + if (!NR) { + printf "%s: No lines found on input\n", self | "cat >&2" + exit(1) + } + + # Print the line + print ln +} diff --git a/bin/rndl.mi5 b/bin/rndl.mi5 deleted file mode 100644 index f99ccbea..00000000 --- a/bin/rndl.mi5 +++ /dev/null @@ -1,38 +0,0 @@ -# Print a random line from input -self=rndl - -# If there are no arguments, we're checking stdin; this is more complicated -# than checking file arguments because we have to count the lines in order to -# correctly choose a random one, and two passes means we require a temporary -# file if we don't want to read all of the input into memory (!) -if [ "$#" -eq 0 ] ; then - -<% -include(`include/mktd.m4') -%> - - # We'll operate on stdin in the temp directory; write the script's stdin to - # it with cat(1) - set -- "$td"/stdin - cat >"$td"/stdin -fi - -# Count the number of lines in the input -lc=$(sed -- '$=;d' "$@") || exit - -# If there were none, bail -case $lc in - ''|0) - printf >&2 'rndl: No lines found on input\n' - exit 2 - ;; -esac - -# Try to get a random seed from rnds(1df) for rndi(1df) -seed=$(rnds) - -# Get a random line number from rndi(1df) -ri=$(rndi 1 "$lc" "$seed") || exit - -# Print the line using sed(1) -sed -- "$ri"'!d' "$@" diff --git a/games/pks.awk b/games/pks.awk index c490e8dc..c7ff320d 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -13,12 +13,13 @@ BEGIN { } # Seed the random number generator - srand() + "rnds 2>/dev/null" | getline seed + srand(seed) } # Iterate over the lines, randomly assigning the first field of each one with a # decreasing probability; this method -rand() * NR < 1 { wr = $1 } +$1 ~ /[[:alpha:]]/ && rand() * ++n < 1 { wr = $1 } # Ha, ha, ha! Incompetent! END { @@ -27,11 +28,10 @@ END { if (!NR) exit 1 - # Strip trailing possessives - sub(/'s*$/, "", wr) + # Strip trailing possessives and punctuation + sub(/[^[:alpha:]]+s*$/, "", wr) # Two or three "has"? Important decisions here folks - srand() hr = int(rand()*2+1) for (ha = "Ha"; hi < hr; hi++) ha = ha ", ha" diff --git a/man/man1/rndl.1df b/man/man1/rndl.1df index ec44564a..0e952724 100644 --- a/man/man1/rndl.1df +++ b/man/man1/rndl.1df @@ -13,7 +13,7 @@ command | .B rndl .SH DESCRIPTION .B rndl -prints a random line from its input, using rndi(1df) to choose it. This is +prints a random line from its input, using rnds(1df) as a seed. This is probably not a high-quality source, but should differ within seconds and between runs on most systems. .SH SEE ALSO -- cgit v1.2.3 From 59dba36a9a91d17684e7ea31925a93d465c9d314 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 22:01:48 +1200 Subject: Correct srand() arg count --- bin/rndl.awk | 5 ++++- games/pks.awk | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/rndl.awk b/bin/rndl.awk index 8359af90..f495a28c 100644 --- a/bin/rndl.awk +++ b/bin/rndl.awk @@ -8,7 +8,10 @@ BEGIN { # Seed the random number generator "rnds 2>/dev/null" | getline seed - srand(seed) + if (length(seed)) + srand(seed) + else + srand() } # Iterate over the lines, randomly assigning the first field of each one with a diff --git a/games/pks.awk b/games/pks.awk index c7ff320d..1e69f4ee 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -14,7 +14,10 @@ BEGIN { # Seed the random number generator "rnds 2>/dev/null" | getline seed - srand(seed) + if (length(seed)) + srand(seed) + else + srand() } # Iterate over the lines, randomly assigning the first field of each one with a -- cgit v1.2.3 From 7d86a4bca3500885cd2f9b11cd97688685ccb7c5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 22:16:55 +1200 Subject: Put local gamesdir at end of PATH So that if anything actually important has the same name, that's used instead --- sh/profile.d/games.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/profile.d/games.sh b/sh/profile.d/games.sh index ee56c593..956d1de1 100644 --- a/sh/profile.d/games.sh +++ b/sh/profile.d/games.sh @@ -1,3 +1,3 @@ # Add ~/.local/games to PATH if it exists [ -d "$HOME"/.local/games ] || return -PATH=$HOME/.local/games:$PATH +PATH=$PATH:$HOME/.local/games -- cgit v1.2.3 From d54558806aea74bd0096f52a938f5876b3167239 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 22:31:57 +1200 Subject: Correct Awk variable lvalue in mw(1df) --- bin/mw.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mw.awk b/bin/mw.awk index 84332fac..48f45fb1 100644 --- a/bin/mw.awk +++ b/bin/mw.awk @@ -1,7 +1,7 @@ # Crude approach to get alphabetic words one per line from input, not sorted or # deduplicated BEGIN { - RS = "(--|['_-]*[^[:alnum:]'_-]+['_-]*)" + FS = "(--|['_-]*[^[:alnum:]'_-]+['_-]*)" } { for (i = 1; i <= NF; i++) -- cgit v1.2.3 From 44628c19f1fca7966c1fa9b2b07aded7f978d1e1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jul 2017 23:49:35 +1200 Subject: Fix typo --- games/pks.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/pks.awk b/games/pks.awk index 1e69f4ee..fb40ce7b 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -34,7 +34,7 @@ END { # Strip trailing possessives and punctuation sub(/[^[:alpha:]]+s*$/, "", wr) - # Two or three "has"? Important decisions here folks + # Two or three "ha"s? Important decisions here folks hr = int(rand()*2+1) for (ha = "Ha"; hi < hr; hi++) ha = ha ", ha" -- cgit v1.2.3 From 041a0647af74ac37ed7f1612a86a44ef253d38ab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/unimpaired | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired index 7bbbca73..e1e0cc38 160000 --- a/vim/bundle/unimpaired +++ b/vim/bundle/unimpaired @@ -1 +1 @@ -Subproject commit 7bbbca73233b1492a8c3d16f91f34340eccc9b30 +Subproject commit e1e0cc3859323f354b8d905ca177e172c7d69f0e -- cgit v1.2.3 From e003aab4fe76515593b86b6bd40f7f7d816fd12c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 01:03:59 +1200 Subject: Very important addenda to pks(6df) --- games/pks.awk | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- man/man6/pks.6df | 4 +++ 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/games/pks.awk b/games/pks.awk index fb40ce7b..2219872b 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -3,8 +3,27 @@ # Process arguments BEGIN { - # If no arguments, assume a dictionary file - if (ARGC == 1) { + # Look for options; keep a count of non-option args + ac = ARGC + for (i = 1; i <= ARGC; i++) { + + # Show a pic of Phil + if (ARGV[i] == "--phil") { + pic = 1 + ARGV[i] = "" + ac-- + } + + # End-of-options + if (ARGV[i] == "--") { + break + ARGV[i] = "" + ac-- + } + } + + # If no arguments left, assume a dictionary file + if (ac == 1) { ARGC = 2 if ("DICT" in ENVIRON) ARGV[1] = ENVIRON["DICT"] @@ -43,5 +62,55 @@ END { wr = toupper(substr(wr,1,1)) substr(wr,2) # Return the laughter and the word - printf "%s! %s!\n", ha, wr + if (pic) + dopic(ha, wr) + else + printf "%s! %s!\n", ha, wr +} + +# Ha, ha! Low-res! +function dopic(ha, wr) { + print "" + print " " ha "! " wr "!" + print " \\" + print " .''''''''''''''''''''''.." + print " .'''''''''''''''''''''''''''" + print " .'''''''''''''''''''''''''''''" + print " ,'''''''''''''''''''''''''''''''" + print " '''''''''''''''''''''''''''''''':" + print " ,'''''''''''##`'''''''''''''''.'''`" + print " ;''''''''.###########,'''''',###'''" + print " ;'''''';#################:'#####.''" + print " `:''''''#########################'." + print " ::` ,'+########################';" + print " ''''''': .#####################''" + print " ''''''''.####` `;#############;##'" + print " ;''''''',####,###: +############." + print " ,###''''''#############` ;##:#######" + print " ,#:##''';+#####+ :###### +##+ +" + print " ,'#;#,''#####',+###` ;####`+ " + print " ,#'#,#';############++. ,`## " + print " :#####+:#######,@,``@@,#####' " + print " ;#+#+#############++++##.#+## +" + print " ###+################'####'## " + print " #######+###################.# :." + print " ######'########################'" + print " ,+#####;#######################" + print " ,#######;############'####+###:" + print " ,#######################+#####'" + print " ,###############' ` #'# +'#" + print " #,##.###########'##+##'###'####" + print " ``@.############## `+#@@@@@######" + print " +```@@################ ,,. . ####." + print " ;````@@,##.##############':..:######" + print " ;`````@@@########.##################" + print " +````````@@@@#####;####################:" + print " +`````.`````@@@@######`###################```+" + print " +````````,`````'@@@@@##'#####################`````." + print "+ ``````````.``````@@@@@@##'###'################```````` +" + print "```````````````````@@@@@@@'#####;##########,##'`````````````.+" + print "```````````````````@@@@@@@@@+#####':####+:+'````````````````````," + print "```````````````````,@@@@@@@@@#:#########'@@@``````````````````````" + print "```````````.````````@@@@@@@@@@@@#'#####@@@@@```````````````````````" + print "```````````.````````@@@@@@@@@@@@@@' @@@@@@@.``````````````````````" } diff --git a/man/man6/pks.6df b/man/man6/pks.6df index 30ae4ba1..47ddf7aa 100644 --- a/man/man6/pks.6df +++ b/man/man6/pks.6df @@ -12,6 +12,8 @@ program | .B pks - .br +.B pks +--phil DICT=$HOME/dict .B pks .SH DESCRIPTION @@ -21,6 +23,8 @@ no files are given, it defaults to /usr/share/dict/words, or the value of DICT (ha, ha!) if specified in the environment. .P A hyphen character "-" can be given as an argument to select standard input. +.P +Adding --phil will show a picture of our founder, Phil Ken Sebben. .SH SEE ALSO .SH AUTHOR -- cgit v1.2.3 From f60184867b480bba44e5d4470dd8d58882195832 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 01:40:32 +1200 Subject: Break pks(6df) and philsay(6df) in two Looks like awk(1) implementations vary in how they interpret option arguments. --- .gitignore | 1 + Makefile | 1 + README.markdown | 1 + games/philsay.sh | 47 ++++++++++++++++++++++++++++++ games/pks.awk | 80 ++++------------------------------------------------ man/man6/philsay.6df | 28 ++++++++++++++++++ man/man6/pks.6df | 6 ++-- 7 files changed, 86 insertions(+), 78 deletions(-) create mode 100644 games/philsay.sh create mode 100644 man/man6/philsay.6df diff --git a/.gitignore b/.gitignore index 7e2ae706..deccfe5e 100644 --- a/.gitignore +++ b/.gitignore @@ -149,6 +149,7 @@ games/chkl games/dr games/drakon games/kvlt +games/philsay games/pks games/rndn games/rot13 diff --git a/Makefile b/Makefile index a5af63a9..6cfee7a1 100644 --- a/Makefile +++ b/Makefile @@ -226,6 +226,7 @@ GAMES = games/aaf \ games/dr \ games/drakon \ games/kvlt \ + games/philsay \ games/pks \ games/rndn \ games/rot13 \ diff --git a/README.markdown b/README.markdown index 830ca51d..adc4c73a 100644 --- a/README.markdown +++ b/README.markdown @@ -554,6 +554,7 @@ There's some silly stuff in `install-games`: * `squ(6df)` makes a reduced Latin square out of each line of input. * `kvlt(6df)` translates input to emulate a style of typing unique to black metal communities on the internet. +* `philsay(6df)` shows a picture to accompany `pks(6df)` output. * `pks(6df)` laughs at a randomly selected word. * `rndn(6df)` implements an esoteric random number generation algorithm. * `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. diff --git a/games/philsay.sh b/games/philsay.sh new file mode 100644 index 00000000..dac2ae6e --- /dev/null +++ b/games/philsay.sh @@ -0,0 +1,47 @@ +#!/bin/shp +speech=$(pks "$@") || exit +printf '\n%066s\n' '( '"$speech"' )' +cat <<'EOF' + / + + .''''''''''''''''''''''.. + .''''''''''''''''''''''''''' + .''''''''''''''''''''''''''''' + ,''''''''''''''''''''''''''''''' + '''''''''''''''''''''''''''''''': + ,'''''''''''##`'''''''''''''''.'''` + ;''''''''.###########,'''''',###''' + ;'''''';#################:'#####.'' + `:''''''#########################'. + ::` ,'+########################'; + ''''''': .#####################'' + ''''''''.####` `;#############;##' + ;''''''',####,###: +############. + ,###''''''#############` ;##:####### + ,#:##''';+#####+ :###### +##+ + + ,'#;#,''#####',+###` ;####`+ + ,#'#,#';############++. ,`## + :#####+:#######,@,``@@,#####' + ;#+#+#############++++##.#+## + + ###+################'####'## + #######+###################.# :. + ######'########################' + ,+#####;####################### + ,#######;############'####+###: + ,#######################+#####' + ,###############' ` #'# +'# + #,##.###########'##+##'###'#### + ``@.############## `+#@@@@@###### + +```@@################ ,,. . ####. + ;````@@,##.##############':..:###### + ;`````@@@########.################## + +````````@@@@#####;####################: + +`````.`````@@@@######`###################```+ + +````````,`````'@@@@@##'#####################`````. ++ ``````````.``````@@@@@@##'###'################```````` + +```````````````````@@@@@@@'#####;##########,##'`````````````.+ +```````````````````@@@@@@@@@+#####':####+:+'````````````````````, +```````````````````,@@@@@@@@@#:#########'@@@`````````````````````` +```````````.````````@@@@@@@@@@@@#'#####@@@@@``````````````````````` +```````````.````````@@@@@@@@@@@@@@' @@@@@@@.`````````````````````` +EOF diff --git a/games/pks.awk b/games/pks.awk index 2219872b..06aad75f 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -3,27 +3,8 @@ # Process arguments BEGIN { - # Look for options; keep a count of non-option args - ac = ARGC - for (i = 1; i <= ARGC; i++) { - - # Show a pic of Phil - if (ARGV[i] == "--phil") { - pic = 1 - ARGV[i] = "" - ac-- - } - - # End-of-options - if (ARGV[i] == "--") { - break - ARGV[i] = "" - ac-- - } - } - # If no arguments left, assume a dictionary file - if (ac == 1) { + if (ARGC == 1) { ARGC = 2 if ("DICT" in ENVIRON) ARGV[1] = ENVIRON["DICT"] @@ -40,10 +21,11 @@ BEGIN { } # Iterate over the lines, randomly assigning the first field of each one with a -# decreasing probability; this method +# decreasing probability; this method allows a single pass over the input, +# though it requires a lot of random numbers $1 ~ /[[:alpha:]]/ && rand() * ++n < 1 { wr = $1 } -# Ha, ha, ha! Incompetent! +# Ha, ha! Conclusion! END { # Check that we processed at least one line @@ -61,56 +43,6 @@ END { # Capitalise the word wr = toupper(substr(wr,1,1)) substr(wr,2) - # Return the laughter and the word - if (pic) - dopic(ha, wr) - else - printf "%s! %s!\n", ha, wr -} - -# Ha, ha! Low-res! -function dopic(ha, wr) { - print "" - print " " ha "! " wr "!" - print " \\" - print " .''''''''''''''''''''''.." - print " .'''''''''''''''''''''''''''" - print " .'''''''''''''''''''''''''''''" - print " ,'''''''''''''''''''''''''''''''" - print " '''''''''''''''''''''''''''''''':" - print " ,'''''''''''##`'''''''''''''''.'''`" - print " ;''''''''.###########,'''''',###'''" - print " ;'''''';#################:'#####.''" - print " `:''''''#########################'." - print " ::` ,'+########################';" - print " ''''''': .#####################''" - print " ''''''''.####` `;#############;##'" - print " ;''''''',####,###: +############." - print " ,###''''''#############` ;##:#######" - print " ,#:##''';+#####+ :###### +##+ +" - print " ,'#;#,''#####',+###` ;####`+ " - print " ,#'#,#';############++. ,`## " - print " :#####+:#######,@,``@@,#####' " - print " ;#+#+#############++++##.#+## +" - print " ###+################'####'## " - print " #######+###################.# :." - print " ######'########################'" - print " ,+#####;#######################" - print " ,#######;############'####+###:" - print " ,#######################+#####'" - print " ,###############' ` #'# +'#" - print " #,##.###########'##+##'###'####" - print " ``@.############## `+#@@@@@######" - print " +```@@################ ,,. . ####." - print " ;````@@,##.##############':..:######" - print " ;`````@@@########.##################" - print " +````````@@@@#####;####################:" - print " +`````.`````@@@@######`###################```+" - print " +````````,`````'@@@@@##'#####################`````." - print "+ ``````````.``````@@@@@@##'###'################```````` +" - print "```````````````````@@@@@@@'#####;##########,##'`````````````.+" - print "```````````````````@@@@@@@@@+#####':####+:+'````````````````````," - print "```````````````````,@@@@@@@@@#:#########'@@@``````````````````````" - print "```````````.````````@@@@@@@@@@@@#'#####@@@@@```````````````````````" - print "```````````.````````@@@@@@@@@@@@@@' @@@@@@@.``````````````````````" + # Print the laughter and the word + printf "%s! %s!\n", ha, wr } diff --git a/man/man6/philsay.6df b/man/man6/philsay.6df new file mode 100644 index 00000000..4de7c476 --- /dev/null +++ b/man/man6/philsay.6df @@ -0,0 +1,28 @@ +.TH PHILSAY 6df "July 2017" "Manual page for philsay" +.SH NAME +.B philsay +\- Ha, ha, ha! ASCII art! +.SH USAGE +.B philsay +.br +.B philsay +FILE1 FILE2 +.br +program | +.B philsay +- +.br +DICT=$HOME/dict +.B philsay +.SH DESCRIPTION +.B philsay +shows a picture of our founder, Phil Ken Sebben, saying the first word of a +line randomly chosen from the input using pks(6df). +.P +A hyphen character "-" can be given as an argument to select standard input. +.SH SEE ALSO +pks(6df), cowsay(1df) +.br + +.SH AUTHOR +Tom Ryder diff --git a/man/man6/pks.6df b/man/man6/pks.6df index 47ddf7aa..dc430eff 100644 --- a/man/man6/pks.6df +++ b/man/man6/pks.6df @@ -12,8 +12,6 @@ program | .B pks - .br -.B pks ---phil DICT=$HOME/dict .B pks .SH DESCRIPTION @@ -23,9 +21,9 @@ no files are given, it defaults to /usr/share/dict/words, or the value of DICT (ha, ha!) if specified in the environment. .P A hyphen character "-" can be given as an argument to select standard input. -.P -Adding --phil will show a picture of our founder, Phil Ken Sebben. .SH SEE ALSO +philsay(6df) +.br .SH AUTHOR Tom Ryder -- cgit v1.2.3 From ca3cc521dd28478c9b51b7c3d9a176835cfa6fa9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 02:13:25 +1200 Subject: Remove POSIX char classes from Awk I forgot that Debian's awk(1) is still a mawk that doesn't implement e.g. [:alpha:] --- bin/mw.awk | 2 +- bin/onl.awk | 4 ++-- foo | 0 games/drakon.awk | 2 +- games/pks.awk | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 foo diff --git a/bin/mw.awk b/bin/mw.awk index 48f45fb1..95d70c32 100644 --- a/bin/mw.awk +++ b/bin/mw.awk @@ -5,6 +5,6 @@ BEGIN { } { for (i = 1; i <= NF; i++) - if ($i ~ /[[:alpha:]]/) + if ($i ~ /[a-zA-Z]/) print $i } diff --git a/bin/onl.awk b/bin/onl.awk index 466b8451..15e4f46d 100644 --- a/bin/onl.awk +++ b/bin/onl.awk @@ -2,8 +2,8 @@ # For each line of input ... { - # Strip out non-printable characters and rebuild the fields - gsub(/[[:cntrl:]]/, "") + # Strip out whitespace characters and rebuild the fields + gsub(/[\n\t\r ]+/, "") # Print each field, without a newline; add a leading space if it's not the # very first one diff --git a/foo b/foo new file mode 100644 index 00000000..e69de29b diff --git a/games/drakon.awk b/games/drakon.awk index ce619585..ebca4e95 100644 --- a/games/drakon.awk +++ b/games/drakon.awk @@ -6,7 +6,7 @@ tog = 0 for (i = 1; i <= len; i++) { chr = substr($0, i, 1) - if (chr ~ /[[:alpha:]]/) + if (chr ~ /[a-zA-Z]/) chr = (tog = !tog) ? tolower(chr) : toupper(chr) lin = lin chr } diff --git a/games/pks.awk b/games/pks.awk index 06aad75f..028e471f 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -23,7 +23,7 @@ BEGIN { # Iterate over the lines, randomly assigning the first field of each one with a # decreasing probability; this method allows a single pass over the input, # though it requires a lot of random numbers -$1 ~ /[[:alpha:]]/ && rand() * ++n < 1 { wr = $1 } +$1 ~ /[a-zA-Z]/ && rand() * ++n < 1 { wr = $1 } # Ha, ha! Conclusion! END { @@ -33,7 +33,7 @@ END { exit 1 # Strip trailing possessives and punctuation - sub(/[^[:alpha:]]+s*$/, "", wr) + sub(/[^a-zA-Z]+s*$/, "", wr) # Two or three "ha"s? Important decisions here folks hr = int(rand()*2+1) -- cgit v1.2.3 From ebce693d72875a7b1f4a0fed3b6bd9caf01cb37b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 14:47:43 +1200 Subject: Remove bad shebang from philsay.sh --- games/philsay.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/games/philsay.sh b/games/philsay.sh index dac2ae6e..9270c52e 100644 --- a/games/philsay.sh +++ b/games/philsay.sh @@ -1,4 +1,3 @@ -#!/bin/shp speech=$(pks "$@") || exit printf '\n%066s\n' '( '"$speech"' )' cat <<'EOF' -- cgit v1.2.3 From cb6014e61a2ffd2c80184e5e9576178ea3c58014 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 16:07:36 +1200 Subject: Remove null FS assignment from trs(1df) gawk's --lint option complains: > awk: .dotfiles/bin/trs.awk:7: warning: null string for `FS' is a gawk extension --- bin/trs.awk | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/trs.awk b/bin/trs.awk index 8d0a1ef0..58fdf8a9 100644 --- a/bin/trs.awk +++ b/bin/trs.awk @@ -3,9 +3,6 @@ BEGIN { # Name self self = "trs" - # No wordsplitting required - FS = "" - # Two and only two arguments required if (ARGC != 3) fail("Need a string and a replacement") -- cgit v1.2.3 From 8d3157099a35fa2e1d1d192bb66e1c898e7332f9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 16:16:02 +1200 Subject: Coerce seed to number --- bin/rndl.awk | 2 +- games/pks.awk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/rndl.awk b/bin/rndl.awk index f495a28c..8feb4f90 100644 --- a/bin/rndl.awk +++ b/bin/rndl.awk @@ -9,7 +9,7 @@ BEGIN { # Seed the random number generator "rnds 2>/dev/null" | getline seed if (length(seed)) - srand(seed) + srand(seed + 0) else srand() } diff --git a/games/pks.awk b/games/pks.awk index 028e471f..4c28625c 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -15,7 +15,7 @@ BEGIN { # Seed the random number generator "rnds 2>/dev/null" | getline seed if (length(seed)) - srand(seed) + srand(seed + 0) else srand() } -- cgit v1.2.3 From 95276f25769a0607cda50041169197d0522b98ff Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 17:36:37 +1200 Subject: Lots of cleanup of awk scripts Mostly inspired by suggestions from gawk --lint --- bin/csmw.awk | 1 + bin/ddup.awk | 6 +++++- bin/gwp.awk | 11 ++++++++--- bin/hms.awk | 16 ++++++++++++---- bin/max.awk | 6 ++---- bin/mean.awk | 3 ++- bin/med.awk | 10 +++++++++- bin/mftl.awk | 10 ++++++++-- bin/mi5.awk | 19 ++++++++----------- bin/rndi.awk | 35 ++++++++++++++++++++++++++++------- bin/rndl.awk | 8 ++++++-- bin/sec.awk | 18 ++++++++++++++---- bin/tot.awk | 1 + bin/trs.awk | 6 ++++-- bin/unf.awk | 2 ++ bin/xrq.awk | 9 +++++++-- foo | 0 games/pks.awk | 4 +++- man/man1/mi5.1df | 2 +- 19 files changed, 121 insertions(+), 46 deletions(-) delete mode 100644 foo diff --git a/bin/csmw.awk b/bin/csmw.awk index 4479d8f8..351fc749 100644 --- a/bin/csmw.awk +++ b/bin/csmw.awk @@ -1,4 +1,5 @@ # Print an English comma-separated list of monospace-quoted words (backticks) +BEGIN { wc = 0 } { for (i = 1; i <= NF; i++) ws[++wc] = "`" $i "`" diff --git a/bin/ddup.awk b/bin/ddup.awk index 2dec1d00..63381cfb 100644 --- a/bin/ddup.awk +++ b/bin/ddup.awk @@ -1,2 +1,6 @@ # Skip duplicate lines (without requiring sorted input) -!seen[$0]++ +$0 in seen { next } +length($0) { + seen[$0] = 1 + print +} diff --git a/bin/gwp.awk b/bin/gwp.awk index f1e3b3bd..6b558388 100644 --- a/bin/gwp.awk +++ b/bin/gwp.awk @@ -7,6 +7,9 @@ BEGIN { # Words are separated by any non-alphanumeric characters FS = "[^a-zA-Z0-9]+" + # Nothing found yet + found = 0 + # First argument is the word required; push its case downward so we can # match case-insensitively word = tolower(ARGV[1]) @@ -15,15 +18,17 @@ BEGIN { ARGV[1] = "" # Bail out if we don't have a suitable word - if (!word) + if (!length(word)) fail("Need a single non-null alphanumeric string as a search word") if (word ~ FS) fail("Word contains non-alphanumeric characters; use grep(1)") } # Bailout function -function fail(str) { - printf "%s: %s\n", self, str | "cat >&2" +function fail(msg) { + stderr = "cat >&2" + printf "%s: %s\n", self, msg | stderr + close(stderr) exit(2) } diff --git a/bin/hms.awk b/bin/hms.awk index 3054db44..2aa492a1 100644 --- a/bin/hms.awk +++ b/bin/hms.awk @@ -1,19 +1,23 @@ # Convert seconds to colon-delimited durations BEGIN { OFS = ":" + ex = 0 + stderr = "" } # Refuse to deal with anything that's not a positive (unsigned) integer /[^0-9]/ { - print "hms: Bad number" | "cat >&2" - err = 1 + if (!stderr) + stderr = "cat >&2" + print "hms: Bad number" | stderr + ex = 1 next } # Integer looks valid { # Break it down into hours, minutes, and seconds - s = $0 + s = int($0 + 0) h = int(s / 3600) s %= 3600 m = int(s / 60) @@ -29,4 +33,8 @@ BEGIN { } # Done, exit 1 if we had any errors on the way -END { exit(err > 0) } +END { + if (stderr) + close(stderr) + exit(ex) +} diff --git a/bin/max.awk b/bin/max.awk index 11d4efd9..f6b84ead 100644 --- a/bin/max.awk +++ b/bin/max.awk @@ -1,8 +1,6 @@ # Get the maximum of a list of numbers -{ - if (NR == 1 || $1 > max) - max = $1 -} +BEGIN { max = 0 } +NR == 1 || $1 > max { max = $1 + 0 } END { if (!NR) exit(1) diff --git a/bin/mean.awk b/bin/mean.awk index b34dc111..98060389 100644 --- a/bin/mean.awk +++ b/bin/mean.awk @@ -1,5 +1,6 @@ # Get the mean of a list of numbers -{ tot += $1 } +BEGIN { tot = 0 } +{ tot += $1 + 0 } END { # Error out if we read no values at all if (!NR) diff --git a/bin/med.awk b/bin/med.awk index aee120cb..0f4d6086 100644 --- a/bin/med.awk +++ b/bin/med.awk @@ -1,7 +1,13 @@ # Get the median of a list of numbers +BEGIN { + self = "med" + stderr = "cat >&2" +} { vals[NR] = $1 } NR > 1 && vals[NR] < vals[NR-1] && !warn++ { - printf "med: Input not sorted!\n" | "cat >&2" + if (!stderr) + stderr = "cat >&2" + printf "%s: Input not sorted!\n", self | stderr } END { # Error out if we read no values at all @@ -12,6 +18,8 @@ END { else med = (vals[NR/2] + vals[NR/2+1]) / 2 print med + if (stderr) + close(stderr) if (warn) exit(1) } diff --git a/bin/mftl.awk b/bin/mftl.awk index 21976337..1546526d 100644 --- a/bin/mftl.awk +++ b/bin/mftl.awk @@ -31,6 +31,12 @@ BEGIN { FS = "[ \t:]" } # Print unique determined targets, sorted END { - for (t in ats) - print t | "sort" + sort = "" + for (t in ats) { + if (!sort) + sort = "sort" + print t | sort + } + if (sort) + close(sort) } diff --git a/bin/mi5.awk b/bin/mi5.awk index 48d71657..7acb6f3b 100644 --- a/bin/mi5.awk +++ b/bin/mi5.awk @@ -4,19 +4,14 @@ BEGIN { # You can change any of these, but while changing these is still relatively # sane... - if (!length(open)) - open = "<%" - if (!length(shut)) - shut = "%>" + open = "<%" + shut = "%>" # ... changing these probably isn't, and should compel you to rethink your # code, or quite possibly your entire life thus far. - if (!length(quote)) - quote = "`" - if (!length(unquote)) - unquote = "'" - if (!length(dnl)) - dnl = "dnl" + quote = "`" + unquote = "'" + dnl = "dnl" # We do not start in a block bmac = 0 @@ -24,7 +19,9 @@ BEGIN { # Fatal error function function fatal(str) { - printf "%s: %s\n", self, str | "cat >&2" + stderr = "cat >&2" + printf "%s: %s\n", self, str | stderr + close(stderr) exit(1) } diff --git a/bin/rndi.awk b/bin/rndi.awk index 49df4398..07c69bc7 100644 --- a/bin/rndi.awk +++ b/bin/rndi.awk @@ -1,20 +1,41 @@ # Get a low-quality random number between two integers. Depending on the awk -# implementation, if you don't provide a third argument (a seed), you might get -# very predictable random numbers based on the current epoch second. +# implementation, if you don't have rnds(1df) available to generate a seed of +# sufficient quality, you might get very predictable random numbers based on +# the current epoch second. BEGIN { + self = "rndi" - # Seed with the third argument if given - if (ARGV[3]) - srand(ARGV[3]) + # Check we have two arguments + if (ARGC != 3) + fail("Need a lower and upper bound") - # If not, just seed with what is probably a date/time-derived value + # Floor args and check for sanity + lower = int(ARGV[1] + 0) + upper = int(ARGV[2] + 0) + if (lower >= upper) + fail("Bounds must be numeric, first lower than second") + + # Seed the random number generator + rnds = "rnds 2>/dev/null" + rnds | getline seed + close(rnds) + if (length(seed)) + srand(seed + 0) else srand() # Print a random integer bounded by the first and second arguments - print int(ARGV[1] + rand() * (ARGV[2] - ARGV[1] + 1)) + print int(lower + rand() * (upper - lower + 1)) # Bail before processing any lines exit } + +# Bailout function +function fail(str) { + stderr = "cat >&2" + printf "%s: %s\n", self, str | stderr + close(stderr) + exit(2) +} diff --git a/bin/rndl.awk b/bin/rndl.awk index 8feb4f90..925235ee 100644 --- a/bin/rndl.awk +++ b/bin/rndl.awk @@ -7,7 +7,9 @@ BEGIN { self = "rndl" # Seed the random number generator - "rnds 2>/dev/null" | getline seed + rnds = "rnds 2>/dev/null" + rnds | getline seed + close(rnds) if (length(seed)) srand(seed + 0) else @@ -23,7 +25,9 @@ END { # Check that we processed at least one line if (!NR) { - printf "%s: No lines found on input\n", self | "cat >&2" + stderr = "cat >&2" + printf "%s: No lines found on input\n", self | stderr + close(stderr) exit(1) } diff --git a/bin/sec.awk b/bin/sec.awk index 001b017d..645df147 100644 --- a/bin/sec.awk +++ b/bin/sec.awk @@ -1,13 +1,19 @@ # Convert [[[hh:]mm:]ss] timestamps to seconds # Separator is :, strip out leading zeroes -BEGIN { FS = ":0*" } +BEGIN { + FS = ":0*" + stderr = "" + ex = 0 +} # If no fields, too many fields, or illegal characters, warn, skip line, accrue # errors !NF || NF > 3 || /[^0-9:]/ { - print "sec: Bad format" | "cat >&2" - err = 1 + if (!stderr) + stderr = "cat >&2" + print "sec: Bad format" | stderr + ex = 1 next } @@ -21,4 +27,8 @@ NF == 2 { printf "%u\n", $1 * 60 + $2 } NF == 1 { printf "%u\n", $1 } # Done, exit 1 if we had any errors on the way -END { exit(err > 0) } +END { + if (stderr) + close(stderr) + exit(ex) +} diff --git a/bin/tot.awk b/bin/tot.awk index eda25724..add5f00e 100644 --- a/bin/tot.awk +++ b/bin/tot.awk @@ -1,3 +1,4 @@ # Total a list of numbers +BEGIN { tot = 0 } { tot += $1 } END { print tot } diff --git a/bin/trs.awk b/bin/trs.awk index 58fdf8a9..fbb7eeba 100644 --- a/bin/trs.awk +++ b/bin/trs.awk @@ -18,8 +18,10 @@ BEGIN { } # Bailout function -function fail(str) { - printf "%s: %s\n", self, str | "cat >&2" +function fail(msg) { + stderr = "cat >&2" + printf "%s: %s\n", self, msg | stderr + close(stderr) exit(2) } diff --git a/bin/unf.awk b/bin/unf.awk index ac6172f7..7acb09c2 100644 --- a/bin/unf.awk +++ b/bin/unf.awk @@ -1,5 +1,7 @@ # Unfold header lines in an internet message, don't touch the body +BEGIN { buf = "" } + # Function to write and empty the buffer function wrbuf() { if (length(buf)) diff --git a/bin/xrq.awk b/bin/xrq.awk index 686cf677..62253bdb 100644 --- a/bin/xrq.awk +++ b/bin/xrq.awk @@ -8,12 +8,16 @@ BEGIN { # Check we have at least one resource name if (ARGC < 2) { - print "xrq: Need at least one resource name" | "cat >&2" + stderr = "cat >&2" + print "xrq: Need at least one resource name" | stderr + close(stderr) exit(2) } # Run `xrdb -query` and search for instances of the requested resource - while ("xrdb -query" | getline) { + xrdb = "xrdb -query" + found = 0 + while (xrdb | getline) { for (i in ARGV) { if ($1 == ARGV[i]) { found = 1 @@ -21,6 +25,7 @@ BEGIN { } } } + close(xrdb) # Exit successfully if we found at least one result exit(!found) diff --git a/foo b/foo deleted file mode 100644 index e69de29b..00000000 diff --git a/games/pks.awk b/games/pks.awk index 4c28625c..b71d2dc4 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -13,7 +13,9 @@ BEGIN { } # Seed the random number generator - "rnds 2>/dev/null" | getline seed + rnds = "rnds 2>/dev/null" + rnds | getline seed + close(rnds) if (length(seed)) srand(seed + 0) else diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df index 6466f35d..53d98bf1 100644 --- a/man/man1/mi5.1df +++ b/man/man1/mi5.1df @@ -7,7 +7,7 @@ FILE > out.m4 .br .B mi5 --v open='{{{' -v shut='}}}' FILE > out.m4 +open='{{{' shut='}}}' FILE > out.m4 .br .B mi5 FILE1 FILE2 > out.m4 -- cgit v1.2.3 From fcb11d71d7d4dd7abf5af3e58106154ab2dd2212 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 23:09:08 +1200 Subject: Correct some rndi(1df) references --- bin/maybe.sh | 3 +-- bin/mktd.sh | 2 +- bin/rnda.sh | 7 ++----- man/man1/rndi.1df | 13 ++++++------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/bin/maybe.sh b/bin/maybe.sh index 6e5c8658..bda7bbc0 100644 --- a/bin/maybe.sh +++ b/bin/maybe.sh @@ -19,5 +19,4 @@ if [ "$((num >= 0 || den >= 1))" -ne 1 ] ; then fi # Perform the test; that's our exit value -seed=$(rnds) -test "$(rndi 1 "$den" "$seed")" -le "$num" +test "$(rndi 1 "$den")" -le "$num" diff --git a/bin/mktd.sh b/bin/mktd.sh index 62b10396..f2a0275e 100644 --- a/bin/mktd.sh +++ b/bin/mktd.sh @@ -5,7 +5,7 @@ seed=$(rnds) # Build the intended directory name, with the last element a random integer # from 1..2^31 -dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648 "$seed") +dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648) # Create the directory and print its name if successful mkdir -m 700 -- "$dn" && printf '%s\n' "$dn" diff --git a/bin/rnda.sh b/bin/rnda.sh index b09a8b6f..6a755305 100644 --- a/bin/rnda.sh +++ b/bin/rnda.sh @@ -6,11 +6,8 @@ if [ "$#" -eq 0 ] ; then exit 2 fi -# Get a random seed from rnds(1df); if it's empty, that's still workable -seed=$(rnds) - -# Get a random integet from 1 to the number of arguments -argi=$(rndi 1 "$#" "$seed") || exit +# Get a random integer from 1 to the number of arguments +argi=$(rndi 1 "$#") || exit # Shift until that argument is the first argument shift "$((argi-1))" diff --git a/man/man1/rndi.1df b/man/man1/rndi.1df index 767ad148..72ad0218 100644 --- a/man/man1/rndi.1df +++ b/man/man1/rndi.1df @@ -7,18 +7,17 @@ 0 10 .br .B rndi -0 10 "$(rnds)" +0 10 .SH DESCRIPTION .B rndi returns a random integer ranging from the first argument to the second argument -in a POSIX-compliant way (using awk), using the optional third argument as a +in a POSIX-compliant way (using awk), using rnds(1df) if available for a seed. seed. .P -The answer returned is low-quality; given some implementations of awk and no -properly random seed, it may even return the same result if run within the same -second. This should not be used in any sort of security or statistical context. -The author wrote it to support scripts to choose a random background image from -a directory. +The answer returned is low-quality; on some platforms, it may even return the +same result if run within the same second. This should not be used in any sort +of security or statistical context. The author wrote it to support scripts to +choose a random background image from a directory. .SH SEE ALSO rnda(1df), rndf(1df), rndl(1df), rnds(1df), rndn(6df) .SH AUTHOR -- cgit v1.2.3 From 7187e3bd871d6bb5491b9c20ba30de7e6702ce42 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Jul 2017 23:10:00 +1200 Subject: More corrections to rndi(1df) man page --- man/man1/rndi.1df | 4 ---- 1 file changed, 4 deletions(-) diff --git a/man/man1/rndi.1df b/man/man1/rndi.1df index 72ad0218..e9588ab7 100644 --- a/man/man1/rndi.1df +++ b/man/man1/rndi.1df @@ -5,14 +5,10 @@ .SH SYNOPSIS .B rndi 0 10 -.br -.B rndi -0 10 .SH DESCRIPTION .B rndi returns a random integer ranging from the first argument to the second argument in a POSIX-compliant way (using awk), using rnds(1df) if available for a seed. -seed. .P The answer returned is low-quality; on some platforms, it may even return the same result if run within the same second. This should not be used in any sort -- cgit v1.2.3 From 64427872e9a259dab9e2b27dd6e3e1f430c06274 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jul 2017 12:35:14 +1200 Subject: Work around mawk's srand() behaviour Specific values for these tasks get chosen way more often than other in mawk, and it seems to be caused by the random seed being above a certain value. Not sure if it's a bug or how it interacts with the POSIX standard, but this seems to fix it. --- bin/rndi.awk | 5 ++++- bin/rndl.awk | 5 ++++- games/pks.awk | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/rndi.awk b/bin/rndi.awk index 07c69bc7..7d5a5b96 100644 --- a/bin/rndi.awk +++ b/bin/rndi.awk @@ -16,10 +16,13 @@ BEGIN { if (lower >= upper) fail("Bounds must be numeric, first lower than second") - # Seed the random number generator + # Get a random seed if rnds(1df) available rnds = "rnds 2>/dev/null" rnds | getline seed close(rnds) + + # Truncate the seed to 8 characters because mawk might choke on it + seed = substr(seed,1,8) if (length(seed)) srand(seed + 0) else diff --git a/bin/rndl.awk b/bin/rndl.awk index 925235ee..99f5b4e1 100644 --- a/bin/rndl.awk +++ b/bin/rndl.awk @@ -6,10 +6,13 @@ BEGIN { # Name self self = "rndl" - # Seed the random number generator + # Get a random seed if rnds(1df) available rnds = "rnds 2>/dev/null" rnds | getline seed close(rnds) + + # Truncate the seed to 8 characters because mawk might choke on it + seed = substr(seed,1,8) if (length(seed)) srand(seed + 0) else diff --git a/games/pks.awk b/games/pks.awk index b71d2dc4..1a441980 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -12,10 +12,13 @@ BEGIN { ARGV[1] = "/usr/share/dict/words" } - # Seed the random number generator + # Get a random seed if rnds(1df) available rnds = "rnds 2>/dev/null" rnds | getline seed close(rnds) + + # Truncate the seed to 8 characters because mawk might choke on it + seed = substr(seed,1,8) if (length(seed)) srand(seed + 0) else -- cgit v1.2.3 From 694e3e4f6de5b6759c0bca0a50f653844e92c821 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jul 2017 14:33:44 +1200 Subject: Remove unused var from mktd(1df) --- bin/mktd.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/mktd.sh b/bin/mktd.sh index f2a0275e..89cdc7c3 100644 --- a/bin/mktd.sh +++ b/bin/mktd.sh @@ -1,8 +1,5 @@ # Try to make a random temp directory -# Get a random seed from rnds(1df); if it's empty, that's still workable -seed=$(rnds) - # Build the intended directory name, with the last element a random integer # from 1..2^31 dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648) -- cgit v1.2.3 From 92be1147fc7eb831ddb8dfb600c02335dbdc2a34 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jul 2017 14:45:23 +1200 Subject: Remove some unneeded braces --- bin/xrq.awk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/xrq.awk b/bin/xrq.awk index 62253bdb..ffd5f124 100644 --- a/bin/xrq.awk +++ b/bin/xrq.awk @@ -17,14 +17,12 @@ BEGIN { # Run `xrdb -query` and search for instances of the requested resource xrdb = "xrdb -query" found = 0 - while (xrdb | getline) { - for (i in ARGV) { + while (xrdb | getline) + for (i in ARGV) if ($1 == ARGV[i]) { found = 1 print $2 } - } - } close(xrdb) # Exit successfully if we found at least one result -- cgit v1.2.3 From 15167871f9fa429ca68bd1c058d86f49ba1ccb4a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jul 2017 22:50:44 +1200 Subject: Add dot and slash to legal mftl(1df) target chars --- bin/mftl.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mftl.awk b/bin/mftl.awk index 1546526d..916348b2 100644 --- a/bin/mftl.awk +++ b/bin/mftl.awk @@ -19,7 +19,7 @@ BEGIN { FS = "[ \t:]" } } # Check lines matching expected "targets:dependencies" format -/^[a-zA-Z0-9][a-zA-Z0-9 \t_-]+:([^=]|$)/ { +/^[a-zA-Z0-9][a-zA-Z0-9./ \t_-]+:([^=]|$)/ { # Iterate through the targets that don't look like substitutions or # inference rules and stack them up into an array's keys to keep them -- cgit v1.2.3 From fd2b6fd3bbe4919a1d4560e788fc66db742c0c6d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Jul 2017 12:38:39 +1200 Subject: Escape backslashes in command prompt output To stop them getting interpreted as \h, \w etc. None of these *should* be able to emit backslashes (it's an illegal branch name), but best to be thorough. --- bash/bashrc.d/prompt.bash | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 782af287..a6506a60 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -167,7 +167,10 @@ prompt() { # Print the status in brackets; add a git: prefix only if there # might be another VCS prompt (because PROMPT_VCS is set) printf '(%s%s%s%s)' \ - "${PROMPT_VCS:+git:}" "$name" "${proc:+:"$proc"}" "$state" + "${PROMPT_VCS:+git:}" \ + "${name//\\/\\\\}" \ + "${proc:+:"${proc//\\/\\\\}"}" \ + "${state//\\/\\\\}" ;; # Subversion prompt function @@ -193,6 +196,7 @@ prompt() { branch=${branch#/} branch=${branch#branches/} branch=${branch%%/*} + [[ -n $branch ]] || branch=unknown # Parse the output of svn status to determine working copy state local symbol @@ -210,7 +214,9 @@ prompt() { ((untracked)) && state=${state}'?' # Print the state in brackets with an svn: prefix - printf '(svn:%s%s)' "${branch:-unknown}" "$state" + printf '(svn:%s%s)' \ + "${branch//\\/\\\\}" \ + "${state//\\/\\\\}" ;; # VCS wrapper prompt function; print the first relevant prompt, if any @@ -224,7 +230,7 @@ prompt() { # Show return status of previous command in angle brackets, if not zero ret) # shellcheck disable=SC2154 - ((ret)) && printf '<%u>' "$ret" + ((ret)) && printf '<%u>' "${ret//\\/\\\\}" ;; # Show the count of background jobs in curly brackets, if not zero @@ -233,7 +239,7 @@ prompt() { while read -r ; do ((jobc++)) done < <(jobs -p) - ((jobc)) && printf '{%u}' "$jobc" + ((jobc)) && printf '{%u}' "${jobc//\\/\\\\}" ;; # No argument given, print prompt strings and vars -- cgit v1.2.3 From ba883a5f183edaaa440eb1a41cb6dbd595d55a87 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Jul 2017 12:51:01 +1200 Subject: Escape % signs in prompt command output The Zsh analogue of fd2b6fd. This one matters a bit more, as e.g. "%test" is a legal Git branch name. A generic fix for this for Korn shell will be tough, as some of them seem to use backslash escape sequences and others don't. None of the prompt commands *should* emit backslashes, and it doesn't allow remote execution, so I might just leave that. --- zsh/zshrc.d/prompt.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index 7c695e25..b612c704 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -125,7 +125,10 @@ prompt() { # Print the status in brackets; add a git: prefix only if there # might be another VCS prompt (because PROMPT_VCS is set) printf '(%s%s%s%s)' \ - "${PROMPT_VCS:+git:}" "$name" "${proc:+:"$proc"}" "$state" + "${PROMPT_VCS:+git:}" \ + "${name//\%/%%}" \ + "${proc:+:"${proc//\%/%%}"}" \ + "${state//\%/%%}" ;; # Subversion prompt function @@ -151,6 +154,7 @@ prompt() { branch=${branch#/} branch=${branch#branches/} branch=${branch%%/*} + [[ -n $branch ]] || branch=unknown # Parse the output of svn status to determine working copy state local symbol @@ -168,7 +172,9 @@ prompt() { ((untracked)) && state=${state}'?' # Print the state in brackets with an svn: prefix - printf '(svn:%s%s)' "${branch:-unknown}" "$state" + printf '(svn:%s%s)' \ + "${branch//\%/%%}" \ + "${state//\%/%%}" ;; # VCS wrapper prompt function; print the first relevant prompt, if any @@ -182,7 +188,7 @@ prompt() { # Show return status of previous command in angle brackets, if not zero ret) # shellcheck disable=SC2154 - ((ret)) && printf '<%u>' "$ret" + ((ret)) && printf '<%u>' "${ret//\%/%%}" ;; # Show the count of background jobs in curly brackets, if not zero @@ -191,7 +197,7 @@ prompt() { while read -r ; do ((jobc++)) done < <(jobs -p) - ((jobc)) && printf '{%u}' "$jobc" + ((jobc)) && printf '{%u}' "${jobc//\%/%%}" ;; # No argument given, print prompt strings and vars -- cgit v1.2.3 From e1cfcab9e277527ea34d3d7729b827fe26f3d086 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 8 Jul 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/unimpaired | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/unimpaired b/vim/bundle/unimpaired index e1e0cc38..3a775907 160000 --- a/vim/bundle/unimpaired +++ b/vim/bundle/unimpaired @@ -1 +1 @@ -Subproject commit e1e0cc3859323f354b8d905ca177e172c7d69f0e +Subproject commit 3a7759075cca5b0dc29ce81f2747489b6c8e36a7 -- cgit v1.2.3 From ab6cb2673a51f8582e82828b15fd62f303f54d75 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 11 Jul 2017 23:57:23 +1200 Subject: Gracefully handle two failed tput color calls --- sh/shrc.d/grep.sh | 2 +- sh/shrc.d/ls.sh | 2 +- sh/shrc.d/tree.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 "$@" -- cgit v1.2.3 From 5f6907bdba0ceb017dd9215ee636ff3bb86ab6fe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 25 Jul 2017 16:21:11 +1200 Subject: Use combining chars properly for strik(6df) --- games/strik.sed | 64 +----------------------------------------------------- man/man6/strik.6df | 10 ++++----- 2 files changed, 6 insertions(+), 68 deletions(-) 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/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 + .SH AUTHOR Tom Ryder -- cgit v1.2.3 From cd7a8c2433182ee147380318008a81a839f65596 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 26 Jul 2017 08:59:46 +1200 Subject: Adjust linebreak behaviour around downloads check --- sh/profile.d/downloads.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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' ) -- cgit v1.2.3 From 248aec473f380edac020912b1c913bc0825b9cb1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:27:01 +1200 Subject: Update submodules --- vim/bundle/pathogen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen index ddfb1f14..e7857bed 160000 --- a/vim/bundle/pathogen +++ b/vim/bundle/pathogen @@ -1 +1 @@ -Subproject commit ddfb1f14d7597e6aedc749be06b559a673c437ab +Subproject commit e7857bed4e0705f91f781dbe99706f07d08d104b -- cgit v1.2.3 From 89dca912dfe5705dcc7c622e3cba0de633b3baf2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:32:56 +1200 Subject: Remove two more POSIX character classes Debian's ancient mawk doesn't support them --- bin/mw.awk | 2 +- bin/rfct.awk | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/mw.awk b/bin/mw.awk index 95d70c32..c2565cf3 100644 --- a/bin/mw.awk +++ b/bin/mw.awk @@ -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/rfct.awk b/bin/rfct.awk index 4467f206..90cd8e0d 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -6,8 +6,5 @@ BEGIN { ORS = "\n\n" } -# Strip out control characters, except tab and newline -{ gsub(/[^[:print:]\n\t]/, "") } - # If there's anything left, print it length($0) -- cgit v1.2.3 From 9bd9b909e3946da58d98a381ad09a6ac2015f9a9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:37:28 +1200 Subject: Correct previous commit Forgot to remove the square brackets --- bin/mw.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mw.awk b/bin/mw.awk index c2565cf3..8af28312 100644 --- a/bin/mw.awk +++ b/bin/mw.awk @@ -1,7 +1,7 @@ # Crude approach to get alphabetic words one per line from input, not sorted or # deduplicated BEGIN { - FS = "(--|['_-]*[^[a-zA-Z0-9_]'_-]+['_-]*)" + FS = "(--|['_-]*[^a-zA-Z0-9_'_-]+['_-]*)" } { for (i = 1; i <= NF; i++) -- cgit v1.2.3 From f091052f84b3f418eede1833a3fa81933310a456 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:42:09 +1200 Subject: Restore ^L-skipping code --- bin/rfct.awk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/rfct.awk b/bin/rfct.awk index 90cd8e0d..5ceef43f 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -6,5 +6,9 @@ BEGIN { ORS = "\n\n" } +# Skip paragraphs with ^L chars in them +# We have to be literal here due to mawk's failures +/ / { next } + # If there's anything left, print it length($0) -- cgit v1.2.3 From 94ad9332c0a8213ad384007707d68ac8fd1810cb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:45:17 +1200 Subject: Nicer handling of RFC control chars --- bin/rfct.awk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/rfct.awk b/bin/rfct.awk index 5ceef43f..230ac42c 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -6,9 +6,12 @@ BEGIN { ORS = "\n\n" } -# Skip paragraphs with ^L chars in them -# We have to be literal here due to mawk's failures -/ / { next } +# 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 tha, print it length($0) -- cgit v1.2.3 From 7128d16de2547125ddec97d9ffe989216674601d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:49:21 +1200 Subject: Compatible stripping for onl(1df) --- bin/onl.awk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3 From be35ea619d3d257469110c4274fe37380a1abfa0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 8 Aug 2017 10:54:30 +1200 Subject: Correct typo comment --- bin/rfct.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/rfct.awk b/bin/rfct.awk index 230ac42c..3d942b58 100644 --- a/bin/rfct.awk +++ b/bin/rfct.awk @@ -13,5 +13,5 @@ BEGIN { # Strip out other control characters, but allow newline and tab { gsub(/[\a\b\r\v]/, "") } -# If there's anything left after tha, print it +# If there's anything left after that, print it length($0) -- cgit v1.2.3 From 16f81a60f9b83555d3bf9db7dfac56e0fdcde766 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 21 Aug 2017 09:58:50 +1200 Subject: Add missing slash to comment --- bin/plmu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From f609986735b0a381d6ad95ad30a62f1fdf8169a8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 21 Aug 2017 21:47:54 +1200 Subject: Add arg checks to chc(1df) --- bin/chc.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/chc.sh b/bin/chc.sh index 8b15317c..ee030f5f 100644 --- a/bin/chc.sh +++ b/bin/chc.sh @@ -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 -- cgit v1.2.3 From f76716b6ed18dcb2c7d22ee88e68d4da52979815 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 24 Aug 2017 01:00:03 +1200 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 9aa4a1c7..1d045ca0 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 9aa4a1c79c61c581ace5caa5b09b0e283d5c72ae +Subproject commit 1d045ca0b6d3e9863f6361e151762435df3009c6 -- cgit v1.2.3 From 91fe0b5754d526c1a79316fc9e6f427598e108ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 30 Aug 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/lion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/lion b/vim/bundle/lion index 08d5e714..80de27aa 160000 --- a/vim/bundle/lion +++ b/vim/bundle/lion @@ -1 +1 @@ -Subproject commit 08d5e714e87305c4b42f17db373af8244293e423 +Subproject commit 80de27aa2849b42d8f9cec6ac362858651677d95 -- cgit v1.2.3 From 6924f1bd69c45667829931eb683c3ab2219606c5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 4 Sep 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index 050335f8..7681a534 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit 050335f848d57cb1c59bffe6f32f901307b7e504 +Subproject commit 7681a534903e1d6efa00571680650849f27eef47 -- cgit v1.2.3 From 5e6cedf739a5140893937bc76681bfebe517a4b6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Sep 2017 01:00:04 +1200 Subject: Update submodules --- vim/bundle/html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/html5 b/vim/bundle/html5 index 1d045ca0..916085df 160000 --- a/vim/bundle/html5 +++ b/vim/bundle/html5 @@ -1 +1 @@ -Subproject commit 1d045ca0b6d3e9863f6361e151762435df3009c6 +Subproject commit 916085df16ad6bd10ecbd37bc5d44b62f062572b -- cgit v1.2.3 From f08633a999df36e571bd659b1a2825851cf296b8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 22 Sep 2017 14:57:59 +1200 Subject: Add an idea --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index f267be12..23ae6470 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -1,6 +1,8 @@ Ideas ===== +* 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 -- cgit v1.2.3 From e8f0d1466832b26fb895702b4ceca71efc7e26e7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 22 Sep 2017 15:01:25 +1200 Subject: Add another idea --- IDEAS.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS.markdown b/IDEAS.markdown index 23ae6470..544530e3 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -1,6 +1,8 @@ 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 -- cgit v1.2.3 From 44d27b5f1c0ff8b6e83f7ba6e8ae787df2aae498 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:50:06 +1300 Subject: Add a comment about how hardcore I am --- perlcritic/perlcriticrc | 1 + 1 file changed, 1 insertion(+) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index ed1d9064..c6e83501 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -1,3 +1,4 @@ +# No mercy! severity = brutal exclude = Bangs::ProhibitBitwiseOperators -- cgit v1.2.3 From 41523c0cbbde693cb693ab6a45dbf530f40d4f31 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:52:17 +1300 Subject: Clarify excluded Perl::Critic policy --- perlcritic/perlcriticrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index c6e83501..4e8edf9b 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -1,6 +1,10 @@ # 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] [Bangs::ProhibitNumberedNames] exceptions = inet4 inet6 ipv4 ipv6 md5 sha1 sha256 sha512 x11 utf8 -- cgit v1.2.3 From 223630ab9990ff7e20b893327e520dbe83c3cb9d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:52:42 +1300 Subject: Update addenda to allowed num-suffixed idents --- perlcritic/perlcriticrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index 4e8edf9b..25343d50 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -6,5 +6,6 @@ severity = brutal # 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 -- cgit v1.2.3 From e85104ab65c02e76e4988e39384013a00d317067 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:53:01 +1300 Subject: Allow a few more numeric literals in Perl --- perlcritic/perlcriticrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index 25343d50..c3fda080 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -9,3 +9,8 @@ severity = brutal # Add some networking terms to the list of legal numbered names [Bangs::ProhibitNumberedNames] add_exceptions = inet4 inet6 ipv4 ipv6 + +# Soften this policy a bit; tolerate all the single-digit integers as literals, +# and also 100 (for calculating percentages) +[ValuesAndExpressions::ProhibitMagicNumbers] +allowed_values = 0..9 100 -- cgit v1.2.3 From 8f3b2a088aaea9661677fd50bcb65a758e45eb34 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:53:13 +1300 Subject: Deprecate some ancient Perl variables --- perlcritic/perlcriticrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index c3fda080..3bc92cdd 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -14,3 +14,7 @@ add_exceptions = inet4 inet6 ipv4 ipv6 # and also 100 (for calculating percentages) [ValuesAndExpressions::ProhibitMagicNumbers] allowed_values = 0..9 100 + +# These are all explicitly listed as deprecated in perlvar +[Variables::ProhibitEvilVariables] +variables = $# $* $[ -- cgit v1.2.3 From d919a05733d27b0f7d4f5ec7f319429305cb8ba5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 27 Sep 2017 15:56:17 +1300 Subject: Remove overkill punc vars policy Variables::ProhibitPunctuationVars handles this case already, and they have no English equivalents anyway. --- perlcritic/perlcriticrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index 3bc92cdd..c3fda080 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -14,7 +14,3 @@ add_exceptions = inet4 inet6 ipv4 ipv6 # and also 100 (for calculating percentages) [ValuesAndExpressions::ProhibitMagicNumbers] allowed_values = 0..9 100 - -# These are all explicitly listed as deprecated in perlvar -[Variables::ProhibitEvilVariables] -variables = $# $* $[ -- cgit v1.2.3 From 4740a68693dac9045e599a724be88818b6da43bb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 2 Oct 2017 11:39:23 +1300 Subject: Correct a typo in a key name --- keychain/profile.d/keychain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)" -- cgit v1.2.3 From a6304e7187349d490792e86c2c4c12464f28c48f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 3 Oct 2017 01:00:04 +1300 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index 7681a534..0f916137 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit 7681a534903e1d6efa00571680650849f27eef47 +Subproject commit 0f91613787202c5e22c2378bcdb9f20ce45f6687 -- cgit v1.2.3 From bc35e35081678ab880e2cef8265aa7f380b05649 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 6 Oct 2017 01:10:18 +1300 Subject: Allow 10 and 1000 as literals --- perlcritic/perlcriticrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index c3fda080..7428792a 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -11,6 +11,6 @@ severity = brutal add_exceptions = inet4 inet6 ipv4 ipv6 # Soften this policy a bit; tolerate all the single-digit integers as literals, -# and also 100 (for calculating percentages) +# and also three powers of 10 (for percentages, milliseconds etc) [ValuesAndExpressions::ProhibitMagicNumbers] -allowed_values = 0..9 100 +allowed_values = 0..9 10 100 1000 -- cgit v1.2.3 From 5ef627e8af33c9ea61553ba31624a05339175e67 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 6 Oct 2017 21:19:57 +1300 Subject: Ignore a Perl::Critic policy --- perlcritic/perlcriticrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index 7428792a..e8d13dcd 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -10,6 +10,10 @@ severity = brutal [Bangs::ProhibitNumberedNames] 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 on Perl 5.6 +[-Compatibility::PodMinimumVersion] + # 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] -- cgit v1.2.3 From c5cfb57bdaf0b6be0d13699810a691843ff570ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Oct 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index 0f916137..4afd32ba 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit 0f91613787202c5e22c2378bcdb9f20ce45f6687 +Subproject commit 4afd32ba368b1d46f29915416f88332567a2db22 -- cgit v1.2.3 From d83d75e9b0fb90e434199e82de1afc7c4f92ee7c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 11 Oct 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/commentary | 2 +- vim/bundle/targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/bundle/commentary b/vim/bundle/commentary index be79030b..89f43af1 160000 --- a/vim/bundle/commentary +++ b/vim/bundle/commentary @@ -1 +1 @@ -Subproject commit be79030b3e8c0ee3c5f45b4333919e4830531e80 +Subproject commit 89f43af18692d22ed999c3097e449f12fdd8b299 diff --git a/vim/bundle/targets b/vim/bundle/targets index 4afd32ba..3c25a84a 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit 4afd32ba368b1d46f29915416f88332567a2db22 +Subproject commit 3c25a84ae38445c4b6fb6f1f18a4c694f8c9d1de -- cgit v1.2.3 From 5084615b1925afae5575c5b21f20ee92bbaed5aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Oct 2017 01:00:03 +1300 Subject: Update submodules --- vim/bundle/targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/targets b/vim/bundle/targets index 3c25a84a..dec6409f 160000 --- a/vim/bundle/targets +++ b/vim/bundle/targets @@ -1 +1 @@ -Subproject commit 3c25a84ae38445c4b6fb6f1f18a4c694f8c9d1de +Subproject commit dec6409fb80ec1554bad582652f7511aa28c4ed2 -- cgit v1.2.3 From e6493290cba7e1ede2ccb93aae14fd3e321891a6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Oct 2017 09:05:16 +1300 Subject: Correct comment typos --- games/kvlt.sed | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3 From c4a1f8a7ea386e89cf4fee286b3c1aac61e4f16c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Oct 2017 12:02:00 +1300 Subject: Document why fnl(1df) command is wrapped Because I forgot --- bin/fnl.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/fnl.sh b/bin/fnl.sh index 86e582f1..e8a5f071 100644 --- a/bin/fnl.sh +++ b/bin/fnl.sh @@ -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=$? -- cgit v1.2.3 From 5ba343e6ea76183f8f46c8ce28d36a66539a7b1d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 15 Oct 2017 00:47:35 +1300 Subject: Exclude another Perl::Critic policy --- perlcritic/perlcriticrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc index e8d13dcd..bc8453f8 100644 --- a/perlcritic/perlcriticrc +++ b/perlcritic/perlcriticrc @@ -14,6 +14,9 @@ add_exceptions = inet4 inet6 ipv4 ipv6 # documentation, so allow e.g. L 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] -- cgit v1.2.3 From 2550842ce1e0ce8163fbf1956482292c01a6bbe4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Oct 2017 09:07:45 +1300 Subject: Make rndi(1df) upper bound a little clearer --- bin/mktd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/mktd.sh b/bin/mktd.sh index 89cdc7c3..61c1b5ab 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 "$e") # Create the directory and print its name if successful mkdir -m 700 -- "$dn" && printf '%s\n' "$dn" -- cgit v1.2.3 From 42fad6eadb9603d5e8e7ec01a1c6fa0ffc633c8d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Oct 2017 09:08:58 +1300 Subject: Remove unneeded shebangs from games shb(1df) installs these --- games/aaf.sh | 1 - games/chkl.sed | 1 - games/dr.sh | 1 - games/rndn.sh | 1 - games/xyzzy.sh | 1 - 5 files changed, 5 deletions(-) diff --git a/games/aaf.sh b/games/aaf.sh index 4f1825c6..09c2bc36 100644 --- a/games/aaf.sh +++ b/games/aaf.sh @@ -1,3 +1,2 @@ -#!/bin/sh 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..dbb8292f 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 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/xyzzy.sh b/games/xyzzy.sh index d262c0e6..8101b190 100644 --- a/games/xyzzy.sh +++ b/games/xyzzy.sh @@ -1,4 +1,3 @@ -#!/bin/sh if [ -e "$HOME"/.xyzzy ] ; then printf >&2 '%s\n' 'Nothing happens.' exit 1 -- cgit v1.2.3 From 95a8e7619bf4e31933c815604b86b3a0682050cf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Oct 2017 09:09:35 +1300 Subject: Add some leading comments to games --- games/aaf.sh | 1 + games/philsay.sh | 1 + games/xyzzy.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/games/aaf.sh b/games/aaf.sh index 09c2bc36..24094a73 100644 --- a/games/aaf.sh +++ b/games/aaf.sh @@ -1,2 +1,3 @@ +# Print a random ASCII Art Fart curl http://www.asciiartfarts.com/random.cgi | pup -p 'table[cellpadding]' pre text{} 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/xyzzy.sh b/games/xyzzy.sh index 8101b190..5cc03278 100644 --- a/games/xyzzy.sh +++ b/games/xyzzy.sh @@ -1,3 +1,4 @@ +# ADVENTURE if [ -e "$HOME"/.xyzzy ] ; then printf >&2 '%s\n' 'Nothing happens.' exit 1 -- cgit v1.2.3 From 850eaa9b274cec7d6c84eba5b34b55fdcd40e64e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Oct 2017 09:09:59 +1300 Subject: Adjust dr(6df) to use 2-arg rndi(1df) --- games/dr.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/games/dr.sh b/games/dr.sh index dbb8292f..df21d7a5 100644 --- a/games/dr.sh +++ b/games/dr.sh @@ -22,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 -- cgit v1.2.3 From 0a5471dfd507bc446420716ad8287b59700bcb6c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Oct 2017 09:22:58 +1300 Subject: Correct misnamed variable --- bin/mktd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mktd.sh b/bin/mktd.sh index 61c1b5ab..72375873 100644 --- a/bin/mktd.sh +++ b/bin/mktd.sh @@ -3,7 +3,7 @@ # Build the intended directory name, with the last element a random integer # from 1..2^31 lim=$((2 << 31)) -dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 "$e") +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" -- cgit v1.2.3 From 2b13fc067386408620442f1bf53e1a057608585d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 14:29:20 +1300 Subject: Add TABS.markdown to show how to switch to tabs This enables me to remove my expensive and rather silly "tabs" feature branch. --- TABS.markdown | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 TABS.markdown diff --git a/TABS.markdown b/TABS.markdown new file mode 100644 index 00000000..feeee631 --- /dev/null +++ b/TABS.markdown @@ -0,0 +1,26 @@ +Spaces to tabs +============== + +If you prefer tabs to spaces, the following recipe seems to convert everything +pretty nicely: + + $ find . -name .git -prune -o -name vim -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t4 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + + $ find vim -name bundle -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t2 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + +If you have GNU unexpand(1) and can add `--first-only` to each of those calls, +the results seem perfect. + +You can configure Vim to accommodate this by removing the settings for: + +* `expandtab` +* `shiftround` +* `shiftwidth` +* `smarttab` +* `softtabstop` -- cgit v1.2.3 From f19ec7b2948c9caa0af7d6302e869dcbfccbe86e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 14:44:43 +1300 Subject: Correct explanation of ksw(1df) idea --- IDEAS.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDEAS.markdown b/IDEAS.markdown index 544530e3..bba9e314 100644 --- a/IDEAS.markdown +++ b/IDEAS.markdown @@ -1,8 +1,8 @@ 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 ksw(1df) (kill-switch) that traps SIGINT 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 -- cgit v1.2.3 From a2f391804fda279b8a9d2bf5b1ed55ab49543435 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 14:46:59 +1300 Subject: Rename .markdown files to .md --- IDEAS.markdown | 21 -- IDEAS.md | 21 ++ ISSUES.markdown | 24 -- ISSUES.md | 24 ++ README.markdown | 603 -------------------------------------------------- README.md | 603 ++++++++++++++++++++++++++++++++++++++++++++++++++ TABS.markdown | 26 --- TABS.md | 26 +++ man/man1/murl.1df | 2 +- man/man7/dotfiles.7df | 2 +- 10 files changed, 676 insertions(+), 676 deletions(-) delete mode 100644 IDEAS.markdown create mode 100644 IDEAS.md delete mode 100644 ISSUES.markdown create mode 100644 ISSUES.md delete mode 100644 README.markdown create mode 100644 README.md delete mode 100644 TABS.markdown create mode 100644 TABS.md diff --git a/IDEAS.markdown b/IDEAS.markdown deleted file mode 100644 index bba9e314..00000000 --- a/IDEAS.markdown +++ /dev/null @@ -1,21 +0,0 @@ -Ideas -===== - -* A wrapper ksw(1df) (kill-switch) that traps SIGINT 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 - manageable -* Have eds(1df) accept stdin with the "starting content" for the script -* Convert all the manual pages to mandoc maybe? -* qmp(1df)--quick man page -* The solution to chn(1df) not running in parallel is probably backgrounded - processes and mkfifo(1). -* Write something like hcat(1df) or tcat(1df) that includes filename headings - for each concatenated file. -* I can probably get rid of all that nasty templated shell by writing - something that wraps around td(1df) and generates shell script to run, and - calls that via `eval`. diff --git a/IDEAS.md b/IDEAS.md new file mode 100644 index 00000000..bba9e314 --- /dev/null +++ b/IDEAS.md @@ -0,0 +1,21 @@ +Ideas +===== + +* A wrapper ksw(1df) (kill-switch) that traps SIGINT 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 + manageable +* Have eds(1df) accept stdin with the "starting content" for the script +* Convert all the manual pages to mandoc maybe? +* qmp(1df)--quick man page +* The solution to chn(1df) not running in parallel is probably backgrounded + processes and mkfifo(1). +* Write something like hcat(1df) or tcat(1df) that includes filename headings + for each concatenated file. +* I can probably get rid of all that nasty templated shell by writing + something that wraps around td(1df) and generates shell script to run, and + calls that via `eval`. diff --git a/ISSUES.markdown b/ISSUES.markdown deleted file mode 100644 index 48007919..00000000 --- a/ISSUES.markdown +++ /dev/null @@ -1,24 +0,0 @@ -Known issues -============ - -* man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on - that system; need to find some way of finding which manual directories - should be searched at runtime, if there is one. -* The checks gscr(1df) makes to determine where it is are a bit naïve (don't - work with bare repos) and could probably be improved with some appropriate - git-reflog(1) calls -* dr(6df) is probably more practical in awk -* Running the block of git(1) commands in the prompt leaves five "stale" - jobspecs around that flee after a jobs builtin run; only saw this manifest - after 90dcadf; either I understand job specs really poorly or this may be a - bug in bash -* I can't find a clean way of detecting a restricted shell for ksh instances - to prevent trying to load anything fancy (works for Bash) - * Zsh, either! $options[restricted] is "off" within the startup file -* Would be good to complete the Makefile variables for NAME, EMAIL etc with - educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding - my own stuff in there -* Completion for custom functions e.g. `sd` should ideally respect - `completion-ignore-case` setting -* Document `install-conf` target once I'm sure it's not a dumb idea -* Need to decide whether I care about XDG, and implement it if I do diff --git a/ISSUES.md b/ISSUES.md new file mode 100644 index 00000000..48007919 --- /dev/null +++ b/ISSUES.md @@ -0,0 +1,24 @@ +Known issues +============ + +* man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on + that system; need to find some way of finding which manual directories + should be searched at runtime, if there is one. +* The checks gscr(1df) makes to determine where it is are a bit naïve (don't + work with bare repos) and could probably be improved with some appropriate + git-reflog(1) calls +* dr(6df) is probably more practical in awk +* Running the block of git(1) commands in the prompt leaves five "stale" + jobspecs around that flee after a jobs builtin run; only saw this manifest + after 90dcadf; either I understand job specs really poorly or this may be a + bug in bash +* I can't find a clean way of detecting a restricted shell for ksh instances + to prevent trying to load anything fancy (works for Bash) + * Zsh, either! $options[restricted] is "off" within the startup file +* Would be good to complete the Makefile variables for NAME, EMAIL etc with + educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding + my own stuff in there +* Completion for custom functions e.g. `sd` should ideally respect + `completion-ignore-case` setting +* Document `install-conf` target once I'm sure it's not a dumb idea +* Need to decide whether I care about XDG, and implement it if I do diff --git a/README.markdown b/README.markdown deleted file mode 100644 index adc4c73a..00000000 --- a/README.markdown +++ /dev/null @@ -1,603 +0,0 @@ -Dotfiles (Tom Ryder) -==================== - -This is my personal repository of configuration files and scripts for `$HOME`, -including most of the settings that migrate well between machines. - -This repository began as a simple way to share Vim and tmux configuration, but -over time a lot of scripts and shell configuration have been added, making it -into a personal suite of custom Unix tools. - -Installation ------------- - - $ git clone https://sanctum.geek.nz/code/dotfiles.git ~/.dotfiles - $ cd ~/.dotfiles - $ git submodule init - $ git submodule update - $ make - $ make -n install - $ make install - -For the default `all` target, you'll need a POSIX-fearing userland, including -`make(1)` and `m4(1)`. - -The installation `Makefile` will overwrite things standing in the way of its -installed files without backing them up, so read the output of `make -n -install` before running `make install` to make sure you aren't going to lose -anything unexpected. If you're still not sure, install it in a temporary -directory so you can explore: - - $ tmpdir=$(mktemp -d) - $ make install HOME="$tmpdir" - $ env -i HOME="$tmpdir" TERM="$TERM" "$SHELL" -l - -The default `install` target will install these targets and all their -dependencies. Note that you don't actually have to have any of this except `sh` -installed. - -* `install-bin` -* `install-bin-man` -* `install-curl` -* `install-ex` -* `install-git` -* `install-gnupg` -* `install-less` -* `install-login-shell` -* `install-readline` -* `install-vim` - -The `install-login-shell` looks at your `SHELL` environment variable and tries -to figure out which shell’s configuration files to install, falling back on -`install-sh`. - -The remaining dotfiles can be installed with the other `install-*` targets. Try -`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list. - -Tools ------ - -Configuration is included for: - -* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and - some helper functions: - * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) - * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) - * [Z shell](https://www.zsh.org/) -* [Abook](http://abook.sourceforge.net/) -- curses address book program -* [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data - with URL syntax -* [Dunst](http://knopwob.org/dunst/) -- A lightweight X11 notification daemon - that works with `libnotify` -* `finger(1)` -- User information lookup program -* [Git](https://git-scm.com/) -- Distributed version control system -* [GnuPG](https://www.gnupg.org/) -- GNU Privacy Guard, for private - communication and file encryption -* [GTK+](https://www.gtk.org/) -- GIMP Toolkit, for graphical user interface - elements -* [i3](https://i3wm.org/) -- Tiling window manager -* [less](https://www.gnu.org/software/less/) -- Terminal pager -* [Mutt](http://www.mutt.org/) -- Terminal mail user agent -* [`mysql(1)`](https://linux.die.net/man/1/mysql) -- Command-line MySQL client -* [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client -* [Newsbeuter](https://www.newsbeuter.org/) -- Terminal RSS/Atom feed reader -* [`psql(1)`](https://linux.die.net/man/1/psql) -- Command-line PostgreSQL - client -* [Perl::Critic](http://perlcritic.com/) -- static source code analysis - engine for Perl -* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl indenter and - reformatter -* [Readline](https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) -- GNU - library for user input used by Bash, MySQL, and others -* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) -- Fork of - the rxvt terminal emulator with Unicode support -* [Subversion](https://subversion.apache.org/) -- Apache Subversion, a - version control system -* [tmux](https://tmux.github.io/) -- Terminal multiplexer similar to GNU - Screen -* [Vim](http://www.vim.org/) -- Vi IMproved, a text editor -* [X11](https://www.x.org/wiki/) -- Windowing system with network - transparency for Unix - -The configurations for shells, GnuPG, Mutt, tmux, and Vim are the most -expansive, and most likely to be of interest. The i3 configuration is mostly -changed to make window switching behave like Vim windows and tmux panes do, and -there's a fair few resources defined for rxvt-unicode. - -### Shell - -My `.profile` and other files in `sh` are written in POSIX shell script, so -they should work in most `sh(1)` implementations. Individual scripts called by -`.profile` are saved in `.profile.d` and iterated on login for ease of -management. Most of these boil down to exporting variables appropriate to the -system and the software it has available. - -Configuration that should be sourced for all POSIX-fearing interactive shells -is kept in `~/.shrc`, with subscripts read from `~/.shrc.d`. There's a shim in -`~/.shinit` to act as `ENV`. I make an effort to target POSIX for my functions -and scripts where I can so that the same files can be loaded for all shells. - -On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, preferably -`ksh93` if it's available. - -As I occasionally have work on very old internal systems, my Bash is written to -work with [any version 2.05a or -newer](http://wiki.bash-hackers.org/scripting/bashchanges). This is why I use -older syntax for certain things such as appending items to arrays: - - array[${#array[@]}]=$item - -Compare this to the much nicer syntax available since 3.1-alpha1, which -actually works for arrays with sparse indices, unlike the above syntax: - - array+=("$item") - -Where I do use features that are only available in versions of Bash newer than -2.05a, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run -after testing `BASH_VERSINFO` appropriately. - -#### Prompt - -A terminal session with my prompt looks something like this: - - ~$ ssh remote - remote:~$ cd .dotfiles - remote:~/.dotfiles(master+!)$ git status - M README.markdown - M bash/bashrc.d/prompt.bash - A init - remote:~/.dotfiles(master+!)$ foobar - foobar: command not found - remote:~/.dotfiles(master+!)<127>$ sleep 5 & - [1] 28937 - remote:~/.dotfiles(master+!){1}$ - -The hostname is elided if not connected via SSH. The working directory with -tilde abbreviation for `$HOME` is always shown. The rest of the prompt expands -based on context to include these elements in this order: - -* Whether in a Git repository if applicable, and punctuation to show - repository status including reference to upstreams at a glance. Subversion - support can also be enabled (I need it at work), in which case a `git:` or - `svn:` prefix is added appropriately. -* The number of running background jobs, if non-zero. -* The exit status of the last command, if non-zero. - -You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all -do about what you'd expect. - -If you start up Bash, Ksh, or Zsh and it detects that it's not normally your -`$SHELL`, the prompt will display an appropriate prefix. - -This is all managed within the `prompt` function. There's some mildly hacky -logic on `tput` codes included such that it should work correctly for most -common terminals using both `termcap(5)` and `terminfo(5)`, including \*BSD -systems. It's also designed to degrade gracefully for eight-color and no-color -terminals. - -#### Functions - -If a function can be written in POSIX `sh` without too much hackery, I put it -in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: - -* Four functions for using a "marked" directory, which I find a more - manageable concept than the `pushd`/`popd` directory stack: - * `md()` marks a given (or the current) directory. - * `gd()` goes to the marked directory. - * `pmd()` prints the marked directory. - * `xd()` swaps the current and marked directories. -* Ten other directory management and navigation functions: - * `bd()` changes into a named ancestor of the current directory. - * `gt()` changes into a directory or into a file's directory. - * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. - * `mkcd()` creates a directory and changes into it. - * `pd()` changes to the argument's parent directory. - * `rd()` replaces the first instance of its first argument with its - second argument in `$PWD`, emulating a feature of the Zsh `cd` builtin - that I like. - * `scr()` creates a temporary directory and changes into it. - * `sd()` changes into a sibling of the current directory. - * `ud()` changes into an indexed ancestor of a directory. - * `vr()` tries to change to the root directory of a source control - repository. -* `bc()` silences startup messages from GNU `bc(1)`. -* `ed()` tries to get verbose error messages, a prompt, and a Readline - environment for `ed(1)`. -* `gdb()` silences startup messages from `gdb(1)`. -* `gpg()` quietens `gpg(1)` down for most commands. -* `grep()` tries to apply color and other options good for interactive use if - available. -* `hgrep()` allows searching `$HISTFILE`. -* `keychain()` keeps `$GPG_TTY` up to date if a GnuPG agent is available. -* `ls()` tries to apply color and other options good for interactive use if - available. - * `la()` runs `ls -A` if it can, or `ls -a` otherwise. - * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. -* `path()` manages the contents of `PATH` conveniently. -* `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. -* `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never - preserved; I hate having `root`-owned files in my home directory. -* `tree()` colorizes GNU `tree(1)` output if possible (without having - `LS_COLORS` set). -* `x()` is a one-key shortcut for `exec startx`. - -There are a few other little tricks defined for other shells providing -non-POSIX features, as compatibility allows: - -* `keep()` stores ad-hoc shell functions and variables (Bash, Korn Shell 93, - Z shell). -* `prompt()` sets up my interactive prompt (Bash, Korn Shell, Z shell). -* `pushd()` adds a default destination of `$HOME` to the `pushd` builtin - (Bash). -* `vared()` allows interactively editing a variable with Readline, emulating - a Zsh function I like by the same name (Bash). -* `ver()` prints the current shell's version information (Bash, Korn Shell, - Z shell). - -#### Completion - -I find the `bash-completion` package a bit too heavy for my tastes, and turn it -off using a stub file installed in `~/.config/bash_completion`. The majority of -the time I just want to complete paths anyway, and this makes for a quicker -startup without a lot of junk functions in my Bash namespace. - -I do make some exceptions with completions defined in `.bash_completion.d` -files, for things I really do get tired of typing repeatedly: - -* Bash builtins: commands, help topics, shell options, variables, etc. -* `find(1)`'s more portable options -* `ftp(1)` hostnames from `~/.netrc` -* `git(1)` subcommands, remotes, branches, tags, and addable files -* `gpg(1)` long options -* `make(1)` targets read from a `Makefile` -* `man(1)` page titles -* `pass(1)` entries -* `ssh(1)` hostnames from `~/.ssh/config` - -For commands that pretty much always want to operate on text, such as text file -or stream editors, I exclude special file types and extensions I know are -binary. I don't actually read the file, so this is more of a heuristic thing, -and sometimes it will get things wrong. - -I also add completions for my own scripts and functions where useful. The -completions are dynamically loaded if Bash is version 4.0 or greater. -Otherwise, they're all loaded on startup. - -#### Korn shell - -These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T -`ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow -prompt if detected. - -#### Zsh - -These are experimental; I do not like Zsh much at the moment. The files started -as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan. - -### GnuPG - -The configuration for GnuPG is intended to follow [RiseUp's OpenPGP best -practices](https://riseup.net/en/security/message-security/openpgp/best-practices). -The configuration file is rebuilt using `mi5(1df)` and `make(1)` because it -requires hard-coding a path to the SKS keyserver certificate authority, and -neither tilde nor `$HOME` expansion works for this. - -### Mutt - -My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where -most unfiltered mail is sent. I use -[Getmail](http://pyropus.ca/software/getmail/), -[maildrop](https://www.courier-mta.org/maildrop/), and -[MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not -included here. I sign whenever I have some indication that the recipient might -be using a PGP implementation, and I encrypt whenever I have a public key -available for them. The GnuPG and S/MIME interfacing is done with -[GPGme](https://www.gnupg.org/related_software/gpgme/), rather than defining -commands for each crypto operation. I wrote [an article about this -setup](https://sanctum.geek.nz/arabesque/linux-crypto-email/) if it sounds -appealing. - -You'll need [Abook](http://abook.sourceforge.net/) installed if you want to use -the `query_command` I have defined, and [msmtp](http://msmtp.sourceforge.net/) -for the `sendmail` command. - -### rxvt-unicode - -I've butchered the URxvt Perl extensions `selection-to-clipboard` and -`selection` into a single `select` extension in `~/.urxvt/ext`, which is the -only extension I define in `~/.Xresources`. - -The included `.Xresources` file assumes that `urxvt` can use 256 colors and -Perl extensions. If you're missing functionality, try changing -`perl-ext-common` to `default`. - -My choice of font is [Ubuntu Mono](http://font.ubuntu.com/), but the file -should allow falling back to the more common [Deja Vu Sans -Mono](https://dejavu-fonts.github.io/). I've found -[Terminus](http://terminus-font.sourceforge.net/) works well too, but bitmap -fonts are not really my cup of tea. The Lohit Kannada font bit is purely to -make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box. - -### tmux - -These are just generally vi-friendly settings, not much out of the ordinary. -Note that the configuration presently uses a hard-coded 256-color colorscheme, -and uses non-login shells, with an attempt to control the environment to stop -shells thinking they have access to an X display. - -The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into -the default command if no arguments are given and sessions do already exist. My -`~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key -combination to detach. - -### Vim - -The majority of the `.vimrc` file is just setting options, with a few mappings. -I try not to deviate too much from the Vim defaults behaviour in terms of -interactive behavior and keybindings. - -The configuration is extensively commented, mostly because I was reading -through it one day and realised I'd forgotten what half of it did. Plugins are -loaded using @tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen). - -Scripts -------- - -Where practical, I make short scripts into POSIX (but not Bourne) `sh(1)`, -`awk(1)`, or `sed(1)` scripts in `~/.local/bin`. I try to use shell functions -only when I actually need to, which tends to be when I need to tinker with the -namespace of the user's current shell. - -Installed by the `install-bin` target: - -* Three SSH-related scripts: - * `sls(1df)` prints hostnames read from a `ssh_config(5)` file. It uses - `slsf(1df)` to read each one. - * `sra(1df)` runs a command on multiple hosts read from `sls(1df)` and - prints output. - * `sta(1df)` runs a command on multiple hosts read from `sls(1df)` and - prints the hostname if the command returns zero. -* Five URL-related shortcut scripts: - * `hurl(1df)` extracts values of `href` attributes of `` tags, sorts - them uniquely, and writes them to `stdout`; it requires - [pup](https://github.com/ericchiang/pup). - * `murl(1df)` converts Markdown documents to HTML with `pandoc(1)` and - runs the output through `hurl(1df)`. - * `urlc(1df)` accepts a list of URLs on `stdin` and writes error messages - to `stderr` if any of the URLs are broken, redirecting, or are insecure - and have working secure versions; requires `curl(1)`. - * `urlh(1df)` prints the values for a given HTTP header from a HEAD - response. - * `urlmt(1df)` prints the MIME type from the `Content-Type` header as - retrieved by `urlh(1df)`. -* Three RFC-related shortcut scripts: - * `rfcf(1df)` fetches ASCII RFCs from the IETF website. - * `rfct(1df)` formats ASCII RFCs. - * `rfcr(1df)` does both, displaying in a pager if appropriate, like a - `man(1)` reader for RFCs. -* Five toy random-number scripts (not for sensitive/dead-serious use): - * `rndi(1df)` gets a random integer within two bounds. - * `rnds(1df)` attempts to get an optional random seed for `rndi(1df)`. - * `rnda(1df)` uses `rndi(1df)` to choose a random argument. - * `rndf(1df)` uses `rnda(1df)` to choose a random file from a directory. - * `rndl(1df)` uses `rndi(1df)` to choose a random line from files. -* Four file formatting scripts: - * `d2u(1df)` converts DOS line endings in files to UNIX ones. - * `u2d(1df)` converts UNIX line endings in files to DOS ones. - * `stbl(1df)` strips a trailing blank line from the files in its - arguments. - * `stws(1df)` strips trailing spaces from the ends of lines of the files - in its arguments. -* Seven stream formatting scripts: - * `sd2u(1df)` converts DOS line endings in streams to UNIX ones. - * `su2d(1df)` converts UNIX line endings in streams to DOS ones. - * `slow(1df)` converts uppercase to lowercase. - * `supp(1df)` converts lowercase to uppercase. - * `tl(1df)` tags input lines with a prefix or suffix, basically a - `sed(1)` shortcut. - * `tlcs(1df)` executes a command and uses `tl(1df)` to tag stdout and - stderr lines, and color them if you want. - * `unf(1df)` joins lines with leading spaces to the previous line. - Intended for unfolding HTTP headers, but it should work for most RFC - 822 formats. -* Six simple aggregators for numbers: - * `max(1df)` prints the maximum. - * `mean(1df)` prints the mean. - * `med(1df)` prints the median. - * `min(1df)` prints the minimum. - * `mode(1df)` prints the first encountered mode. - * `tot(1df)` totals the set. -* Three quick-and-dirty HTML tools: - * `htenc(1df)` encodes. - * `htdec(1df)` decodes. - * `htrec(1df)` wraps `a` tags around URLs. -* Two internet message quoting tools: - * `quo(1df)` indents with quoting right angle-brackets. - * `wro(1df)` adds a quote attribution header to its input. -* Six Git-related tools: - * `fgscr(1df)` finds Git repositories in a directory root and scrubs them - with `gscr(1df)`. - * `grc(1df)` quietly tests whether the given directory appears to be a - Git repository with pending changes. - * `gscr(1df)` scrubs Git repositories. - * `isgr(1df)` quietly tests whether the given directory appears to be a - Git repository. - * `jfc(1df)` adds and commits lazily to a Git repository. - * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it - sees any. -* Two time duration functions: - * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. - * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. -* Three pipe interaction tools: - * `pst(1df)` runs an interactive program on data before passing it along - a pipeline. - * `ped(1df)` runs `pst(1df)` with `$EDITOR` or `ed(1)`. - * `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`. -* `ap(1df)` reads arguments for a given command from the standard input, - prompting if appropriate. -* `apf(1df)` prepends arguments to a command with ones read from a file, - intended as a framework for shell wrappers or functions. -* `ax(1df)` evaluates an awk expression given on the command line; this is - intended as a quick way to test how Awk would interpret a given expression. -* `bcq(1df)` runs `bc(1)`, quieting it down if need be. -* `bel(1df)` prints a terminal bell character. -* `bl(1df)` generates a given number of blank lines. -* `bp(1df)` runs `br(1df)` after prompting for an URL. -* `br(1df)` launches `$BROWSER`. -* `ca(1df)` prints a count of its given arguments. -* `cf(1df)` prints a count of entries in a given directory. -* `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as - well. -* `chc(1df)` caches the output of a command. -* `chn(1df)` runs a filter over its input a given number of times. -* `clog(1df)` is a tiny timestamped log system. -* `clrd(1df)` sets up a per-line file read, clearing the screen first. -* `clwr(1df)` sets up a per-line file write, clearing the screen before each - line. -* `csmw(1df)` prints an English list of monospace-quoted words read from the - input. -* `dam(1df)` buffers all its input before emitting it as output. -* `ddup(1df)` removes duplicate lines from unsorted input. -* `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X - CLIPBOARD. -* `dub(1df)` lists the biggest entries in a directory. -* `edda(1df)` provides a means to run `ed(1)` over a set of files preserving - any options, mostly useful for scripts. -* `eds(1df)` edits executable script files in `EDSPATH`, defaulting to - `~/.local/bin`, for personal scripting snippets. -* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. -* `finc(1df)` counts the number of results returned from a set of given - `find(1)` conditions. -* `fnl(1df)` runs a command and saves its output and error into temporary - files, printing their paths and line counts. -* `fnp(1df)` prints the given files to stdout, each with a plaintext heading - with the filename in it. -* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the - script `getmails` in the `getmail` suite, but runs the requests in parallel - and does up to three silent retries using `try(1df)`. -* `grec(1df)` is a more logically-named `grep -c`. -* `gred(1df)` is a more logically-named `grep -v`. -* `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. -* `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will - look for `help` topics. You could use it from the shell too. -* `igex(1df)` wraps around a command to allow you to ignore error conditions - that don't actually worry you, exiting with 0 anyway. -* `ix(1df)` posts its input to the ix.io pastebin. -* `jfp(1df)` prints its input, excluding any shebang on the first line only. -* `loc(1df)` is a quick-search wrapped around `find(1)`. -* `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of - success, - it exits with success or failure. Good for quick tests. -* `mex(1df)` makes given filenames in `$PATH` executable. -* `mi5(1df)` pre-processes a crude but less painful macro expansion file - format into `m4` input. -* `mftl(1df)` finds usable-looking targets in Makefiles. -* `mkcp(1df)` creates a directory and copies preceding arguments into it. -* `mkmv(1df)` creates a directory and moves preceding arguments into it. -* `motd(1df)` shows the system MOTD. -* `mw(1df)` prints alphabetic space-delimited words from the input one per - line. -* `oii(1df)` runs a command on input only if there is any. -* `onl(1df)` crunches input down to one printable line. -* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s - `s_client` subcommand. -* `p(1df)` prints concatenated standard input; `cat(1)` as it should always - have been. -* `pa(1df)` prints its arguments, one per line. -* `pp(1df)` prints the full path of each argument using `$PWD`. -* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. -* `paz(1df)` print its arguments terminated by NULL chars. -* `pit(1df)` runs its input through a pager if its standard output looks like - a terminal. -* `plmu(1df)` retrieves a list of installed modules from - [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in - `~/.plenv/non-cpan-modules`, and updates them all. -* `pwg(1df)` generates just one decent password with `pwgen(1)`. -* `rep(1df)` repeats a command a given number of times. -* `rgl(1df)` is a very crude interactive `grep(1)` loop. -* `shb(1df)` attempts to build shebang lines for scripts from the system - paths. -* `sqs(1df)` chops off query strings from filenames, usually downloads. -* `sshi(1df)` prints human-readable SSH connection details. -* `stex(1df)` strips extensions from filenames. -* `sue(8df)` execs `sudoedit(8)` as the owner of all the file arguments given, - perhaps in cases where you may not necessarily have `root` `sudo(8)` - privileges. -* `swr(1df)` allows you to run commands locally specifying remote files in - `scp(1)`'s HOST:PATH format. -* `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used - to use Taskwarrior, but found it too complex and buggy. -* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and - `new-session` if it doesn't. -* `trs(1df)` replaces strings (not regular expression) in its input. -* `try(1df)` repeats a command up to a given number of times until it - succeeds, only printing error output if all three attempts failed. Good for - tolerating blips or temporary failures in `cron(8)` scripts. -* `umake(1df)` iterates upwards through the directory tree from `$PWD` until - it finds a Makefile for which to run `make(1)` with the given arguments. -* `uts(1df)` gets the current UNIX timestamp in an unorthodox way that should - work on all POSIX-compliant operating systems. -* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. -* `vex(1df)` runs a command and prints `true` or `false` explicitly to - `stdout` based on the exit value. -* `xrbg(1df)` applies the same randomly-selected background to each X screen. -* `xrq(1df)` gets the values of specific resources out of `xrdb -query` - output. - -There's some silly stuff in `install-games`: - -* `aaf(6df)` gets a random [ASCII Art Farts](http://www.asciiartfarts.com/) - comic. -* `acq(6df)` allows you to interrogate AC, the interplanetary computer. -* `aesth(6df)` converts English letters to their fullwidth CJK analogues, for - AESTHETIC PURPOSES. -* `squ(6df)` makes a reduced Latin square out of each line of input. -* `kvlt(6df)` translates input to emulate a style of typing unique to black - metal communities on the internet. -* `philsay(6df)` shows a picture to accompany `pks(6df)` output. -* `pks(6df)` laughs at a randomly selected word. -* `rndn(6df)` implements an esoteric random number generation algorithm. -* `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. -* `rot13(6df)` rotates the Latin letters in its input. -* `xyzzy(6df)` teleports to a marked location on the filesystem. -* `zs(6df)` prepends "z" case-appropriately to every occurrence of "s" in the - text on its standard input. - -Manuals -------- - -The `install-bin` and `install-games` targets install manuals for each script -they install. If you want to use the manuals, you may need to add -`~/.local/share/man` to your `~/.manpath` or `/etc/manpath` configuration, -depending on your system. - -Testing -------- - -You can check that both sets of shell scripts are syntactically correct with -`make check-bash`, `make check-sh`, or `make check` for everything including -the scripts in `bin` and `games`. There's no proper test suite for the actual -functionality (yet). - -If you have [ShellCheck](https://www.shellcheck.net/) and/or -[Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell -script files and Perl files respectively. The files don't need to pass that -check to be installed. - -Known issues ------------- - -See ISSUES.markdown. - -License -------- - -Public domain; see the included `UNLICENSE` file. It's just configuration and -simple scripts, so do whatever you like with it if any of it's useful to you. -If you're feeling generous, please join and/or donate to a free software -advocacy group, and let me know you did it because of this project: - -* [Free Software Foundation](https://www.fsf.org/) -* [Software in the Public Interest](https://www.spi-inc.org/) -* [FreeBSD Foundation](https://www.freebsdfoundation.org/) -* [OpenBSD Foundation](http://www.openbsdfoundation.org/) diff --git a/README.md b/README.md new file mode 100644 index 00000000..f1b254f0 --- /dev/null +++ b/README.md @@ -0,0 +1,603 @@ +Dotfiles (Tom Ryder) +==================== + +This is my personal repository of configuration files and scripts for `$HOME`, +including most of the settings that migrate well between machines. + +This repository began as a simple way to share Vim and tmux configuration, but +over time a lot of scripts and shell configuration have been added, making it +into a personal suite of custom Unix tools. + +Installation +------------ + + $ git clone https://sanctum.geek.nz/code/dotfiles.git ~/.dotfiles + $ cd ~/.dotfiles + $ git submodule init + $ git submodule update + $ make + $ make -n install + $ make install + +For the default `all` target, you'll need a POSIX-fearing userland, including +`make(1)` and `m4(1)`. + +The installation `Makefile` will overwrite things standing in the way of its +installed files without backing them up, so read the output of `make -n +install` before running `make install` to make sure you aren't going to lose +anything unexpected. If you're still not sure, install it in a temporary +directory so you can explore: + + $ tmpdir=$(mktemp -d) + $ make install HOME="$tmpdir" + $ env -i HOME="$tmpdir" TERM="$TERM" "$SHELL" -l + +The default `install` target will install these targets and all their +dependencies. Note that you don't actually have to have any of this except `sh` +installed. + +* `install-bin` +* `install-bin-man` +* `install-curl` +* `install-ex` +* `install-git` +* `install-gnupg` +* `install-less` +* `install-login-shell` +* `install-readline` +* `install-vim` + +The `install-login-shell` looks at your `SHELL` environment variable and tries +to figure out which shell’s configuration files to install, falling back on +`install-sh`. + +The remaining dotfiles can be installed with the other `install-*` targets. Try +`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list. + +Tools +----- + +Configuration is included for: + +* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and + some helper functions: + * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) + * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) + * [Z shell](https://www.zsh.org/) +* [Abook](http://abook.sourceforge.net/) -- curses address book program +* [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data + with URL syntax +* [Dunst](http://knopwob.org/dunst/) -- A lightweight X11 notification daemon + that works with `libnotify` +* `finger(1)` -- User information lookup program +* [Git](https://git-scm.com/) -- Distributed version control system +* [GnuPG](https://www.gnupg.org/) -- GNU Privacy Guard, for private + communication and file encryption +* [GTK+](https://www.gtk.org/) -- GIMP Toolkit, for graphical user interface + elements +* [i3](https://i3wm.org/) -- Tiling window manager +* [less](https://www.gnu.org/software/less/) -- Terminal pager +* [Mutt](http://www.mutt.org/) -- Terminal mail user agent +* [`mysql(1)`](https://linux.die.net/man/1/mysql) -- Command-line MySQL client +* [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client +* [Newsbeuter](https://www.newsbeuter.org/) -- Terminal RSS/Atom feed reader +* [`psql(1)`](https://linux.die.net/man/1/psql) -- Command-line PostgreSQL + client +* [Perl::Critic](http://perlcritic.com/) -- static source code analysis + engine for Perl +* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl indenter and + reformatter +* [Readline](https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) -- GNU + library for user input used by Bash, MySQL, and others +* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) -- Fork of + the rxvt terminal emulator with Unicode support +* [Subversion](https://subversion.apache.org/) -- Apache Subversion, a + version control system +* [tmux](https://tmux.github.io/) -- Terminal multiplexer similar to GNU + Screen +* [Vim](http://www.vim.org/) -- Vi IMproved, a text editor +* [X11](https://www.x.org/wiki/) -- Windowing system with network + transparency for Unix + +The configurations for shells, GnuPG, Mutt, tmux, and Vim are the most +expansive, and most likely to be of interest. The i3 configuration is mostly +changed to make window switching behave like Vim windows and tmux panes do, and +there's a fair few resources defined for rxvt-unicode. + +### Shell + +My `.profile` and other files in `sh` are written in POSIX shell script, so +they should work in most `sh(1)` implementations. Individual scripts called by +`.profile` are saved in `.profile.d` and iterated on login for ease of +management. Most of these boil down to exporting variables appropriate to the +system and the software it has available. + +Configuration that should be sourced for all POSIX-fearing interactive shells +is kept in `~/.shrc`, with subscripts read from `~/.shrc.d`. There's a shim in +`~/.shinit` to act as `ENV`. I make an effort to target POSIX for my functions +and scripts where I can so that the same files can be loaded for all shells. + +On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, preferably +`ksh93` if it's available. + +As I occasionally have work on very old internal systems, my Bash is written to +work with [any version 2.05a or +newer](http://wiki.bash-hackers.org/scripting/bashchanges). This is why I use +older syntax for certain things such as appending items to arrays: + + array[${#array[@]}]=$item + +Compare this to the much nicer syntax available since 3.1-alpha1, which +actually works for arrays with sparse indices, unlike the above syntax: + + array+=("$item") + +Where I do use features that are only available in versions of Bash newer than +2.05a, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run +after testing `BASH_VERSINFO` appropriately. + +#### Prompt + +A terminal session with my prompt looks something like this: + + ~$ ssh remote + remote:~$ cd .dotfiles + remote:~/.dotfiles(master+!)$ git status + M README.md + M bash/bashrc.d/prompt.bash + A init + remote:~/.dotfiles(master+!)$ foobar + foobar: command not found + remote:~/.dotfiles(master+!)<127>$ sleep 5 & + [1] 28937 + remote:~/.dotfiles(master+!){1}$ + +The hostname is elided if not connected via SSH. The working directory with +tilde abbreviation for `$HOME` is always shown. The rest of the prompt expands +based on context to include these elements in this order: + +* Whether in a Git repository if applicable, and punctuation to show + repository status including reference to upstreams at a glance. Subversion + support can also be enabled (I need it at work), in which case a `git:` or + `svn:` prefix is added appropriately. +* The number of running background jobs, if non-zero. +* The exit status of the last command, if non-zero. + +You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all +do about what you'd expect. + +If you start up Bash, Ksh, or Zsh and it detects that it's not normally your +`$SHELL`, the prompt will display an appropriate prefix. + +This is all managed within the `prompt` function. There's some mildly hacky +logic on `tput` codes included such that it should work correctly for most +common terminals using both `termcap(5)` and `terminfo(5)`, including \*BSD +systems. It's also designed to degrade gracefully for eight-color and no-color +terminals. + +#### Functions + +If a function can be written in POSIX `sh` without too much hackery, I put it +in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: + +* Four functions for using a "marked" directory, which I find a more + manageable concept than the `pushd`/`popd` directory stack: + * `md()` marks a given (or the current) directory. + * `gd()` goes to the marked directory. + * `pmd()` prints the marked directory. + * `xd()` swaps the current and marked directories. +* Ten other directory management and navigation functions: + * `bd()` changes into a named ancestor of the current directory. + * `gt()` changes into a directory or into a file's directory. + * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. + * `mkcd()` creates a directory and changes into it. + * `pd()` changes to the argument's parent directory. + * `rd()` replaces the first instance of its first argument with its + second argument in `$PWD`, emulating a feature of the Zsh `cd` builtin + that I like. + * `scr()` creates a temporary directory and changes into it. + * `sd()` changes into a sibling of the current directory. + * `ud()` changes into an indexed ancestor of a directory. + * `vr()` tries to change to the root directory of a source control + repository. +* `bc()` silences startup messages from GNU `bc(1)`. +* `ed()` tries to get verbose error messages, a prompt, and a Readline + environment for `ed(1)`. +* `gdb()` silences startup messages from `gdb(1)`. +* `gpg()` quietens `gpg(1)` down for most commands. +* `grep()` tries to apply color and other options good for interactive use if + available. +* `hgrep()` allows searching `$HISTFILE`. +* `keychain()` keeps `$GPG_TTY` up to date if a GnuPG agent is available. +* `ls()` tries to apply color and other options good for interactive use if + available. + * `la()` runs `ls -A` if it can, or `ls -a` otherwise. + * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. +* `path()` manages the contents of `PATH` conveniently. +* `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. +* `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never + preserved; I hate having `root`-owned files in my home directory. +* `tree()` colorizes GNU `tree(1)` output if possible (without having + `LS_COLORS` set). +* `x()` is a one-key shortcut for `exec startx`. + +There are a few other little tricks defined for other shells providing +non-POSIX features, as compatibility allows: + +* `keep()` stores ad-hoc shell functions and variables (Bash, Korn Shell 93, + Z shell). +* `prompt()` sets up my interactive prompt (Bash, Korn Shell, Z shell). +* `pushd()` adds a default destination of `$HOME` to the `pushd` builtin + (Bash). +* `vared()` allows interactively editing a variable with Readline, emulating + a Zsh function I like by the same name (Bash). +* `ver()` prints the current shell's version information (Bash, Korn Shell, + Z shell). + +#### Completion + +I find the `bash-completion` package a bit too heavy for my tastes, and turn it +off using a stub file installed in `~/.config/bash_completion`. The majority of +the time I just want to complete paths anyway, and this makes for a quicker +startup without a lot of junk functions in my Bash namespace. + +I do make some exceptions with completions defined in `.bash_completion.d` +files, for things I really do get tired of typing repeatedly: + +* Bash builtins: commands, help topics, shell options, variables, etc. +* `find(1)`'s more portable options +* `ftp(1)` hostnames from `~/.netrc` +* `git(1)` subcommands, remotes, branches, tags, and addable files +* `gpg(1)` long options +* `make(1)` targets read from a `Makefile` +* `man(1)` page titles +* `pass(1)` entries +* `ssh(1)` hostnames from `~/.ssh/config` + +For commands that pretty much always want to operate on text, such as text file +or stream editors, I exclude special file types and extensions I know are +binary. I don't actually read the file, so this is more of a heuristic thing, +and sometimes it will get things wrong. + +I also add completions for my own scripts and functions where useful. The +completions are dynamically loaded if Bash is version 4.0 or greater. +Otherwise, they're all loaded on startup. + +#### Korn shell + +These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T +`ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow +prompt if detected. + +#### Zsh + +These are experimental; I do not like Zsh much at the moment. The files started +as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan. + +### GnuPG + +The configuration for GnuPG is intended to follow [RiseUp's OpenPGP best +practices](https://riseup.net/en/security/message-security/openpgp/best-practices). +The configuration file is rebuilt using `mi5(1df)` and `make(1)` because it +requires hard-coding a path to the SKS keyserver certificate authority, and +neither tilde nor `$HOME` expansion works for this. + +### Mutt + +My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where +most unfiltered mail is sent. I use +[Getmail](http://pyropus.ca/software/getmail/), +[maildrop](https://www.courier-mta.org/maildrop/), and +[MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not +included here. I sign whenever I have some indication that the recipient might +be using a PGP implementation, and I encrypt whenever I have a public key +available for them. The GnuPG and S/MIME interfacing is done with +[GPGme](https://www.gnupg.org/related_software/gpgme/), rather than defining +commands for each crypto operation. I wrote [an article about this +setup](https://sanctum.geek.nz/arabesque/linux-crypto-email/) if it sounds +appealing. + +You'll need [Abook](http://abook.sourceforge.net/) installed if you want to use +the `query_command` I have defined, and [msmtp](http://msmtp.sourceforge.net/) +for the `sendmail` command. + +### rxvt-unicode + +I've butchered the URxvt Perl extensions `selection-to-clipboard` and +`selection` into a single `select` extension in `~/.urxvt/ext`, which is the +only extension I define in `~/.Xresources`. + +The included `.Xresources` file assumes that `urxvt` can use 256 colors and +Perl extensions. If you're missing functionality, try changing +`perl-ext-common` to `default`. + +My choice of font is [Ubuntu Mono](http://font.ubuntu.com/), but the file +should allow falling back to the more common [Deja Vu Sans +Mono](https://dejavu-fonts.github.io/). I've found +[Terminus](http://terminus-font.sourceforge.net/) works well too, but bitmap +fonts are not really my cup of tea. The Lohit Kannada font bit is purely to +make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box. + +### tmux + +These are just generally vi-friendly settings, not much out of the ordinary. +Note that the configuration presently uses a hard-coded 256-color colorscheme, +and uses non-login shells, with an attempt to control the environment to stop +shells thinking they have access to an X display. + +The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into +the default command if no arguments are given and sessions do already exist. My +`~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key +combination to detach. + +### Vim + +The majority of the `.vimrc` file is just setting options, with a few mappings. +I try not to deviate too much from the Vim defaults behaviour in terms of +interactive behavior and keybindings. + +The configuration is extensively commented, mostly because I was reading +through it one day and realised I'd forgotten what half of it did. Plugins are +loaded using @tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen). + +Scripts +------- + +Where practical, I make short scripts into POSIX (but not Bourne) `sh(1)`, +`awk(1)`, or `sed(1)` scripts in `~/.local/bin`. I try to use shell functions +only when I actually need to, which tends to be when I need to tinker with the +namespace of the user's current shell. + +Installed by the `install-bin` target: + +* Three SSH-related scripts: + * `sls(1df)` prints hostnames read from a `ssh_config(5)` file. It uses + `slsf(1df)` to read each one. + * `sra(1df)` runs a command on multiple hosts read from `sls(1df)` and + prints output. + * `sta(1df)` runs a command on multiple hosts read from `sls(1df)` and + prints the hostname if the command returns zero. +* Five URL-related shortcut scripts: + * `hurl(1df)` extracts values of `href` attributes of `` tags, sorts + them uniquely, and writes them to `stdout`; it requires + [pup](https://github.com/ericchiang/pup). + * `murl(1df)` converts Markdown documents to HTML with `pandoc(1)` and + runs the output through `hurl(1df)`. + * `urlc(1df)` accepts a list of URLs on `stdin` and writes error messages + to `stderr` if any of the URLs are broken, redirecting, or are insecure + and have working secure versions; requires `curl(1)`. + * `urlh(1df)` prints the values for a given HTTP header from a HEAD + response. + * `urlmt(1df)` prints the MIME type from the `Content-Type` header as + retrieved by `urlh(1df)`. +* Three RFC-related shortcut scripts: + * `rfcf(1df)` fetches ASCII RFCs from the IETF website. + * `rfct(1df)` formats ASCII RFCs. + * `rfcr(1df)` does both, displaying in a pager if appropriate, like a + `man(1)` reader for RFCs. +* Five toy random-number scripts (not for sensitive/dead-serious use): + * `rndi(1df)` gets a random integer within two bounds. + * `rnds(1df)` attempts to get an optional random seed for `rndi(1df)`. + * `rnda(1df)` uses `rndi(1df)` to choose a random argument. + * `rndf(1df)` uses `rnda(1df)` to choose a random file from a directory. + * `rndl(1df)` uses `rndi(1df)` to choose a random line from files. +* Four file formatting scripts: + * `d2u(1df)` converts DOS line endings in files to UNIX ones. + * `u2d(1df)` converts UNIX line endings in files to DOS ones. + * `stbl(1df)` strips a trailing blank line from the files in its + arguments. + * `stws(1df)` strips trailing spaces from the ends of lines of the files + in its arguments. +* Seven stream formatting scripts: + * `sd2u(1df)` converts DOS line endings in streams to UNIX ones. + * `su2d(1df)` converts UNIX line endings in streams to DOS ones. + * `slow(1df)` converts uppercase to lowercase. + * `supp(1df)` converts lowercase to uppercase. + * `tl(1df)` tags input lines with a prefix or suffix, basically a + `sed(1)` shortcut. + * `tlcs(1df)` executes a command and uses `tl(1df)` to tag stdout and + stderr lines, and color them if you want. + * `unf(1df)` joins lines with leading spaces to the previous line. + Intended for unfolding HTTP headers, but it should work for most RFC + 822 formats. +* Six simple aggregators for numbers: + * `max(1df)` prints the maximum. + * `mean(1df)` prints the mean. + * `med(1df)` prints the median. + * `min(1df)` prints the minimum. + * `mode(1df)` prints the first encountered mode. + * `tot(1df)` totals the set. +* Three quick-and-dirty HTML tools: + * `htenc(1df)` encodes. + * `htdec(1df)` decodes. + * `htrec(1df)` wraps `a` tags around URLs. +* Two internet message quoting tools: + * `quo(1df)` indents with quoting right angle-brackets. + * `wro(1df)` adds a quote attribution header to its input. +* Six Git-related tools: + * `fgscr(1df)` finds Git repositories in a directory root and scrubs them + with `gscr(1df)`. + * `grc(1df)` quietly tests whether the given directory appears to be a + Git repository with pending changes. + * `gscr(1df)` scrubs Git repositories. + * `isgr(1df)` quietly tests whether the given directory appears to be a + Git repository. + * `jfc(1df)` adds and commits lazily to a Git repository. + * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it + sees any. +* Two time duration functions: + * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. + * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. +* Three pipe interaction tools: + * `pst(1df)` runs an interactive program on data before passing it along + a pipeline. + * `ped(1df)` runs `pst(1df)` with `$EDITOR` or `ed(1)`. + * `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`. +* `ap(1df)` reads arguments for a given command from the standard input, + prompting if appropriate. +* `apf(1df)` prepends arguments to a command with ones read from a file, + intended as a framework for shell wrappers or functions. +* `ax(1df)` evaluates an awk expression given on the command line; this is + intended as a quick way to test how Awk would interpret a given expression. +* `bcq(1df)` runs `bc(1)`, quieting it down if need be. +* `bel(1df)` prints a terminal bell character. +* `bl(1df)` generates a given number of blank lines. +* `bp(1df)` runs `br(1df)` after prompting for an URL. +* `br(1df)` launches `$BROWSER`. +* `ca(1df)` prints a count of its given arguments. +* `cf(1df)` prints a count of entries in a given directory. +* `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as + well. +* `chc(1df)` caches the output of a command. +* `chn(1df)` runs a filter over its input a given number of times. +* `clog(1df)` is a tiny timestamped log system. +* `clrd(1df)` sets up a per-line file read, clearing the screen first. +* `clwr(1df)` sets up a per-line file write, clearing the screen before each + line. +* `csmw(1df)` prints an English list of monospace-quoted words read from the + input. +* `dam(1df)` buffers all its input before emitting it as output. +* `ddup(1df)` removes duplicate lines from unsorted input. +* `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X + CLIPBOARD. +* `dub(1df)` lists the biggest entries in a directory. +* `edda(1df)` provides a means to run `ed(1)` over a set of files preserving + any options, mostly useful for scripts. +* `eds(1df)` edits executable script files in `EDSPATH`, defaulting to + `~/.local/bin`, for personal scripting snippets. +* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. +* `finc(1df)` counts the number of results returned from a set of given + `find(1)` conditions. +* `fnl(1df)` runs a command and saves its output and error into temporary + files, printing their paths and line counts. +* `fnp(1df)` prints the given files to stdout, each with a plaintext heading + with the filename in it. +* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the + script `getmails` in the `getmail` suite, but runs the requests in parallel + and does up to three silent retries using `try(1df)`. +* `grec(1df)` is a more logically-named `grep -c`. +* `gred(1df)` is a more logically-named `grep -v`. +* `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. +* `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will + look for `help` topics. You could use it from the shell too. +* `igex(1df)` wraps around a command to allow you to ignore error conditions + that don't actually worry you, exiting with 0 anyway. +* `ix(1df)` posts its input to the ix.io pastebin. +* `jfp(1df)` prints its input, excluding any shebang on the first line only. +* `loc(1df)` is a quick-search wrapped around `find(1)`. +* `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of + success, + it exits with success or failure. Good for quick tests. +* `mex(1df)` makes given filenames in `$PATH` executable. +* `mi5(1df)` pre-processes a crude but less painful macro expansion file + format into `m4` input. +* `mftl(1df)` finds usable-looking targets in Makefiles. +* `mkcp(1df)` creates a directory and copies preceding arguments into it. +* `mkmv(1df)` creates a directory and moves preceding arguments into it. +* `motd(1df)` shows the system MOTD. +* `mw(1df)` prints alphabetic space-delimited words from the input one per + line. +* `oii(1df)` runs a command on input only if there is any. +* `onl(1df)` crunches input down to one printable line. +* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s + `s_client` subcommand. +* `p(1df)` prints concatenated standard input; `cat(1)` as it should always + have been. +* `pa(1df)` prints its arguments, one per line. +* `pp(1df)` prints the full path of each argument using `$PWD`. +* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. +* `paz(1df)` print its arguments terminated by NULL chars. +* `pit(1df)` runs its input through a pager if its standard output looks like + a terminal. +* `plmu(1df)` retrieves a list of installed modules from + [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in + `~/.plenv/non-cpan-modules`, and updates them all. +* `pwg(1df)` generates just one decent password with `pwgen(1)`. +* `rep(1df)` repeats a command a given number of times. +* `rgl(1df)` is a very crude interactive `grep(1)` loop. +* `shb(1df)` attempts to build shebang lines for scripts from the system + paths. +* `sqs(1df)` chops off query strings from filenames, usually downloads. +* `sshi(1df)` prints human-readable SSH connection details. +* `stex(1df)` strips extensions from filenames. +* `sue(8df)` execs `sudoedit(8)` as the owner of all the file arguments given, + perhaps in cases where you may not necessarily have `root` `sudo(8)` + privileges. +* `swr(1df)` allows you to run commands locally specifying remote files in + `scp(1)`'s HOST:PATH format. +* `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used + to use Taskwarrior, but found it too complex and buggy. +* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and + `new-session` if it doesn't. +* `trs(1df)` replaces strings (not regular expression) in its input. +* `try(1df)` repeats a command up to a given number of times until it + succeeds, only printing error output if all three attempts failed. Good for + tolerating blips or temporary failures in `cron(8)` scripts. +* `umake(1df)` iterates upwards through the directory tree from `$PWD` until + it finds a Makefile for which to run `make(1)` with the given arguments. +* `uts(1df)` gets the current UNIX timestamp in an unorthodox way that should + work on all POSIX-compliant operating systems. +* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. +* `vex(1df)` runs a command and prints `true` or `false` explicitly to + `stdout` based on the exit value. +* `xrbg(1df)` applies the same randomly-selected background to each X screen. +* `xrq(1df)` gets the values of specific resources out of `xrdb -query` + output. + +There's some silly stuff in `install-games`: + +* `aaf(6df)` gets a random [ASCII Art Farts](http://www.asciiartfarts.com/) + comic. +* `acq(6df)` allows you to interrogate AC, the interplanetary computer. +* `aesth(6df)` converts English letters to their fullwidth CJK analogues, for + AESTHETIC PURPOSES. +* `squ(6df)` makes a reduced Latin square out of each line of input. +* `kvlt(6df)` translates input to emulate a style of typing unique to black + metal communities on the internet. +* `philsay(6df)` shows a picture to accompany `pks(6df)` output. +* `pks(6df)` laughs at a randomly selected word. +* `rndn(6df)` implements an esoteric random number generation algorithm. +* `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. +* `rot13(6df)` rotates the Latin letters in its input. +* `xyzzy(6df)` teleports to a marked location on the filesystem. +* `zs(6df)` prepends "z" case-appropriately to every occurrence of "s" in the + text on its standard input. + +Manuals +------- + +The `install-bin` and `install-games` targets install manuals for each script +they install. If you want to use the manuals, you may need to add +`~/.local/share/man` to your `~/.manpath` or `/etc/manpath` configuration, +depending on your system. + +Testing +------- + +You can check that both sets of shell scripts are syntactically correct with +`make check-bash`, `make check-sh`, or `make check` for everything including +the scripts in `bin` and `games`. There's no proper test suite for the actual +functionality (yet). + +If you have [ShellCheck](https://www.shellcheck.net/) and/or +[Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell +script files and Perl files respectively. The files don't need to pass that +check to be installed. + +Known issues +------------ + +See ISSUES.markdown. + +License +------- + +Public domain; see the included `UNLICENSE` file. It's just configuration and +simple scripts, so do whatever you like with it if any of it's useful to you. +If you're feeling generous, please join and/or donate to a free software +advocacy group, and let me know you did it because of this project: + +* [Free Software Foundation](https://www.fsf.org/) +* [Software in the Public Interest](https://www.spi-inc.org/) +* [FreeBSD Foundation](https://www.freebsdfoundation.org/) +* [OpenBSD Foundation](http://www.openbsdfoundation.org/) diff --git a/TABS.markdown b/TABS.markdown deleted file mode 100644 index feeee631..00000000 --- a/TABS.markdown +++ /dev/null @@ -1,26 +0,0 @@ -Spaces to tabs -============== - -If you prefer tabs to spaces, the following recipe seems to convert everything -pretty nicely: - - $ find . -name .git -prune -o -name vim -prune -o -type f \ - -exec sh -c \ - 'for f;do unexpand -t4 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ - _ {} + - - $ find vim -name bundle -prune -o -type f \ - -exec sh -c \ - 'for f;do unexpand -t2 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ - _ {} + - -If you have GNU unexpand(1) and can add `--first-only` to each of those calls, -the results seem perfect. - -You can configure Vim to accommodate this by removing the settings for: - -* `expandtab` -* `shiftround` -* `shiftwidth` -* `smarttab` -* `softtabstop` diff --git a/TABS.md b/TABS.md new file mode 100644 index 00000000..feeee631 --- /dev/null +++ b/TABS.md @@ -0,0 +1,26 @@ +Spaces to tabs +============== + +If you prefer tabs to spaces, the following recipe seems to convert everything +pretty nicely: + + $ find . -name .git -prune -o -name vim -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t4 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + + $ find vim -name bundle -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t2 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + +If you have GNU unexpand(1) and can add `--first-only` to each of those calls, +the results seem perfect. + +You can configure Vim to accommodate this by removing the settings for: + +* `expandtab` +* `shiftround` +* `shiftwidth` +* `smarttab` +* `softtabstop` diff --git a/man/man1/murl.1df b/man/man1/murl.1df index f022152b..088158b0 100644 --- a/man/man1/murl.1df +++ b/man/man1/murl.1df @@ -4,7 +4,7 @@ \- convert Markdown to HTML with pandoc(1) and extract URLs from it with hurl(1df) .SH SYNOPSIS .B murl -README.markdown +README.md .br .B murl page1.md page2.md diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index 831af06d..5538fdd2 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -209,7 +209,7 @@ A terminal session with my prompt looks something like this: ~$\ ssh\ remote remote:~$\ cd\ .dotfiles remote:~/.dotfiles(master+!)$\ git\ status -\ M\ README.markdown +\ M\ README.md M\ \ bash/bashrc.d/prompt.bash A\ \ init remote:~/.dotfiles(master+!)$\ foobar -- cgit v1.2.3 From 45ca5d95d610e44fa4728a0374024300bbb025d0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 15:02:43 +1300 Subject: Merge branch 'master' into port/sunos/illumos/openindiana --- IDEAS.markdown | 21 -- IDEAS.md | 21 ++ ISSUES.markdown | 24 -- ISSUES.md | 24 ++ README.markdown | 603 -------------------------------------------------- README.md | 603 ++++++++++++++++++++++++++++++++++++++++++++++++++ TABS.md | 26 +++ man/man1/murl.1df | 2 +- man/man7/dotfiles.7df | 2 +- sh/shrc.d/ls.sh | 10 + 10 files changed, 686 insertions(+), 650 deletions(-) delete mode 100644 IDEAS.markdown create mode 100644 IDEAS.md delete mode 100644 ISSUES.markdown create mode 100644 ISSUES.md delete mode 100644 README.markdown create mode 100644 README.md create mode 100644 TABS.md diff --git a/IDEAS.markdown b/IDEAS.markdown deleted file mode 100644 index 544530e3..00000000 --- a/IDEAS.markdown +++ /dev/null @@ -1,21 +0,0 @@ -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 - manageable -* Have eds(1df) accept stdin with the "starting content" for the script -* Convert all the manual pages to mandoc maybe? -* qmp(1df)--quick man page -* The solution to chn(1df) not running in parallel is probably backgrounded - processes and mkfifo(1). -* Write something like hcat(1df) or tcat(1df) that includes filename headings - for each concatenated file. -* I can probably get rid of all that nasty templated shell by writing - something that wraps around td(1df) and generates shell script to run, and - calls that via `eval`. diff --git a/IDEAS.md b/IDEAS.md new file mode 100644 index 00000000..bba9e314 --- /dev/null +++ b/IDEAS.md @@ -0,0 +1,21 @@ +Ideas +===== + +* A wrapper ksw(1df) (kill-switch) that traps SIGINT 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 + manageable +* Have eds(1df) accept stdin with the "starting content" for the script +* Convert all the manual pages to mandoc maybe? +* qmp(1df)--quick man page +* The solution to chn(1df) not running in parallel is probably backgrounded + processes and mkfifo(1). +* Write something like hcat(1df) or tcat(1df) that includes filename headings + for each concatenated file. +* I can probably get rid of all that nasty templated shell by writing + something that wraps around td(1df) and generates shell script to run, and + calls that via `eval`. diff --git a/ISSUES.markdown b/ISSUES.markdown deleted file mode 100644 index 48007919..00000000 --- a/ISSUES.markdown +++ /dev/null @@ -1,24 +0,0 @@ -Known issues -============ - -* man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on - that system; need to find some way of finding which manual directories - should be searched at runtime, if there is one. -* The checks gscr(1df) makes to determine where it is are a bit naïve (don't - work with bare repos) and could probably be improved with some appropriate - git-reflog(1) calls -* dr(6df) is probably more practical in awk -* Running the block of git(1) commands in the prompt leaves five "stale" - jobspecs around that flee after a jobs builtin run; only saw this manifest - after 90dcadf; either I understand job specs really poorly or this may be a - bug in bash -* I can't find a clean way of detecting a restricted shell for ksh instances - to prevent trying to load anything fancy (works for Bash) - * Zsh, either! $options[restricted] is "off" within the startup file -* Would be good to complete the Makefile variables for NAME, EMAIL etc with - educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding - my own stuff in there -* Completion for custom functions e.g. `sd` should ideally respect - `completion-ignore-case` setting -* Document `install-conf` target once I'm sure it's not a dumb idea -* Need to decide whether I care about XDG, and implement it if I do diff --git a/ISSUES.md b/ISSUES.md new file mode 100644 index 00000000..48007919 --- /dev/null +++ b/ISSUES.md @@ -0,0 +1,24 @@ +Known issues +============ + +* man(1) completion doesn't work on OpenBSD as manpath(1) isn't a thing on + that system; need to find some way of finding which manual directories + should be searched at runtime, if there is one. +* The checks gscr(1df) makes to determine where it is are a bit naïve (don't + work with bare repos) and could probably be improved with some appropriate + git-reflog(1) calls +* dr(6df) is probably more practical in awk +* Running the block of git(1) commands in the prompt leaves five "stale" + jobspecs around that flee after a jobs builtin run; only saw this manifest + after 90dcadf; either I understand job specs really poorly or this may be a + bug in bash +* I can't find a clean way of detecting a restricted shell for ksh instances + to prevent trying to load anything fancy (works for Bash) + * Zsh, either! $options[restricted] is "off" within the startup file +* Would be good to complete the Makefile variables for NAME, EMAIL etc with + educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding + my own stuff in there +* Completion for custom functions e.g. `sd` should ideally respect + `completion-ignore-case` setting +* Document `install-conf` target once I'm sure it's not a dumb idea +* Need to decide whether I care about XDG, and implement it if I do diff --git a/README.markdown b/README.markdown deleted file mode 100644 index adc4c73a..00000000 --- a/README.markdown +++ /dev/null @@ -1,603 +0,0 @@ -Dotfiles (Tom Ryder) -==================== - -This is my personal repository of configuration files and scripts for `$HOME`, -including most of the settings that migrate well between machines. - -This repository began as a simple way to share Vim and tmux configuration, but -over time a lot of scripts and shell configuration have been added, making it -into a personal suite of custom Unix tools. - -Installation ------------- - - $ git clone https://sanctum.geek.nz/code/dotfiles.git ~/.dotfiles - $ cd ~/.dotfiles - $ git submodule init - $ git submodule update - $ make - $ make -n install - $ make install - -For the default `all` target, you'll need a POSIX-fearing userland, including -`make(1)` and `m4(1)`. - -The installation `Makefile` will overwrite things standing in the way of its -installed files without backing them up, so read the output of `make -n -install` before running `make install` to make sure you aren't going to lose -anything unexpected. If you're still not sure, install it in a temporary -directory so you can explore: - - $ tmpdir=$(mktemp -d) - $ make install HOME="$tmpdir" - $ env -i HOME="$tmpdir" TERM="$TERM" "$SHELL" -l - -The default `install` target will install these targets and all their -dependencies. Note that you don't actually have to have any of this except `sh` -installed. - -* `install-bin` -* `install-bin-man` -* `install-curl` -* `install-ex` -* `install-git` -* `install-gnupg` -* `install-less` -* `install-login-shell` -* `install-readline` -* `install-vim` - -The `install-login-shell` looks at your `SHELL` environment variable and tries -to figure out which shell’s configuration files to install, falling back on -`install-sh`. - -The remaining dotfiles can be installed with the other `install-*` targets. Try -`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list. - -Tools ------ - -Configuration is included for: - -* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and - some helper functions: - * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) - * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) - * [Z shell](https://www.zsh.org/) -* [Abook](http://abook.sourceforge.net/) -- curses address book program -* [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data - with URL syntax -* [Dunst](http://knopwob.org/dunst/) -- A lightweight X11 notification daemon - that works with `libnotify` -* `finger(1)` -- User information lookup program -* [Git](https://git-scm.com/) -- Distributed version control system -* [GnuPG](https://www.gnupg.org/) -- GNU Privacy Guard, for private - communication and file encryption -* [GTK+](https://www.gtk.org/) -- GIMP Toolkit, for graphical user interface - elements -* [i3](https://i3wm.org/) -- Tiling window manager -* [less](https://www.gnu.org/software/less/) -- Terminal pager -* [Mutt](http://www.mutt.org/) -- Terminal mail user agent -* [`mysql(1)`](https://linux.die.net/man/1/mysql) -- Command-line MySQL client -* [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client -* [Newsbeuter](https://www.newsbeuter.org/) -- Terminal RSS/Atom feed reader -* [`psql(1)`](https://linux.die.net/man/1/psql) -- Command-line PostgreSQL - client -* [Perl::Critic](http://perlcritic.com/) -- static source code analysis - engine for Perl -* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl indenter and - reformatter -* [Readline](https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) -- GNU - library for user input used by Bash, MySQL, and others -* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) -- Fork of - the rxvt terminal emulator with Unicode support -* [Subversion](https://subversion.apache.org/) -- Apache Subversion, a - version control system -* [tmux](https://tmux.github.io/) -- Terminal multiplexer similar to GNU - Screen -* [Vim](http://www.vim.org/) -- Vi IMproved, a text editor -* [X11](https://www.x.org/wiki/) -- Windowing system with network - transparency for Unix - -The configurations for shells, GnuPG, Mutt, tmux, and Vim are the most -expansive, and most likely to be of interest. The i3 configuration is mostly -changed to make window switching behave like Vim windows and tmux panes do, and -there's a fair few resources defined for rxvt-unicode. - -### Shell - -My `.profile` and other files in `sh` are written in POSIX shell script, so -they should work in most `sh(1)` implementations. Individual scripts called by -`.profile` are saved in `.profile.d` and iterated on login for ease of -management. Most of these boil down to exporting variables appropriate to the -system and the software it has available. - -Configuration that should be sourced for all POSIX-fearing interactive shells -is kept in `~/.shrc`, with subscripts read from `~/.shrc.d`. There's a shim in -`~/.shinit` to act as `ENV`. I make an effort to target POSIX for my functions -and scripts where I can so that the same files can be loaded for all shells. - -On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, preferably -`ksh93` if it's available. - -As I occasionally have work on very old internal systems, my Bash is written to -work with [any version 2.05a or -newer](http://wiki.bash-hackers.org/scripting/bashchanges). This is why I use -older syntax for certain things such as appending items to arrays: - - array[${#array[@]}]=$item - -Compare this to the much nicer syntax available since 3.1-alpha1, which -actually works for arrays with sparse indices, unlike the above syntax: - - array+=("$item") - -Where I do use features that are only available in versions of Bash newer than -2.05a, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run -after testing `BASH_VERSINFO` appropriately. - -#### Prompt - -A terminal session with my prompt looks something like this: - - ~$ ssh remote - remote:~$ cd .dotfiles - remote:~/.dotfiles(master+!)$ git status - M README.markdown - M bash/bashrc.d/prompt.bash - A init - remote:~/.dotfiles(master+!)$ foobar - foobar: command not found - remote:~/.dotfiles(master+!)<127>$ sleep 5 & - [1] 28937 - remote:~/.dotfiles(master+!){1}$ - -The hostname is elided if not connected via SSH. The working directory with -tilde abbreviation for `$HOME` is always shown. The rest of the prompt expands -based on context to include these elements in this order: - -* Whether in a Git repository if applicable, and punctuation to show - repository status including reference to upstreams at a glance. Subversion - support can also be enabled (I need it at work), in which case a `git:` or - `svn:` prefix is added appropriately. -* The number of running background jobs, if non-zero. -* The exit status of the last command, if non-zero. - -You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all -do about what you'd expect. - -If you start up Bash, Ksh, or Zsh and it detects that it's not normally your -`$SHELL`, the prompt will display an appropriate prefix. - -This is all managed within the `prompt` function. There's some mildly hacky -logic on `tput` codes included such that it should work correctly for most -common terminals using both `termcap(5)` and `terminfo(5)`, including \*BSD -systems. It's also designed to degrade gracefully for eight-color and no-color -terminals. - -#### Functions - -If a function can be written in POSIX `sh` without too much hackery, I put it -in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: - -* Four functions for using a "marked" directory, which I find a more - manageable concept than the `pushd`/`popd` directory stack: - * `md()` marks a given (or the current) directory. - * `gd()` goes to the marked directory. - * `pmd()` prints the marked directory. - * `xd()` swaps the current and marked directories. -* Ten other directory management and navigation functions: - * `bd()` changes into a named ancestor of the current directory. - * `gt()` changes into a directory or into a file's directory. - * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. - * `mkcd()` creates a directory and changes into it. - * `pd()` changes to the argument's parent directory. - * `rd()` replaces the first instance of its first argument with its - second argument in `$PWD`, emulating a feature of the Zsh `cd` builtin - that I like. - * `scr()` creates a temporary directory and changes into it. - * `sd()` changes into a sibling of the current directory. - * `ud()` changes into an indexed ancestor of a directory. - * `vr()` tries to change to the root directory of a source control - repository. -* `bc()` silences startup messages from GNU `bc(1)`. -* `ed()` tries to get verbose error messages, a prompt, and a Readline - environment for `ed(1)`. -* `gdb()` silences startup messages from `gdb(1)`. -* `gpg()` quietens `gpg(1)` down for most commands. -* `grep()` tries to apply color and other options good for interactive use if - available. -* `hgrep()` allows searching `$HISTFILE`. -* `keychain()` keeps `$GPG_TTY` up to date if a GnuPG agent is available. -* `ls()` tries to apply color and other options good for interactive use if - available. - * `la()` runs `ls -A` if it can, or `ls -a` otherwise. - * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. -* `path()` manages the contents of `PATH` conveniently. -* `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. -* `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never - preserved; I hate having `root`-owned files in my home directory. -* `tree()` colorizes GNU `tree(1)` output if possible (without having - `LS_COLORS` set). -* `x()` is a one-key shortcut for `exec startx`. - -There are a few other little tricks defined for other shells providing -non-POSIX features, as compatibility allows: - -* `keep()` stores ad-hoc shell functions and variables (Bash, Korn Shell 93, - Z shell). -* `prompt()` sets up my interactive prompt (Bash, Korn Shell, Z shell). -* `pushd()` adds a default destination of `$HOME` to the `pushd` builtin - (Bash). -* `vared()` allows interactively editing a variable with Readline, emulating - a Zsh function I like by the same name (Bash). -* `ver()` prints the current shell's version information (Bash, Korn Shell, - Z shell). - -#### Completion - -I find the `bash-completion` package a bit too heavy for my tastes, and turn it -off using a stub file installed in `~/.config/bash_completion`. The majority of -the time I just want to complete paths anyway, and this makes for a quicker -startup without a lot of junk functions in my Bash namespace. - -I do make some exceptions with completions defined in `.bash_completion.d` -files, for things I really do get tired of typing repeatedly: - -* Bash builtins: commands, help topics, shell options, variables, etc. -* `find(1)`'s more portable options -* `ftp(1)` hostnames from `~/.netrc` -* `git(1)` subcommands, remotes, branches, tags, and addable files -* `gpg(1)` long options -* `make(1)` targets read from a `Makefile` -* `man(1)` page titles -* `pass(1)` entries -* `ssh(1)` hostnames from `~/.ssh/config` - -For commands that pretty much always want to operate on text, such as text file -or stream editors, I exclude special file types and extensions I know are -binary. I don't actually read the file, so this is more of a heuristic thing, -and sometimes it will get things wrong. - -I also add completions for my own scripts and functions where useful. The -completions are dynamically loaded if Bash is version 4.0 or greater. -Otherwise, they're all loaded on startup. - -#### Korn shell - -These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T -`ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow -prompt if detected. - -#### Zsh - -These are experimental; I do not like Zsh much at the moment. The files started -as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan. - -### GnuPG - -The configuration for GnuPG is intended to follow [RiseUp's OpenPGP best -practices](https://riseup.net/en/security/message-security/openpgp/best-practices). -The configuration file is rebuilt using `mi5(1df)` and `make(1)` because it -requires hard-coding a path to the SKS keyserver certificate authority, and -neither tilde nor `$HOME` expansion works for this. - -### Mutt - -My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where -most unfiltered mail is sent. I use -[Getmail](http://pyropus.ca/software/getmail/), -[maildrop](https://www.courier-mta.org/maildrop/), and -[MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not -included here. I sign whenever I have some indication that the recipient might -be using a PGP implementation, and I encrypt whenever I have a public key -available for them. The GnuPG and S/MIME interfacing is done with -[GPGme](https://www.gnupg.org/related_software/gpgme/), rather than defining -commands for each crypto operation. I wrote [an article about this -setup](https://sanctum.geek.nz/arabesque/linux-crypto-email/) if it sounds -appealing. - -You'll need [Abook](http://abook.sourceforge.net/) installed if you want to use -the `query_command` I have defined, and [msmtp](http://msmtp.sourceforge.net/) -for the `sendmail` command. - -### rxvt-unicode - -I've butchered the URxvt Perl extensions `selection-to-clipboard` and -`selection` into a single `select` extension in `~/.urxvt/ext`, which is the -only extension I define in `~/.Xresources`. - -The included `.Xresources` file assumes that `urxvt` can use 256 colors and -Perl extensions. If you're missing functionality, try changing -`perl-ext-common` to `default`. - -My choice of font is [Ubuntu Mono](http://font.ubuntu.com/), but the file -should allow falling back to the more common [Deja Vu Sans -Mono](https://dejavu-fonts.github.io/). I've found -[Terminus](http://terminus-font.sourceforge.net/) works well too, but bitmap -fonts are not really my cup of tea. The Lohit Kannada font bit is purely to -make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box. - -### tmux - -These are just generally vi-friendly settings, not much out of the ordinary. -Note that the configuration presently uses a hard-coded 256-color colorscheme, -and uses non-login shells, with an attempt to control the environment to stop -shells thinking they have access to an X display. - -The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into -the default command if no arguments are given and sessions do already exist. My -`~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key -combination to detach. - -### Vim - -The majority of the `.vimrc` file is just setting options, with a few mappings. -I try not to deviate too much from the Vim defaults behaviour in terms of -interactive behavior and keybindings. - -The configuration is extensively commented, mostly because I was reading -through it one day and realised I'd forgotten what half of it did. Plugins are -loaded using @tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen). - -Scripts -------- - -Where practical, I make short scripts into POSIX (but not Bourne) `sh(1)`, -`awk(1)`, or `sed(1)` scripts in `~/.local/bin`. I try to use shell functions -only when I actually need to, which tends to be when I need to tinker with the -namespace of the user's current shell. - -Installed by the `install-bin` target: - -* Three SSH-related scripts: - * `sls(1df)` prints hostnames read from a `ssh_config(5)` file. It uses - `slsf(1df)` to read each one. - * `sra(1df)` runs a command on multiple hosts read from `sls(1df)` and - prints output. - * `sta(1df)` runs a command on multiple hosts read from `sls(1df)` and - prints the hostname if the command returns zero. -* Five URL-related shortcut scripts: - * `hurl(1df)` extracts values of `href` attributes of `` tags, sorts - them uniquely, and writes them to `stdout`; it requires - [pup](https://github.com/ericchiang/pup). - * `murl(1df)` converts Markdown documents to HTML with `pandoc(1)` and - runs the output through `hurl(1df)`. - * `urlc(1df)` accepts a list of URLs on `stdin` and writes error messages - to `stderr` if any of the URLs are broken, redirecting, or are insecure - and have working secure versions; requires `curl(1)`. - * `urlh(1df)` prints the values for a given HTTP header from a HEAD - response. - * `urlmt(1df)` prints the MIME type from the `Content-Type` header as - retrieved by `urlh(1df)`. -* Three RFC-related shortcut scripts: - * `rfcf(1df)` fetches ASCII RFCs from the IETF website. - * `rfct(1df)` formats ASCII RFCs. - * `rfcr(1df)` does both, displaying in a pager if appropriate, like a - `man(1)` reader for RFCs. -* Five toy random-number scripts (not for sensitive/dead-serious use): - * `rndi(1df)` gets a random integer within two bounds. - * `rnds(1df)` attempts to get an optional random seed for `rndi(1df)`. - * `rnda(1df)` uses `rndi(1df)` to choose a random argument. - * `rndf(1df)` uses `rnda(1df)` to choose a random file from a directory. - * `rndl(1df)` uses `rndi(1df)` to choose a random line from files. -* Four file formatting scripts: - * `d2u(1df)` converts DOS line endings in files to UNIX ones. - * `u2d(1df)` converts UNIX line endings in files to DOS ones. - * `stbl(1df)` strips a trailing blank line from the files in its - arguments. - * `stws(1df)` strips trailing spaces from the ends of lines of the files - in its arguments. -* Seven stream formatting scripts: - * `sd2u(1df)` converts DOS line endings in streams to UNIX ones. - * `su2d(1df)` converts UNIX line endings in streams to DOS ones. - * `slow(1df)` converts uppercase to lowercase. - * `supp(1df)` converts lowercase to uppercase. - * `tl(1df)` tags input lines with a prefix or suffix, basically a - `sed(1)` shortcut. - * `tlcs(1df)` executes a command and uses `tl(1df)` to tag stdout and - stderr lines, and color them if you want. - * `unf(1df)` joins lines with leading spaces to the previous line. - Intended for unfolding HTTP headers, but it should work for most RFC - 822 formats. -* Six simple aggregators for numbers: - * `max(1df)` prints the maximum. - * `mean(1df)` prints the mean. - * `med(1df)` prints the median. - * `min(1df)` prints the minimum. - * `mode(1df)` prints the first encountered mode. - * `tot(1df)` totals the set. -* Three quick-and-dirty HTML tools: - * `htenc(1df)` encodes. - * `htdec(1df)` decodes. - * `htrec(1df)` wraps `a` tags around URLs. -* Two internet message quoting tools: - * `quo(1df)` indents with quoting right angle-brackets. - * `wro(1df)` adds a quote attribution header to its input. -* Six Git-related tools: - * `fgscr(1df)` finds Git repositories in a directory root and scrubs them - with `gscr(1df)`. - * `grc(1df)` quietly tests whether the given directory appears to be a - Git repository with pending changes. - * `gscr(1df)` scrubs Git repositories. - * `isgr(1df)` quietly tests whether the given directory appears to be a - Git repository. - * `jfc(1df)` adds and commits lazily to a Git repository. - * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it - sees any. -* Two time duration functions: - * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. - * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. -* Three pipe interaction tools: - * `pst(1df)` runs an interactive program on data before passing it along - a pipeline. - * `ped(1df)` runs `pst(1df)` with `$EDITOR` or `ed(1)`. - * `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`. -* `ap(1df)` reads arguments for a given command from the standard input, - prompting if appropriate. -* `apf(1df)` prepends arguments to a command with ones read from a file, - intended as a framework for shell wrappers or functions. -* `ax(1df)` evaluates an awk expression given on the command line; this is - intended as a quick way to test how Awk would interpret a given expression. -* `bcq(1df)` runs `bc(1)`, quieting it down if need be. -* `bel(1df)` prints a terminal bell character. -* `bl(1df)` generates a given number of blank lines. -* `bp(1df)` runs `br(1df)` after prompting for an URL. -* `br(1df)` launches `$BROWSER`. -* `ca(1df)` prints a count of its given arguments. -* `cf(1df)` prints a count of entries in a given directory. -* `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as - well. -* `chc(1df)` caches the output of a command. -* `chn(1df)` runs a filter over its input a given number of times. -* `clog(1df)` is a tiny timestamped log system. -* `clrd(1df)` sets up a per-line file read, clearing the screen first. -* `clwr(1df)` sets up a per-line file write, clearing the screen before each - line. -* `csmw(1df)` prints an English list of monospace-quoted words read from the - input. -* `dam(1df)` buffers all its input before emitting it as output. -* `ddup(1df)` removes duplicate lines from unsorted input. -* `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X - CLIPBOARD. -* `dub(1df)` lists the biggest entries in a directory. -* `edda(1df)` provides a means to run `ed(1)` over a set of files preserving - any options, mostly useful for scripts. -* `eds(1df)` edits executable script files in `EDSPATH`, defaulting to - `~/.local/bin`, for personal scripting snippets. -* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. -* `finc(1df)` counts the number of results returned from a set of given - `find(1)` conditions. -* `fnl(1df)` runs a command and saves its output and error into temporary - files, printing their paths and line counts. -* `fnp(1df)` prints the given files to stdout, each with a plaintext heading - with the filename in it. -* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the - script `getmails` in the `getmail` suite, but runs the requests in parallel - and does up to three silent retries using `try(1df)`. -* `grec(1df)` is a more logically-named `grep -c`. -* `gred(1df)` is a more logically-named `grep -v`. -* `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. -* `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will - look for `help` topics. You could use it from the shell too. -* `igex(1df)` wraps around a command to allow you to ignore error conditions - that don't actually worry you, exiting with 0 anyway. -* `ix(1df)` posts its input to the ix.io pastebin. -* `jfp(1df)` prints its input, excluding any shebang on the first line only. -* `loc(1df)` is a quick-search wrapped around `find(1)`. -* `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of - success, - it exits with success or failure. Good for quick tests. -* `mex(1df)` makes given filenames in `$PATH` executable. -* `mi5(1df)` pre-processes a crude but less painful macro expansion file - format into `m4` input. -* `mftl(1df)` finds usable-looking targets in Makefiles. -* `mkcp(1df)` creates a directory and copies preceding arguments into it. -* `mkmv(1df)` creates a directory and moves preceding arguments into it. -* `motd(1df)` shows the system MOTD. -* `mw(1df)` prints alphabetic space-delimited words from the input one per - line. -* `oii(1df)` runs a command on input only if there is any. -* `onl(1df)` crunches input down to one printable line. -* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s - `s_client` subcommand. -* `p(1df)` prints concatenated standard input; `cat(1)` as it should always - have been. -* `pa(1df)` prints its arguments, one per line. -* `pp(1df)` prints the full path of each argument using `$PWD`. -* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. -* `paz(1df)` print its arguments terminated by NULL chars. -* `pit(1df)` runs its input through a pager if its standard output looks like - a terminal. -* `plmu(1df)` retrieves a list of installed modules from - [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in - `~/.plenv/non-cpan-modules`, and updates them all. -* `pwg(1df)` generates just one decent password with `pwgen(1)`. -* `rep(1df)` repeats a command a given number of times. -* `rgl(1df)` is a very crude interactive `grep(1)` loop. -* `shb(1df)` attempts to build shebang lines for scripts from the system - paths. -* `sqs(1df)` chops off query strings from filenames, usually downloads. -* `sshi(1df)` prints human-readable SSH connection details. -* `stex(1df)` strips extensions from filenames. -* `sue(8df)` execs `sudoedit(8)` as the owner of all the file arguments given, - perhaps in cases where you may not necessarily have `root` `sudo(8)` - privileges. -* `swr(1df)` allows you to run commands locally specifying remote files in - `scp(1)`'s HOST:PATH format. -* `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used - to use Taskwarrior, but found it too complex and buggy. -* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and - `new-session` if it doesn't. -* `trs(1df)` replaces strings (not regular expression) in its input. -* `try(1df)` repeats a command up to a given number of times until it - succeeds, only printing error output if all three attempts failed. Good for - tolerating blips or temporary failures in `cron(8)` scripts. -* `umake(1df)` iterates upwards through the directory tree from `$PWD` until - it finds a Makefile for which to run `make(1)` with the given arguments. -* `uts(1df)` gets the current UNIX timestamp in an unorthodox way that should - work on all POSIX-compliant operating systems. -* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. -* `vex(1df)` runs a command and prints `true` or `false` explicitly to - `stdout` based on the exit value. -* `xrbg(1df)` applies the same randomly-selected background to each X screen. -* `xrq(1df)` gets the values of specific resources out of `xrdb -query` - output. - -There's some silly stuff in `install-games`: - -* `aaf(6df)` gets a random [ASCII Art Farts](http://www.asciiartfarts.com/) - comic. -* `acq(6df)` allows you to interrogate AC, the interplanetary computer. -* `aesth(6df)` converts English letters to their fullwidth CJK analogues, for - AESTHETIC PURPOSES. -* `squ(6df)` makes a reduced Latin square out of each line of input. -* `kvlt(6df)` translates input to emulate a style of typing unique to black - metal communities on the internet. -* `philsay(6df)` shows a picture to accompany `pks(6df)` output. -* `pks(6df)` laughs at a randomly selected word. -* `rndn(6df)` implements an esoteric random number generation algorithm. -* `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. -* `rot13(6df)` rotates the Latin letters in its input. -* `xyzzy(6df)` teleports to a marked location on the filesystem. -* `zs(6df)` prepends "z" case-appropriately to every occurrence of "s" in the - text on its standard input. - -Manuals -------- - -The `install-bin` and `install-games` targets install manuals for each script -they install. If you want to use the manuals, you may need to add -`~/.local/share/man` to your `~/.manpath` or `/etc/manpath` configuration, -depending on your system. - -Testing -------- - -You can check that both sets of shell scripts are syntactically correct with -`make check-bash`, `make check-sh`, or `make check` for everything including -the scripts in `bin` and `games`. There's no proper test suite for the actual -functionality (yet). - -If you have [ShellCheck](https://www.shellcheck.net/) and/or -[Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell -script files and Perl files respectively. The files don't need to pass that -check to be installed. - -Known issues ------------- - -See ISSUES.markdown. - -License -------- - -Public domain; see the included `UNLICENSE` file. It's just configuration and -simple scripts, so do whatever you like with it if any of it's useful to you. -If you're feeling generous, please join and/or donate to a free software -advocacy group, and let me know you did it because of this project: - -* [Free Software Foundation](https://www.fsf.org/) -* [Software in the Public Interest](https://www.spi-inc.org/) -* [FreeBSD Foundation](https://www.freebsdfoundation.org/) -* [OpenBSD Foundation](http://www.openbsdfoundation.org/) diff --git a/README.md b/README.md new file mode 100644 index 00000000..f1b254f0 --- /dev/null +++ b/README.md @@ -0,0 +1,603 @@ +Dotfiles (Tom Ryder) +==================== + +This is my personal repository of configuration files and scripts for `$HOME`, +including most of the settings that migrate well between machines. + +This repository began as a simple way to share Vim and tmux configuration, but +over time a lot of scripts and shell configuration have been added, making it +into a personal suite of custom Unix tools. + +Installation +------------ + + $ git clone https://sanctum.geek.nz/code/dotfiles.git ~/.dotfiles + $ cd ~/.dotfiles + $ git submodule init + $ git submodule update + $ make + $ make -n install + $ make install + +For the default `all` target, you'll need a POSIX-fearing userland, including +`make(1)` and `m4(1)`. + +The installation `Makefile` will overwrite things standing in the way of its +installed files without backing them up, so read the output of `make -n +install` before running `make install` to make sure you aren't going to lose +anything unexpected. If you're still not sure, install it in a temporary +directory so you can explore: + + $ tmpdir=$(mktemp -d) + $ make install HOME="$tmpdir" + $ env -i HOME="$tmpdir" TERM="$TERM" "$SHELL" -l + +The default `install` target will install these targets and all their +dependencies. Note that you don't actually have to have any of this except `sh` +installed. + +* `install-bin` +* `install-bin-man` +* `install-curl` +* `install-ex` +* `install-git` +* `install-gnupg` +* `install-less` +* `install-login-shell` +* `install-readline` +* `install-vim` + +The `install-login-shell` looks at your `SHELL` environment variable and tries +to figure out which shell’s configuration files to install, falling back on +`install-sh`. + +The remaining dotfiles can be installed with the other `install-*` targets. Try +`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list. + +Tools +----- + +Configuration is included for: + +* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and + some helper functions: + * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher) + * [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`) + * [Z shell](https://www.zsh.org/) +* [Abook](http://abook.sourceforge.net/) -- curses address book program +* [cURL](https://curl.haxx.se/) -- Command-line tool for transferring data + with URL syntax +* [Dunst](http://knopwob.org/dunst/) -- A lightweight X11 notification daemon + that works with `libnotify` +* `finger(1)` -- User information lookup program +* [Git](https://git-scm.com/) -- Distributed version control system +* [GnuPG](https://www.gnupg.org/) -- GNU Privacy Guard, for private + communication and file encryption +* [GTK+](https://www.gtk.org/) -- GIMP Toolkit, for graphical user interface + elements +* [i3](https://i3wm.org/) -- Tiling window manager +* [less](https://www.gnu.org/software/less/) -- Terminal pager +* [Mutt](http://www.mutt.org/) -- Terminal mail user agent +* [`mysql(1)`](https://linux.die.net/man/1/mysql) -- Command-line MySQL client +* [Ncmpcpp](https://rybczak.net/ncmpcpp/) -- ncurses music player client +* [Newsbeuter](https://www.newsbeuter.org/) -- Terminal RSS/Atom feed reader +* [`psql(1)`](https://linux.die.net/man/1/psql) -- Command-line PostgreSQL + client +* [Perl::Critic](http://perlcritic.com/) -- static source code analysis + engine for Perl +* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl indenter and + reformatter +* [Readline](https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) -- GNU + library for user input used by Bash, MySQL, and others +* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) -- Fork of + the rxvt terminal emulator with Unicode support +* [Subversion](https://subversion.apache.org/) -- Apache Subversion, a + version control system +* [tmux](https://tmux.github.io/) -- Terminal multiplexer similar to GNU + Screen +* [Vim](http://www.vim.org/) -- Vi IMproved, a text editor +* [X11](https://www.x.org/wiki/) -- Windowing system with network + transparency for Unix + +The configurations for shells, GnuPG, Mutt, tmux, and Vim are the most +expansive, and most likely to be of interest. The i3 configuration is mostly +changed to make window switching behave like Vim windows and tmux panes do, and +there's a fair few resources defined for rxvt-unicode. + +### Shell + +My `.profile` and other files in `sh` are written in POSIX shell script, so +they should work in most `sh(1)` implementations. Individual scripts called by +`.profile` are saved in `.profile.d` and iterated on login for ease of +management. Most of these boil down to exporting variables appropriate to the +system and the software it has available. + +Configuration that should be sourced for all POSIX-fearing interactive shells +is kept in `~/.shrc`, with subscripts read from `~/.shrc.d`. There's a shim in +`~/.shinit` to act as `ENV`. I make an effort to target POSIX for my functions +and scripts where I can so that the same files can be loaded for all shells. + +On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, preferably +`ksh93` if it's available. + +As I occasionally have work on very old internal systems, my Bash is written to +work with [any version 2.05a or +newer](http://wiki.bash-hackers.org/scripting/bashchanges). This is why I use +older syntax for certain things such as appending items to arrays: + + array[${#array[@]}]=$item + +Compare this to the much nicer syntax available since 3.1-alpha1, which +actually works for arrays with sparse indices, unlike the above syntax: + + array+=("$item") + +Where I do use features that are only available in versions of Bash newer than +2.05a, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run +after testing `BASH_VERSINFO` appropriately. + +#### Prompt + +A terminal session with my prompt looks something like this: + + ~$ ssh remote + remote:~$ cd .dotfiles + remote:~/.dotfiles(master+!)$ git status + M README.md + M bash/bashrc.d/prompt.bash + A init + remote:~/.dotfiles(master+!)$ foobar + foobar: command not found + remote:~/.dotfiles(master+!)<127>$ sleep 5 & + [1] 28937 + remote:~/.dotfiles(master+!){1}$ + +The hostname is elided if not connected via SSH. The working directory with +tilde abbreviation for `$HOME` is always shown. The rest of the prompt expands +based on context to include these elements in this order: + +* Whether in a Git repository if applicable, and punctuation to show + repository status including reference to upstreams at a glance. Subversion + support can also be enabled (I need it at work), in which case a `git:` or + `svn:` prefix is added appropriately. +* The number of running background jobs, if non-zero. +* The exit status of the last command, if non-zero. + +You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all +do about what you'd expect. + +If you start up Bash, Ksh, or Zsh and it detects that it's not normally your +`$SHELL`, the prompt will display an appropriate prefix. + +This is all managed within the `prompt` function. There's some mildly hacky +logic on `tput` codes included such that it should work correctly for most +common terminals using both `termcap(5)` and `terminfo(5)`, including \*BSD +systems. It's also designed to degrade gracefully for eight-color and no-color +terminals. + +#### Functions + +If a function can be written in POSIX `sh` without too much hackery, I put it +in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include: + +* Four functions for using a "marked" directory, which I find a more + manageable concept than the `pushd`/`popd` directory stack: + * `md()` marks a given (or the current) directory. + * `gd()` goes to the marked directory. + * `pmd()` prints the marked directory. + * `xd()` swaps the current and marked directories. +* Ten other directory management and navigation functions: + * `bd()` changes into a named ancestor of the current directory. + * `gt()` changes into a directory or into a file's directory. + * `lgt()` runs `gt()` on the first result from a `loc(1df)` search. + * `mkcd()` creates a directory and changes into it. + * `pd()` changes to the argument's parent directory. + * `rd()` replaces the first instance of its first argument with its + second argument in `$PWD`, emulating a feature of the Zsh `cd` builtin + that I like. + * `scr()` creates a temporary directory and changes into it. + * `sd()` changes into a sibling of the current directory. + * `ud()` changes into an indexed ancestor of a directory. + * `vr()` tries to change to the root directory of a source control + repository. +* `bc()` silences startup messages from GNU `bc(1)`. +* `ed()` tries to get verbose error messages, a prompt, and a Readline + environment for `ed(1)`. +* `gdb()` silences startup messages from `gdb(1)`. +* `gpg()` quietens `gpg(1)` down for most commands. +* `grep()` tries to apply color and other options good for interactive use if + available. +* `hgrep()` allows searching `$HISTFILE`. +* `keychain()` keeps `$GPG_TTY` up to date if a GnuPG agent is available. +* `ls()` tries to apply color and other options good for interactive use if + available. + * `la()` runs `ls -A` if it can, or `ls -a` otherwise. + * `ll()` runs `ls -Al` if it can, or `ls -al` otherwise. +* `path()` manages the contents of `PATH` conveniently. +* `scp()` tries to detect forgotten hostnames in `scp(1)` command calls. +* `sudo()` forces `-H` for `sudo(8)` calls so that `$HOME` is never + preserved; I hate having `root`-owned files in my home directory. +* `tree()` colorizes GNU `tree(1)` output if possible (without having + `LS_COLORS` set). +* `x()` is a one-key shortcut for `exec startx`. + +There are a few other little tricks defined for other shells providing +non-POSIX features, as compatibility allows: + +* `keep()` stores ad-hoc shell functions and variables (Bash, Korn Shell 93, + Z shell). +* `prompt()` sets up my interactive prompt (Bash, Korn Shell, Z shell). +* `pushd()` adds a default destination of `$HOME` to the `pushd` builtin + (Bash). +* `vared()` allows interactively editing a variable with Readline, emulating + a Zsh function I like by the same name (Bash). +* `ver()` prints the current shell's version information (Bash, Korn Shell, + Z shell). + +#### Completion + +I find the `bash-completion` package a bit too heavy for my tastes, and turn it +off using a stub file installed in `~/.config/bash_completion`. The majority of +the time I just want to complete paths anyway, and this makes for a quicker +startup without a lot of junk functions in my Bash namespace. + +I do make some exceptions with completions defined in `.bash_completion.d` +files, for things I really do get tired of typing repeatedly: + +* Bash builtins: commands, help topics, shell options, variables, etc. +* `find(1)`'s more portable options +* `ftp(1)` hostnames from `~/.netrc` +* `git(1)` subcommands, remotes, branches, tags, and addable files +* `gpg(1)` long options +* `make(1)` targets read from a `Makefile` +* `man(1)` page titles +* `pass(1)` entries +* `ssh(1)` hostnames from `~/.ssh/config` + +For commands that pretty much always want to operate on text, such as text file +or stream editors, I exclude special file types and extensions I know are +binary. I don't actually read the file, so this is more of a heuristic thing, +and sometimes it will get things wrong. + +I also add completions for my own scripts and functions where useful. The +completions are dynamically loaded if Bash is version 4.0 or greater. +Otherwise, they're all loaded on startup. + +#### Korn shell + +These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T +`ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow +prompt if detected. + +#### Zsh + +These are experimental; I do not like Zsh much at the moment. The files started +as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan. + +### GnuPG + +The configuration for GnuPG is intended to follow [RiseUp's OpenPGP best +practices](https://riseup.net/en/security/message-security/openpgp/best-practices). +The configuration file is rebuilt using `mi5(1df)` and `make(1)` because it +requires hard-coding a path to the SKS keyserver certificate authority, and +neither tilde nor `$HOME` expansion works for this. + +### Mutt + +My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where +most unfiltered mail is sent. I use +[Getmail](http://pyropus.ca/software/getmail/), +[maildrop](https://www.courier-mta.org/maildrop/), and +[MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not +included here. I sign whenever I have some indication that the recipient might +be using a PGP implementation, and I encrypt whenever I have a public key +available for them. The GnuPG and S/MIME interfacing is done with +[GPGme](https://www.gnupg.org/related_software/gpgme/), rather than defining +commands for each crypto operation. I wrote [an article about this +setup](https://sanctum.geek.nz/arabesque/linux-crypto-email/) if it sounds +appealing. + +You'll need [Abook](http://abook.sourceforge.net/) installed if you want to use +the `query_command` I have defined, and [msmtp](http://msmtp.sourceforge.net/) +for the `sendmail` command. + +### rxvt-unicode + +I've butchered the URxvt Perl extensions `selection-to-clipboard` and +`selection` into a single `select` extension in `~/.urxvt/ext`, which is the +only extension I define in `~/.Xresources`. + +The included `.Xresources` file assumes that `urxvt` can use 256 colors and +Perl extensions. If you're missing functionality, try changing +`perl-ext-common` to `default`. + +My choice of font is [Ubuntu Mono](http://font.ubuntu.com/), but the file +should allow falling back to the more common [Deja Vu Sans +Mono](https://dejavu-fonts.github.io/). I've found +[Terminus](http://terminus-font.sourceforge.net/) works well too, but bitmap +fonts are not really my cup of tea. The Lohit Kannada font bit is purely to +make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box. + +### tmux + +These are just generally vi-friendly settings, not much out of the ordinary. +Note that the configuration presently uses a hard-coded 256-color colorscheme, +and uses non-login shells, with an attempt to control the environment to stop +shells thinking they have access to an X display. + +The shell scripts in `bin` include `tm(1df)`, a shortcut to make `attach` into +the default command if no arguments are given and sessions do already exist. My +`~/.inputrc` file binds Alt+M to run that, and Tmux in turn binds the same key +combination to detach. + +### Vim + +The majority of the `.vimrc` file is just setting options, with a few mappings. +I try not to deviate too much from the Vim defaults behaviour in terms of +interactive behavior and keybindings. + +The configuration is extensively commented, mostly because I was reading +through it one day and realised I'd forgotten what half of it did. Plugins are +loaded using @tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen). + +Scripts +------- + +Where practical, I make short scripts into POSIX (but not Bourne) `sh(1)`, +`awk(1)`, or `sed(1)` scripts in `~/.local/bin`. I try to use shell functions +only when I actually need to, which tends to be when I need to tinker with the +namespace of the user's current shell. + +Installed by the `install-bin` target: + +* Three SSH-related scripts: + * `sls(1df)` prints hostnames read from a `ssh_config(5)` file. It uses + `slsf(1df)` to read each one. + * `sra(1df)` runs a command on multiple hosts read from `sls(1df)` and + prints output. + * `sta(1df)` runs a command on multiple hosts read from `sls(1df)` and + prints the hostname if the command returns zero. +* Five URL-related shortcut scripts: + * `hurl(1df)` extracts values of `href` attributes of `` tags, sorts + them uniquely, and writes them to `stdout`; it requires + [pup](https://github.com/ericchiang/pup). + * `murl(1df)` converts Markdown documents to HTML with `pandoc(1)` and + runs the output through `hurl(1df)`. + * `urlc(1df)` accepts a list of URLs on `stdin` and writes error messages + to `stderr` if any of the URLs are broken, redirecting, or are insecure + and have working secure versions; requires `curl(1)`. + * `urlh(1df)` prints the values for a given HTTP header from a HEAD + response. + * `urlmt(1df)` prints the MIME type from the `Content-Type` header as + retrieved by `urlh(1df)`. +* Three RFC-related shortcut scripts: + * `rfcf(1df)` fetches ASCII RFCs from the IETF website. + * `rfct(1df)` formats ASCII RFCs. + * `rfcr(1df)` does both, displaying in a pager if appropriate, like a + `man(1)` reader for RFCs. +* Five toy random-number scripts (not for sensitive/dead-serious use): + * `rndi(1df)` gets a random integer within two bounds. + * `rnds(1df)` attempts to get an optional random seed for `rndi(1df)`. + * `rnda(1df)` uses `rndi(1df)` to choose a random argument. + * `rndf(1df)` uses `rnda(1df)` to choose a random file from a directory. + * `rndl(1df)` uses `rndi(1df)` to choose a random line from files. +* Four file formatting scripts: + * `d2u(1df)` converts DOS line endings in files to UNIX ones. + * `u2d(1df)` converts UNIX line endings in files to DOS ones. + * `stbl(1df)` strips a trailing blank line from the files in its + arguments. + * `stws(1df)` strips trailing spaces from the ends of lines of the files + in its arguments. +* Seven stream formatting scripts: + * `sd2u(1df)` converts DOS line endings in streams to UNIX ones. + * `su2d(1df)` converts UNIX line endings in streams to DOS ones. + * `slow(1df)` converts uppercase to lowercase. + * `supp(1df)` converts lowercase to uppercase. + * `tl(1df)` tags input lines with a prefix or suffix, basically a + `sed(1)` shortcut. + * `tlcs(1df)` executes a command and uses `tl(1df)` to tag stdout and + stderr lines, and color them if you want. + * `unf(1df)` joins lines with leading spaces to the previous line. + Intended for unfolding HTTP headers, but it should work for most RFC + 822 formats. +* Six simple aggregators for numbers: + * `max(1df)` prints the maximum. + * `mean(1df)` prints the mean. + * `med(1df)` prints the median. + * `min(1df)` prints the minimum. + * `mode(1df)` prints the first encountered mode. + * `tot(1df)` totals the set. +* Three quick-and-dirty HTML tools: + * `htenc(1df)` encodes. + * `htdec(1df)` decodes. + * `htrec(1df)` wraps `a` tags around URLs. +* Two internet message quoting tools: + * `quo(1df)` indents with quoting right angle-brackets. + * `wro(1df)` adds a quote attribution header to its input. +* Six Git-related tools: + * `fgscr(1df)` finds Git repositories in a directory root and scrubs them + with `gscr(1df)`. + * `grc(1df)` quietly tests whether the given directory appears to be a + Git repository with pending changes. + * `gscr(1df)` scrubs Git repositories. + * `isgr(1df)` quietly tests whether the given directory appears to be a + Git repository. + * `jfc(1df)` adds and commits lazily to a Git repository. + * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it + sees any. +* Two time duration functions: + * `hms(1df)` converts seconds to `hh:mm:ss` or `mm:ss` timestamps. + * `sec(1df)` converts `hh:mm:ss` or `mm:ss` timestamps to seconds. +* Three pipe interaction tools: + * `pst(1df)` runs an interactive program on data before passing it along + a pipeline. + * `ped(1df)` runs `pst(1df)` with `$EDITOR` or `ed(1)`. + * `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`. +* `ap(1df)` reads arguments for a given command from the standard input, + prompting if appropriate. +* `apf(1df)` prepends arguments to a command with ones read from a file, + intended as a framework for shell wrappers or functions. +* `ax(1df)` evaluates an awk expression given on the command line; this is + intended as a quick way to test how Awk would interpret a given expression. +* `bcq(1df)` runs `bc(1)`, quieting it down if need be. +* `bel(1df)` prints a terminal bell character. +* `bl(1df)` generates a given number of blank lines. +* `bp(1df)` runs `br(1df)` after prompting for an URL. +* `br(1df)` launches `$BROWSER`. +* `ca(1df)` prints a count of its given arguments. +* `cf(1df)` prints a count of entries in a given directory. +* `cfr(1df)` does the same as `cf(1df)`, but recurses into subdirectories as + well. +* `chc(1df)` caches the output of a command. +* `chn(1df)` runs a filter over its input a given number of times. +* `clog(1df)` is a tiny timestamped log system. +* `clrd(1df)` sets up a per-line file read, clearing the screen first. +* `clwr(1df)` sets up a per-line file write, clearing the screen before each + line. +* `csmw(1df)` prints an English list of monospace-quoted words read from the + input. +* `dam(1df)` buffers all its input before emitting it as output. +* `ddup(1df)` removes duplicate lines from unsorted input. +* `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X + CLIPBOARD. +* `dub(1df)` lists the biggest entries in a directory. +* `edda(1df)` provides a means to run `ed(1)` over a set of files preserving + any options, mostly useful for scripts. +* `eds(1df)` edits executable script files in `EDSPATH`, defaulting to + `~/.local/bin`, for personal scripting snippets. +* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. +* `finc(1df)` counts the number of results returned from a set of given + `find(1)` conditions. +* `fnl(1df)` runs a command and saves its output and error into temporary + files, printing their paths and line counts. +* `fnp(1df)` prints the given files to stdout, each with a plaintext heading + with the filename in it. +* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the + script `getmails` in the `getmail` suite, but runs the requests in parallel + and does up to three silent retries using `try(1df)`. +* `grec(1df)` is a more logically-named `grep -c`. +* `gred(1df)` is a more logically-named `grep -v`. +* `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`. +* `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will + look for `help` topics. You could use it from the shell too. +* `igex(1df)` wraps around a command to allow you to ignore error conditions + that don't actually worry you, exiting with 0 anyway. +* `ix(1df)` posts its input to the ix.io pastebin. +* `jfp(1df)` prints its input, excluding any shebang on the first line only. +* `loc(1df)` is a quick-search wrapped around `find(1)`. +* `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of + success, + it exits with success or failure. Good for quick tests. +* `mex(1df)` makes given filenames in `$PATH` executable. +* `mi5(1df)` pre-processes a crude but less painful macro expansion file + format into `m4` input. +* `mftl(1df)` finds usable-looking targets in Makefiles. +* `mkcp(1df)` creates a directory and copies preceding arguments into it. +* `mkmv(1df)` creates a directory and moves preceding arguments into it. +* `motd(1df)` shows the system MOTD. +* `mw(1df)` prints alphabetic space-delimited words from the input one per + line. +* `oii(1df)` runs a command on input only if there is any. +* `onl(1df)` crunches input down to one printable line. +* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s + `s_client` subcommand. +* `p(1df)` prints concatenated standard input; `cat(1)` as it should always + have been. +* `pa(1df)` prints its arguments, one per line. +* `pp(1df)` prints the full path of each argument using `$PWD`. +* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. +* `paz(1df)` print its arguments terminated by NULL chars. +* `pit(1df)` runs its input through a pager if its standard output looks like + a terminal. +* `plmu(1df)` retrieves a list of installed modules from + [`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in + `~/.plenv/non-cpan-modules`, and updates them all. +* `pwg(1df)` generates just one decent password with `pwgen(1)`. +* `rep(1df)` repeats a command a given number of times. +* `rgl(1df)` is a very crude interactive `grep(1)` loop. +* `shb(1df)` attempts to build shebang lines for scripts from the system + paths. +* `sqs(1df)` chops off query strings from filenames, usually downloads. +* `sshi(1df)` prints human-readable SSH connection details. +* `stex(1df)` strips extensions from filenames. +* `sue(8df)` execs `sudoedit(8)` as the owner of all the file arguments given, + perhaps in cases where you may not necessarily have `root` `sudo(8)` + privileges. +* `swr(1df)` allows you to run commands locally specifying remote files in + `scp(1)`'s HOST:PATH format. +* `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used + to use Taskwarrior, but found it too complex and buggy. +* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and + `new-session` if it doesn't. +* `trs(1df)` replaces strings (not regular expression) in its input. +* `try(1df)` repeats a command up to a given number of times until it + succeeds, only printing error output if all three attempts failed. Good for + tolerating blips or temporary failures in `cron(8)` scripts. +* `umake(1df)` iterates upwards through the directory tree from `$PWD` until + it finds a Makefile for which to run `make(1)` with the given arguments. +* `uts(1df)` gets the current UNIX timestamp in an unorthodox way that should + work on all POSIX-compliant operating systems. +* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`. +* `vex(1df)` runs a command and prints `true` or `false` explicitly to + `stdout` based on the exit value. +* `xrbg(1df)` applies the same randomly-selected background to each X screen. +* `xrq(1df)` gets the values of specific resources out of `xrdb -query` + output. + +There's some silly stuff in `install-games`: + +* `aaf(6df)` gets a random [ASCII Art Farts](http://www.asciiartfarts.com/) + comic. +* `acq(6df)` allows you to interrogate AC, the interplanetary computer. +* `aesth(6df)` converts English letters to their fullwidth CJK analogues, for + AESTHETIC PURPOSES. +* `squ(6df)` makes a reduced Latin square out of each line of input. +* `kvlt(6df)` translates input to emulate a style of typing unique to black + metal communities on the internet. +* `philsay(6df)` shows a picture to accompany `pks(6df)` output. +* `pks(6df)` laughs at a randomly selected word. +* `rndn(6df)` implements an esoteric random number generation algorithm. +* `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text. +* `rot13(6df)` rotates the Latin letters in its input. +* `xyzzy(6df)` teleports to a marked location on the filesystem. +* `zs(6df)` prepends "z" case-appropriately to every occurrence of "s" in the + text on its standard input. + +Manuals +------- + +The `install-bin` and `install-games` targets install manuals for each script +they install. If you want to use the manuals, you may need to add +`~/.local/share/man` to your `~/.manpath` or `/etc/manpath` configuration, +depending on your system. + +Testing +------- + +You can check that both sets of shell scripts are syntactically correct with +`make check-bash`, `make check-sh`, or `make check` for everything including +the scripts in `bin` and `games`. There's no proper test suite for the actual +functionality (yet). + +If you have [ShellCheck](https://www.shellcheck.net/) and/or +[Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell +script files and Perl files respectively. The files don't need to pass that +check to be installed. + +Known issues +------------ + +See ISSUES.markdown. + +License +------- + +Public domain; see the included `UNLICENSE` file. It's just configuration and +simple scripts, so do whatever you like with it if any of it's useful to you. +If you're feeling generous, please join and/or donate to a free software +advocacy group, and let me know you did it because of this project: + +* [Free Software Foundation](https://www.fsf.org/) +* [Software in the Public Interest](https://www.spi-inc.org/) +* [FreeBSD Foundation](https://www.freebsdfoundation.org/) +* [OpenBSD Foundation](http://www.openbsdfoundation.org/) diff --git a/TABS.md b/TABS.md new file mode 100644 index 00000000..feeee631 --- /dev/null +++ b/TABS.md @@ -0,0 +1,26 @@ +Spaces to tabs +============== + +If you prefer tabs to spaces, the following recipe seems to convert everything +pretty nicely: + + $ find . -name .git -prune -o -name vim -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t4 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + + $ find vim -name bundle -prune -o -type f \ + -exec sh -c \ + 'for f;do unexpand -t2 "$f">"$f".tmp;mv "$f" "$f".tmp;done' \ + _ {} + + +If you have GNU unexpand(1) and can add `--first-only` to each of those calls, +the results seem perfect. + +You can configure Vim to accommodate this by removing the settings for: + +* `expandtab` +* `shiftround` +* `shiftwidth` +* `smarttab` +* `softtabstop` diff --git a/man/man1/murl.1df b/man/man1/murl.1df index f022152b..088158b0 100644 --- a/man/man1/murl.1df +++ b/man/man1/murl.1df @@ -4,7 +4,7 @@ \- convert Markdown to HTML with pandoc(1) and extract URLs from it with hurl(1df) .SH SYNOPSIS .B murl -README.markdown +README.md .br .B murl page1.md page2.md diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index 831af06d..5538fdd2 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -209,7 +209,7 @@ A terminal session with my prompt looks something like this: ~$\ ssh\ remote remote:~$\ cd\ .dotfiles remote:~/.dotfiles(master+!)$\ git\ status -\ M\ README.markdown +\ M\ README.md M\ \ bash/bashrc.d/prompt.bash A\ \ init remote:~/.dotfiles(master+!)$\ foobar diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index d58c64f9..7e843cc7 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -33,6 +33,16 @@ ls() { [ -e "$HOME"/.cache/sh/opt/ls/time-style ] && set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" + # If the operating system is FreeBSD, there are some specific options we + # can add that might mean different things to e.g. GNU ls(1) + case $OS in + FreeBSD) + # -D: Timestamp format + # -G: Use color + set -- -D '%Y-%m-%d %H:%M:%S' -G "$@" + ;; + esac + # Run ls(1) with the concluded arguments command ls "$@" } -- cgit v1.2.3