From 5474e4ca0479b523210ef5459b5b09c5f73d4a08 Mon Sep 17 00:00:00 2001 From: Adolfo Perez Alvarez Date: Sat, 9 Mar 2024 15:57:32 +0100 Subject: [PATCH] Make miscutils/rr a ksh function Making this a function available through FPATH allows me to use `rr` with aliases and funcions defined only for interactive shells. --- Makefile | 2 +- rr | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 rr diff --git a/Makefile b/Makefile index 8ea0be5..a6c1d66 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BINDIR?=${HOME}/.local/bin cmds=g kpick -fns=diralias j jmod nsalias +fns=diralias j jmod nsalias rr install: install ${fns} $${FPATH:?FPATH not defined} install ${cmds} ${BINDIR} diff --git a/rr b/rr new file mode 100644 index 0000000..1880527 --- /dev/null +++ b/rr @@ -0,0 +1,19 @@ +function rr +{ + (( $# == 0 )) && print "usage: $0 command ..." && return 64 + typeset tmp1=$(mktemp $0.XXXXXXXXXX) + typeset tmp2=$(mktemp $0.XXXXXXXXXX) + trap "rm $tmp1 $tmp2; exit 0" 0 1 2 15 + while eval "$@" >$tmp2 + do + if ! diff $tmp1 $tmp2 + then + cp $tmp2 $tmp1 + else + print -n "." + fi + sleep 2 + done + print + rm $tmp1 $tmp2 +}