Pipelines!

This commit is contained in:
Daniel Flanagan 2019-12-12 13:00:03 -06:00
parent 972508e74d
commit 76594427ff
2 changed files with 26 additions and 7 deletions

10
bin/linewise Executable file
View File

@ -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

View File

@ -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 <buffer> silent write'
--cmd 'autocmd BufWrite * sleep 500m | checktime'
# TODO: vim set autoread
--cmd 'autocmd CursorHold,CursorHoldI <buffer> silent write' \
--cmd "$(<<< "$job" tr "'" '"')"