diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-04-13 18:40:35 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-04-14 08:46:54 +0000 |
| commit | 1a8debe87762072b3a63b769aa515ebf63b4c70d (patch) | |
| tree | 33b42866307d11d2c0878b23e0ec0bb8925d3fcc /bin | |
| parent | spec base.match __tostring (diff) | |
| download | alive-1a8debe87762072b3a63b769aa515ebf63b4c70d.tar.gz alive-1a8debe87762072b3a63b769aa515ebf63b4c70d.zip | |
move into proper Lua module (`alv`)
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/alv | 23 | ||||
| -rw-r--r-- | bin/copilot.bat | 6 | ||||
| -rwxr-xr-x | bin/copilot.sh | 23 |
3 files changed, 52 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#!/usr/bin/env moon +import Copilot, Logger from require 'alv' +import sleep from require 'system' + +arguments, key = {} +for a in *arg + if match = a\match '^%-%-(.*)' + key = match + arguments[key] = true + elseif key + arguments[key] = a + key = nil + else + table.insert arguments, a + +Logger.init arguments.log + +assert arguments[1], "no filename given" +copilot = Copilot arguments[1] + +while true + copilot\tick! + sleep 1 / 1000 diff --git a/bin/copilot.bat b/bin/copilot.bat new file mode 100644 index 0000000..58c1bf9 --- /dev/null +++ b/bin/copilot.bat @@ -0,0 +1,6 @@ +@echo off +setlocal +set PATH=%PATH%;%~dp0\lua\lua\bin +set LUA_PATH=%LUA_PATH%;%~dp0\?.lua;%~dp0\alive\?\init.lua +moon %~dp0\init.moon %* +exit /b %ERRORLEVEL% diff --git a/bin/copilot.sh b/bin/copilot.sh new file mode 100755 index 0000000..68e8ebd --- /dev/null +++ b/bin/copilot.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +tmpdir=$(mktemp -d) +trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP + +ARGS="$@" +FIFO=$tmpdir/fifo +CONF=$tmpdir/conf +LIBDIR=$(dirname $0) +LUA_PATH="$LIBDIR/?.lua;$LIBDIR/?/init.lua;$LUA_PATH" + +cat > "$CONF" << 'EOF' +split +focus +screen -t evaltime sh -c 'tty > "$FIFO"; read done < "$FIFO"' +focus +screen -t runtime sh -c 'read tty < "$FIFO"; moon "$LIBDIR/alv/copilot.moon" $ARGS 2> "$tty"; echo "[press enter to exit]"; read prompt; echo done > "$FIFO"' +EOF + +mkfifo "$FIFO" +export FIFO ARGS LIBDIR LUA_PATH +exec screen -mc "$CONF" |
