Small cross-platform Lua bindings for terminal inspection.
Supports Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
luarocks install ttyCheck whether a file descriptor or Lua file handle is attached to a terminal.
local tty = require "tty"
print(tty.isTTY())
print(tty.isTTY(2))
print(tty.isTTY(io.stdout))Get the terminal size for stdout, or for a specific file descriptor or Lua file handle.
local rows, cols = tty.size()
print(("terminal: %dx%d"):format(cols, rows))