Page 4 of 4

Re: Language selection tool

Posted: 13 Dec 2016, 15:37
by brokenman
But I know of no trick for any bash script to be able to read $COLUMNS

Code: Select all

#!/bin/bash

columns=$(tput cols)
echo "Columns: " $columns

Re: Language selection tool

Posted: 22 Dec 2016, 19:55
by Rava
tput, yes, I tend to forget about tput...

Also, this might be helpful as well:

Code: Select all

shopt -s checkwinsize
https://www.gnu.org/software/bash/manua ... iltin.html
checkwinsize

If set, Bash checks the window size after each command and, if necessary, updates the values of LINES and COLUMNS.

And then we have this:

Code: Select all

stty size
:D

Useful code: http://pastebin.com/uu9MaVbX
(I just read over it but I have not tested every line)