I'd like to know my current xterms' window sizes. I'm using Cygwin. Is there a command to just print that to the prompt?

link|improve this question

feedback

3 Answers

up vote 3 down vote accepted

If it's an actual xterm, the following should work (tested on a PuTTY session, since I don't have Cygwin installed at the moment):

stty -a | sed 's/;/\n/g' | grep rows | awk '{print $2}'

In my case, that returned 24. Similarly,

stty -a | sed 's/;/\n/g' | grep columns | awk '{print $2}'

returned 80.

All the commands involved should be standard in Cygwin or any UNIX-like system. I'd be very surprised if they didn't work equally well in a Cygwin console prompt.

link|improve this answer
This works in Cygwin's xterm :) – Matthew Read Jul 6 '11 at 1:06
thank you this works great! – Robb Jul 6 '11 at 13:45
feedback

Gives you the size in characters:

 echo $COLUMNS " " $LINES

Whether it works in cygwin? You tell us!

link|improve this answer
This doesn't work in Cygwin's xterm :( – Matthew Read Jul 6 '11 at 1:05
feedback

Install the ncurses package, then execute

tput cols; tput lines
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.