Skip to content

tty ​

LuaRocksLua VersionsPlatformLicense

tty provides lightweight, cross-platform C-backed Lua bindings for terminal detection and terminal size inspection.

✨ Features ​

  • TTY Verification: Check if a Lua file handle (like io.stdout, io.stdin), standard stream, or raw file descriptor is interactive.
  • Window Dimension Query: Retrieve the current width (columns) and height (rows) of the active terminal dynamically.
  • Multiple Lua Versions: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and 5.5.

📦 Installation ​

sh
luarocks install tty

🚀 Usage ​

lua
local tty = require "tty"

-- Check if standard output is a TTY
if tty.isatty(io.stdout) then
  local rows, cols = tty.size()
  print(string.format("Terminal size: %dx%d", cols, rows))
else
  print("Output is redirected")
end