term-size
exposes a platform-independent API to get the size of the current terminal window.
On platform where the native library is available, term-size
doesn't require forking a new
process to get the terminal size. When the native library is unavailable, term-size
uses
tput
to get the size of the current terminal.
term-size
is available on Maven Central. Add the following to your build:
libraryDependencies += "com.github.duhemm" %% "term-size" % "<version>"
The latest version available is
object Main {
def main(args: Array[String]): Unit = {
val size = term.TermSize.size()
println(s"Current terminal size: ${size.rows} rows and ${size.cols} columns.")
}
}
Operating system / CPU architecture | x86_64 | x86_32 | ARM |
---|---|---|---|
MacOS | π | β | β |
Linux | π | β | β |
Windows | π | β | β |
π: Available, native
β
: Available, via Tput
β: Unavailable