I know this is something simple, but I can't recall where it's located/named.
Where's the variable for the current width of the terminal stored?
I see this answer talks about changing things: How are terminal length and width forwarded over SSH and telnet?
But I'd like to get the current value, for use in a script (and I don't understand everything in that answer).
Once upon a time I recall there was some way to display all environment variables? (Hmm, I see an answer that says use set
(vs. env
), but my set
only shows LINES and not width?)
Then of course it's onto the next problem; once I have that $number I'd like to repeat a character ( "-" ) that many times, to make a dashed line that's X-characters-wide (fills the terminal, without wrapping). If you've got an elegant way I should be doing that, I'd appreciate that too.
$COLUMNS
is one such variable. Also there'sstty -a
or more specificallystty size
. – slm Jul 13 '15 at 05:41env
. – ikrabbe Jul 13 '15 at 05:48diff -W ${COLUMNS} -y wideFiles*
– Mark Hudson Dec 07 '20 at 22:23