From 76594427ff4b991b4695847d2c3d0d110932c0c5 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 12 Dec 2019 13:00:03 -0600 Subject: [PATCH] Pipelines! --- bin/linewise | 10 ++++++++++ bin/pipeline | 23 ++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100755 bin/linewise diff --git a/bin/linewise b/bin/linewise new file mode 100755 index 0000000..50711ad --- /dev/null +++ b/bin/linewise @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +if [[ ! -z "${1+x}" ]]; then + while read r; do + <<< "${r}" "$1" + done +else + echo "No reader program provided." + exit 1 +fi diff --git a/bin/pipeline b/bin/pipeline index b39ea47..0f589f5 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -25,16 +25,21 @@ if [[ ! -e "$transform" ]]; then fi in="$td/in" +if [[ ! -z "${1+x}" ]]; then + in="${1}"; shift +fi out="$td/out" +if [[ ! -z "${1+x}" ]]; then + out="${1}"; shift +fi chmod +x "$transform" echo "Hello World" > "$in" -touch /tmp/ll.log -FSW_DEBUG=1 fswi \ +fswi \ "bash -c '< \"$in\" \"$transform\" > \"$out\"'" \ 'in$|transform$' \ - "$td" "$pdir" \ &> /tmp/ll.log & + "$td" "$pdir" &> /dev/null & watcher="$!" if [[ -z ${cleanup_trap+x} ]]; then @@ -43,13 +48,17 @@ else trap "${cleanup_trap}; kill \"$watcher\"" EXIT fi +job="call jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'on_stdout':{j,d,e->execute('checktime')}})" +echo "$job" + +# this will only autosave (and therefore autoreload) for the out buffer (since +# it was opened last) - autosaving (and therefore autorunning) is potentially +# very scary nvim \ --cmd 'set shm+=atIWF' \ --cmd 'set shm-=Oo' \ -o "$in" "$transform" "$out" \ --cmd 'set autoread' \ --cmd 'set updatetime=250' \ - --cmd 'autocmd CursorHold,CursorHoldI silent write' - --cmd 'autocmd BufWrite * sleep 500m | checktime' - -# TODO: vim set autoread + --cmd 'autocmd CursorHold,CursorHoldI silent write' \ + --cmd "$(<<< "$job" tr "'" '"')"