PDA

View Full Version : Mac SSH Q


cwd
01-01-2007, 10:18 PM
I'm sure this is simple, but I've had ssh access on other Linux boxes (that I didn't set up) where bash figured out the number of rows and columns my terminal window could display and set the environment on the fly.

I can't figure out how this is accomplished. Any hints are appreciated.

Thanks

timharig
01-02-2007, 12:09 AM
Dynamic terminal resizing is handled by curses or usually in Linux's case ncurses. When you resize a terminal the SIGWINCH signal is sent to your program to tell it the terminal screen has changed. The program you are using must catch the SIGWINCH signal, find the new terminal size, and redraw the screen. Some programs do not provide this functionality and SIGWINCH is caught by curses itself. If this is the case then the program does not know that the screen has been resized until it calls one of the getch functions for input.

To figure out what is not working for you I need more information. First I need to know which applications are not properly resizing for you. Second I need to know what your terminal is set at. This can be found with the following command "echo $TERM". Then, I need to see your /etc/termcap file. I need to know what terminal emulation program you are using and if possible what kind of terminal it emulates.

Most likely any problems you are experiencing has to do with the fact that the TERM variable is set wrong or that the terminal you are using is not listed in your termcap database.

Also, just to be sure, check and make sure that the LINES and COLUMNS variables are not set. They overide curses window sizing functions.

cwd
01-02-2007, 07:15 AM
Before I get into this much, I need to say that the problem resolved itself without me doing anything. That's spooky.

I set the terminal type to xterm-color, but have also tried linux. What, in particular, was not working for me was emacs. Vim was equally difficult because the command bars were in the wrong place but all that mysteriously healed. I have no idea why.

Well, I'm not complaining... <puzzled look>

Dynamic terminal resizing is handled by curses or usually in Linux's case ncurses. When you resize a terminal the SIGWINCH signal is sent to your program to tell it the terminal screen has changed. The program you are using must catch the SIGWINCH signal, find the new terminal size, and redraw the screen. Some programs do not provide this functionality and SIGWINCH is caught by curses itself. If this is the case then the program does not know that the screen has been resized until it calls one of the getch functions for input.

To figure out what is not working for you I need more information. First I need to know which applications are not properly resizing for you. Second I need to know what your terminal is set at. This can be found with the following command "echo $TERM". Then, I need to see your /etc/termcap file. I need to know what terminal emulation program you are using and if possible what kind of terminal it emulates.

Most likely any problems you are experiencing has to do with the fact that the TERM variable is set wrong or that the terminal you are using is not listed in your termcap database.

Also, just to be sure, check and make sure that the LINES and COLUMNS variables are not set. They overide curses window sizing functions.

tomchuk
01-09-2007, 05:35 AM
'shopt -s checkwinsize' in your ~/.bashrc is all you need.