Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.58 KB

File metadata and controls

44 lines (33 loc) · 1.58 KB

tty

Test LuaRocks Lua Versions Platform License

Lightweight, cross-platform C-backed Lua bindings for terminal detection and terminal size inspection.

Check out the documentation for guides and examples.

✨ Features

  • 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.

📦 Installation

luarocks install tty

🚀 Usage

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