Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When I'm working on my FreeBSD server's ssh, it always assume that terminal width is 80 columns. E.g. man pages show up in one thin column and all programs that use COLUMNS and LINES environment variables to guess terminal size work only in 80 default columns.

Are there any way to make tcsh correctly set this environment vars and send them to child programs?

share|improve this question
    
What terminal are you using that resizing doesn't work? –  Chris S Oct 6 '10 at 15:40
    
I currently use MacOS X+Terminal, verified on Ubuntu 10.04+lxterminal and Windows 7+Putty, the very same result everywhere. –  Yorik.sar Oct 6 '10 at 23:50

4 Answers 4

sh: unset COLUMNS LINES; export TERM=xterm

csh: unsetenv COLUMNS LINES; setenv TERM xterm

Terminals which have dynamic size or font or resolution are the norm, not the exception.

When that became the case, Unix put this information into the kernel tty attributes, and deprecated $COLUMNS, $LINES, and the termcap/terminfo dimension data.

You can see the kernel dims by running "stty -a". Ssh, rlogin, and modern telnet pass these dimensions to the remote side.

Usually, unsetting elicits better behavior. Sometimes, a shell will reset the env vars (based on "stty" info).

share|improve this answer

Not sure about tcsh, but for bash, sh and ksh:

eval `resize`

Should do the trick.

share|improve this answer
    
eval `resize -c` –  Dennis Williamson Oct 6 '10 at 13:13
1  
resize: Command not found. –  Yorik.sar Oct 6 '10 at 14:24
1  
This usually comes bundled with the X server - but the program itself is fairly simple. A quick google turned up this: ohse.de/uwe/software/resize.c.html –  symcbean Oct 7 '10 at 11:53

The resize script comes with xterm which you can install from ports (although you will get libX11 etc with it).

share|improve this answer

tcsh inherits the environment from the parent shell. To add additional envvars you can:

source envvar

where envvar contains for example:

set history = 5000
# Set save history
set savehist = 5000
# Set a prompt
set prompt = `whoami`%' '
# Add to the default exported $PATH from the parent shell.
set path = `echo $path ~/bin`
# Create a new environment variable
set newShellVar = whatEver

Once you enter the shell, e.g. type tcsh <return> you can activate the file using:

source envvar

Of course if you name your envvar file as ~/.tcshrc, then the file is auto sourced when you execute the tcsh command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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