Home > Software design >  How to check, if $COLUMNS and $LINES get updated in a Shell script?
How to check, if $COLUMNS and $LINES get updated in a Shell script?

Time:12-17

I want to check in a POSIX Shell script, if the variables $COLUMNS and $LINES get updated, means if the user changes the size of the terminal window.

How can I do this, maybe even on the fly to automatically update the variables?

CodePudding user response:

How to check, if $COLUMNS and $LINES get updated in a Shell script?

Write a short script, that outputs values of the variables COLUMNS and LINES, then waits for any user input, then outputs the values of the variables.

Run the script in your terminal emulator, let it print the values of the variables. Then resize your terminal emulator to a different window size. Then input anything to the script to let it continue.

Visually inspect both lines of output from the script is they are the same.

  • Related