help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting $COLUMN permanently


From: Koichi Murase
Subject: Re: Setting $COLUMN permanently
Date: Mon, 1 Feb 2021 00:15:28 +0800

2021年1月31日(日) 23:16 Jordan Borgner <jordan@manmtr.net>:
> /. Can one explain this behavior to me?

It is related to the shell option `checkwinsize'. You can turn off the
reset of LINES and COLUMNS after the command executions by the
following setting in your .bashrc:

  shopt -u checkwinsize

You can also turn off the reset of LINES and COLUMNS on the
terminal-size change by

  trap '' WINCH

In addition, you may explicitly block the change of COLUMNS by making
it readonly

  readonly COLUMNS=80

... but I'm not sure why you want to set a different value from the
actual size of the terminal, which may break the rendering of some
terminal applications that don't use `TIOCGWINSZ'. For example, with a
different value from the actual width of a terminal without `xenl'
capability, I don't think a full-screen application using `COLUMNS'
can properly display its contents. I recommend you to set COLUMNS only
for specified commands instead of setting it globally. For example,
you can set up aliases in the following way:

alias mycmd='COLUMNS=80 mycmd'

where `mycmd' is a command that uses `COLUMNS'. The syntax `var=value
command' can be used to set up an environment variable `var' that only
survives while the execution of that command (though there is an
exception in the POSIX mode. See the manual for the detail). I'm sorry
if you understand everything yet have some reason to do it.

--
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]