D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Terminal size?

 

On Wed, 29 Apr 2009 18:53:47 +0100 (BST)
Gordon Henderson wrote:

> On Wed, 29 Apr 2009, Tom Potts wrote:
> 
> > On Wednesday 29 April 2009 16:39, Grant Sewell wrote:
> >> Hi all,
> >>
> >> Is there a way to find out the size (WxH) of the current
> >> terminal/console session from within BASH?  I am trying to write a
> >> menu system using dialog for the "interface", and I would like to
> >> set the position and sizes of the various dialogues nicely.
> >>
> >> Cheers.
> >> Grant. :)
> > $LINES $COLUMNS
> 
> Not present in all shells, but as you are using bash, it mostly
> works..

Thanks for the heads-up.  The menu is the user's 'shell' (ie the last
entry in that user's /etc/passwd entry is this script), but since it's
a bash script it should work OK.

> > I think you can set it using stty but catching problems is a
> > problem. try ncurses - I really should write a WYSIWIG form editor
> > for ncurses in ncurses.. !

Cheers Tom, I would look into ncurses, but I haven't found a nice way
of using it in bash yet... maybe I'm just not looking hard enough.

I will most likely convert the menu to Python at some point (when there
are 36hrs/day I imagine) but the requirement is to get it up and
running quickly, so bash it is.

> You can also get it with stty:
> 
>    stty size
> 
>    gordon @ unicorn: stty size
>    76 100
> 
> Gordon

Excellent!  Cheers for that.  Works a treat.

Grant.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html