Terminal width: REPL and/or script

Can I get the terminal width from julia in a REPL/script agnostic manner?

In the REPL, this works:

terminalWidth = REPL.Terminals.width(Base.active_repl.t)

although maybe it’s not the best way to do it.

When running a script, however, active_repl is not defined.

You can try displaysize(stdout).

7 Likes

Thanks! If anyone else cares it’s the second component, i.e.

displaysize(stdout)[2]
2 Likes