Lightweight, cross-platform C-backed Lua bindings for terminal detection and terminal size inspection.
Check out the documentation for guides and examples.
- TTY Verification: Check if a Lua file handle, standard stream, or raw file descriptor is interactive.
- Window Dimension Query: Retrieve the current terminal width (columns) and height(rows) dynamically.
- Multiple Lua Versions: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and 5.5.
- Cross-Platform: Works consistently across Windows, macOS, and Linux.
luarocks install ttylocal 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