Skip to content

Instantly share code, notes, and snippets.

@bfatemi
Created March 16, 2016 05:07
Show Gist options
  • Save bfatemi/8de059e73d666ca3b938 to your computer and use it in GitHub Desktop.
Save bfatemi/8de059e73d666ca3b938 to your computer and use it in GitHub Desktop.
Snippet to continuously grab and display the size of the console window
#!/bin/bash
trap 'get_window_size' WINCH # trap when a user has resized the window
get_window_size() {
_WINDOW_X=`tput lines`
_WINDOW_Y=`tput cols`
echo "X: $_WINDOW_X"
echo "Y: $_WINDOW_Y"
return 0
}
while read ALINE
do
echo "Read: '$ALINE'"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment