Skip to content

Instantly share code, notes, and snippets.

@scentoni
Created November 28, 2017 18:00
Show Gist options
  • Save scentoni/f4bda3a07cf7711125de3928f95809af to your computer and use it in GitHub Desktop.
Save scentoni/f4bda3a07cf7711125de3928f95809af to your computer and use it in GitHub Desktop.
reset terminal size
res() {
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\0337\033[r\033[999;999H\033[6n\0338' > /dev/tty
IFS='[;R' read -r _ rows cols _ < /dev/tty
stty "$old"
echo "cols:$cols"
echo "rows:$rows"
stty cols "$cols" rows "$rows"
}
res2() {
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\033[18t' > /dev/tty
IFS=';t' read -r _ rows cols _ < /dev/tty
stty "$old"
echo "cols:$cols"
echo "rows:$rows"
stty cols "$cols" rows "$rows"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment