2023-04-23 Hiding in the clear
Sun 23 Apr 2023 08:35:40 PM CDT
Have you ever needed to bang out a post, but didn't want an other who in all other ways significant asking gobs of question?
Meet a little Lua script I wrote and named "eat", because it eats typed characters - by which I mean they never appear on the screen, screen remains blank, sure you might have to explain the sound of mad typing if you're good at it, but other than that you've no "'splainin'" to do:
#! /usr/bin/env lua os.execute('clear') os.execute("stty -icanon") -- put TTY in raw mode local s = '' while true do local c = io.read(1) if c == '\004' then break else s = s .. c os.execute('clear') end end os.execute("stty icanon") -- at end of program, put TTY back to normal mode local handle = io.open('z', 'w') handle:write(s) handle:close()
Run it, type away, eventually hit ctrl-d to end the session. The text winds up in a file named 'z' in the current directory.
Simple. Safe. Gulorious.....