LXTerminal and XTerm Resize Command

Solution 1:

There are two steps to this. First, you need to tell xterm to allow it to happen at all, because by default it ignores requests by hosted programs to resize the window. Add this to your ~/.Xdefaults:

xterm*allowWindowOps: true

For this to take effect, you either have to log out, or run:

xrdb ~/.Xdefaults

Then launch a new xterm, and in your bash script:

echo -ne "\e[8;30;30t"

Solution 2:

Just want to share:

apt-get install xterm

Use the following resize command where 20 = no of rows, 40 = no of columns:

resize -s 20 40

Change the value of rows and columns as per requirement.

Solution 3:

In addition to @Paul's correct answer:

You could try this without editing ~/.Xdefaults, by running:

xterm -xrm 'xterm*allowWindowOps: true'

Then, in new window:

printf "\e[8;%d;%dt" $[LINES+5] $[COLUMNS+5]

.Xdefaults or .Xresources

Depending on your installation, you may have to store this on .Xresources instead of .Xdefaults.

FILES

Xrdb does not load any files on its own, but many desktop environments use xrdb to load ~/.Xresources files on session startup to initialize the resource database, as a generalized replacement for ~/.Xdefaults files.

Then after

sed -e '$axterm*allowWindowOps: true' -i.bak .Xresources 
xrdb <.Xresources

Then...

Some bind samples

You could run this or add to your .bashrc:

# Some bind for 'Shift' + <direction> key and allowWindowOps resource
bind -x '"\e[1;2C"':'printf  "\e[8;%d;%dt" $LINES $((COLUMNS+5))'
bind -x '"\e[1;2D"':'printf  "\e[8;%d;%dt" $LINES $((COLUMNS-5))'
bind -x '"\e[1;2B"':'printf  "\e[8;%d;%dt" $((LINES+3)) $COLUMNS'
bind -x '"\e[1;2A"':'printf  "\e[8;%d;%dt" $((LINES-3)) $COLUMNS'

to be used with respectively: Shift+Right   ,   Shift+Left   ,   Shift+Down   or   Shift+Up

Note: As this in bash bind, this will work in interactive command environment (aka not under vim nor less, read or any work in progress)