dotfiles

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

commit 49ef973cf441e8934e5efa4a6a3f0e3818ff5340 (patch)
parent 1243b110b7779a6b20da225bde3ff57a296cc6b5
Author: Alex Karle <alex@alexkarle.com>
Date:   Fri,  9 Sep 2022 22:13:52 -0400

acme: Update `Note` to append, add GitHub PR plumbing

Fortunately, I'm not a heavy GitHub Issues user so '#123' always means
"PR #123". Writing a plumbing script to open them was pretty easy!

Diffstat:
Mbin/acme-scripts/Note | 11++++++++++-
Abin/openpr | 22++++++++++++++++++++++
Mlib/plumbing | 5+++++
3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/bin/acme-scripts/Note b/bin/acme-scripts/Note @@ -1,3 +1,12 @@ #!/bin/sh name=${1:-scratch-$(/usr/bin/date +%F).txt} -(date; echo) | plumb -i -d edit -a "action=showdata filename=$HOME/notes/$name" + +file=$HOME/notes/$name + +if [ -e $file ]; then + # Just open the existing file! + plumb -d edit $file +else + # Open in a buffer but don't save to the file yet -- will likely rename! + (date; echo) | plumb -i -d edit -a "action=showdata filename=$HOME/notes/$name" +fi diff --git a/bin/openpr b/bin/openpr @@ -0,0 +1,22 @@ +#!/bin/sh +# openpr -- open a pr from GitHub +set -e +die() { + echo "$*" 1>&2 + exit 1 +} + +[ -z "$1" ] && logger "openpr-die" && die "usage: openpr NUM" +logger "openpr: $1" + +logger "openpr-wdir: $wdir" +logger `pwd` +num=${1###} +logger "openpr-num: $num" + +url=$(git remote get-url origin | sed -e 's/^git@//' -e 's@:@/@' -e 's/\.git$//') + +logger "openpr-url: $url" +[ -z "$url" ] && die "not in a repo?" + +${BROWSER:-firefox} "https://$url/pull/$num" diff --git a/lib/plumbing b/lib/plumbing @@ -36,5 +36,10 @@ 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'''' +# #PR numbers to openpr (for work) +type is text +data matches '#([0-9]+)' +plumb start rc -c 'cd '$wdir' && openpr '$1' + editor = acme include basic