[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting screen size into the env?
From: |
Juergen Weigert |
Subject: |
Re: Getting screen size into the env? |
Date: |
Mon, 11 Aug 2008 20:53:44 +0200 |
User-agent: |
Mutt/1.5.7i |
On Aug 07, 08 12:18:53 -0400, Mark Eichin wrote:
> "Thomas Adam" <address@hidden> writes:
>
> > 2008/8/7 Micah Cowan <address@hidden>:
> >> However, if you use bash, it will set _shell_ variables, COLUMNS and
> >> LINES, automatically. This isn't something that screen does, but bash.
> >> Bash does _not_ export these by default, however; you'll need to do
> >>
> >> $ export COLUMNS LINES
This may work, if the screen does not get resized while it is running.
I have my screen session inside an xterm, and resize frequently.
environment variables would still reflect the old value after a resize.
> >
> > Rather unportably between Unixes:
> >
> > eval $(resize)
>
> resize requires having a terminal type that actually does xterm-style
> answerback, which as at best a "maybe".
When run from within screen, we guarantee you that xterm-style
answerback is honored. Screen is an xterm-compatible device.
> What you *really* want is the output of stty:
> $ stty -a |grep rows
> speed 38400 baud; rows 56; columns 144; line = 0;
>
> because it's a property of the tty, and changed there - putting the
> values in the environment is an old and not-really-workable hack.
The best thing to do, is to keep them all in sync:
- Measure the real dimension like resize does,
- Then check what the PTY thinks, and run stty to set cols and rows,
in case a SIGWINCH got lost.
- Then check shell variables COLUMNS and LINES, and fire SIGWINCH to the
shell, if they do not match. The shell will fetch them from the PTY
then.
--
o \ Juergen Weigert unix-software __/ _=======.=======_
<V> | address@hidden creator __/ _---|____________\/
\ | 0179/2069677 __/ (____/ /\
(/) | ____________________________/ _/ \_ vim:set sw=2 wm=8