tags:

views:

657

answers:

3

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
+2  A: 

tput can tell you columns. I'm not sure about height, though.
tput cols man page.

TonyUser
'tput lines' seems to work.
too much php
+2  A: 
yes = | head -n$(($(tput lines) * $COLUMNS)) | tr -d '\n'
pixelbeat
+1  A: 

In bash, the $LINES and $COLUMNS environmental variables should be able to do the trick. The will be set automatically upon any change in the terminal size. (i.e. the SIGWINCH signal)

David Dean