dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | README | LICENSE

commit b3e80152c8dbe9ea641ff4754af271fb57c7d21b (patch)
parent 34aea3ff6f89b0ebc3f66ab943a19f5f9aa01e1a
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 30 Aug 2022 23:29:08 -0400

acme: Add acme startup script and helper utils

I've been mucking around with acme(1) again. Once you feel the power
of the 3rd button plumb(7) it's just so hard to go back!

This patch is my most serious attempt yet at integrating acme into my
everyday work. It adds a startup script with the right env vars set so
that other tools play nicely with the environment (i.e. inside a win(1)
shell) and it adds several small helper tools to make working with git
work well (it's the *perfect* plumber use case!).

Of course, the plumber needs to be updated to understand git sha's, so
I'm checking in the plumbing rules I'm using too!

Diffstat:
Abin/a | 9+++++++++
Abin/acme-scripts/e | 3+++
Abin/acme-scripts/ga | 2++
Abin/acme-scripts/gbl | 9+++++++++
Abin/acme-scripts/gc | 2++
Abin/acme-scripts/gca | 2++
Abin/acme-scripts/gd | 2++
Rbin/gg -> bin/acme-scripts/gg | 0
Abin/acme-scripts/gl | 5+++++
Abin/acme-scripts/glo | 2++
Abin/acme-scripts/gls | 2++
Abin/acme-scripts/gs | 2++
Abin/acme-scripts/i+ | 2++
Abin/acme-scripts/i- | 2++
Abin/acme-scripts/jq | 3+++
Abin/acme-scripts/nas | 15+++++++++++++++
Alib/plumbing | 40++++++++++++++++++++++++++++++++++++++++
17 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/bin/a b/bin/a @@ -0,0 +1,9 @@ +#!/bin/sh +export PAGER=nobs +export EDITOR=editinacme # from 9fans.net/go +unset VISUAL +export TERM=dumb +export NO_COLOR=1 +export SHELL=/usr/lib/plan9/bin/rc +export PATH="$(dirname "$(readlink -f "$0")")/acme-scripts:$PATH" +acme -f /mnt/font/GoMono/12a/font -a "$@" diff --git a/bin/acme-scripts/e b/bin/acme-scripts/e @@ -0,0 +1,3 @@ +#!/bin/sh +# e -- shortcut for editinacme +exec editinacme "$@" diff --git a/bin/acme-scripts/ga b/bin/acme-scripts/ga @@ -0,0 +1,2 @@ +#!/bin/sh +exec git add "$@" diff --git a/bin/acme-scripts/gbl b/bin/acme-scripts/gbl @@ -0,0 +1,9 @@ +#!/bin/sh +# git blame, in acme! +if [ -z "$1" ]; then + echo "usage: gbl FILE" 1>&2 + exit 1 +fi + +file=$1 +git blame --date="short" "$file" | plumb -i -d edit -a "action=showdata filename=$file:BLAME" diff --git a/bin/acme-scripts/gc b/bin/acme-scripts/gc @@ -0,0 +1,2 @@ +#!/bin/sh +exec git commit "$@" diff --git a/bin/acme-scripts/gca b/bin/acme-scripts/gca @@ -0,0 +1,2 @@ +#!/bin/sh +exec git commit -a "$@" diff --git a/bin/acme-scripts/gd b/bin/acme-scripts/gd @@ -0,0 +1,2 @@ +#!/bin/sh +exec git diff "$@" diff --git a/bin/gg b/bin/acme-scripts/gg diff --git a/bin/acme-scripts/gl b/bin/acme-scripts/gl @@ -0,0 +1,5 @@ +#!/bin/sh +# git-log, but piped through plumb so that it: +# 1. doesn't scroll to the end +# 2. has the proper "filename" so that plumbing SHA's works +git log "$@" | plumb -i -d edit -a "action=showdata filename=/$(pwd)/git-log" diff --git a/bin/acme-scripts/glo b/bin/acme-scripts/glo @@ -0,0 +1,2 @@ +#!/bin/sh +exec gl --oneline diff --git a/bin/acme-scripts/gls b/bin/acme-scripts/gls @@ -0,0 +1,2 @@ +#!/bin/sh +exec gl --stat diff --git a/bin/acme-scripts/gs b/bin/acme-scripts/gs @@ -0,0 +1,2 @@ +#!/bin/sh +exec git status "$@" diff --git a/bin/acme-scripts/i+ b/bin/acme-scripts/i+ @@ -0,0 +1,2 @@ +#!/bin/sh +sed 's/^/ /' "$@" diff --git a/bin/acme-scripts/i- b/bin/acme-scripts/i- @@ -0,0 +1,2 @@ +#!/bin/sh +sed 's/^ //' diff --git a/bin/acme-scripts/jq b/bin/acme-scripts/jq @@ -0,0 +1,3 @@ +#!/bin/sh +# monochrome jq +exec /usr/bin/jq -M "$@" diff --git a/bin/acme-scripts/nas b/bin/acme-scripts/nas @@ -0,0 +1,14 @@ +#!/bin/sh +# nas -- new acme script +DIR=$(dirname "$(readlink -f "$0")") + +if [ -z "$1" ]; then + echo "usage: nas FILE" 1>&2 + exit 1 +fi + +file="$DIR/$1" + +touch "$file" +chmod +x "$file" +B "$file" +\ No newline at end of file diff --git a/lib/plumbing b/lib/plumbing @@ -0,0 +1,40 @@ +# plan9 plumbing rules +# +# currently in use in acme(1) on Linux via plan9port. +# +# see /usr/lib/plan9/plumb, plumb(7), and regexp(7) +# to update: cat $home/lib/plumbing | 9p write plumb/rules + +# urls go to web browser +type is text +data matches '(https?|file)://[a-zA-Z0-9_@\-]+([.:][a-zA-Z0-9_@\-]+)*/?[a-zA-Z0-9_?,%#~&/\-+=]+([:.][a-zA-Z0-9_?,%#~&/\-+=]+)*' +plumb to web +plumb start chromium $0 + +# image files go to feh +type is text +data matches '[a-zA-Z0-9_\-./]+' +data matches '([a-zA-Z0-9_\-./]+)\.(jpe?g|JPE?G|gif|GIF|png|PNG)' +arg isfile $0 +plumb to image +plumb start feh $file + +# pdf files go to chromium +type is text +data matches '[a-zA-Z0-9_\-./]+' +data matches '([a-zA-Z0-9_\-./]+)\.(pdf|PDF)' +arg isfile $0 +plumb start chromium $file + +# man pages use system man (but searches plan9 too!) +type is text +data matches '([a-zA-Z¡-￿0-9_\-./]+)\(([1-8])\)' +plumb start rc -c '/usr/bin/man -m /usr/lib/plan9/man '$2' '$1' >[2=1] | nobs | plumb -i -d edit -a ''action=showdata filename=/man/'$1'('$2')''' + +# sha1's to git +type is text +data matches '[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+' +plumb start rc -c 'git -C '$wdir' show '$0' >[2=1] | plumb -i -d edit -a ''action=showdata filename=/'$wdir'/'$0'''' + +editor = acme +include basic