As a simple example, I want to write a CLI script which can print =
across the entire width of the terminal window.
#!/usr/bin/env php
<?php
echo str_repeat('=', ???);
or
#!/usr/bin/env python
print '=' * ???
or
#!/usr/bin/env bash
x=0
while [ $x -lt ??? ]; do echo -n '='; let x=$x+1 done; echo
To do this in Windows CLI environment, the best way I can find is to use the mode command and parse the output.
I hope it's useful!
NOTE: The height returned is the number of lines in the buffer, it is not the number of lines that are visible within the window. Any better options out there?
tput cols
tells you the number of columns.tput lines
tells you the number of rows.