Skip to content

Instantly share code, notes, and snippets.

@durden
Created June 14, 2013 18:46
Show Gist options
  • Save durden/5784253 to your computer and use it in GitHub Desktop.
Save durden/5784253 to your computer and use it in GitHub Desktop.
Get width/height of current terminal in python
# Snippet taken from: https://github.com/JakeWharton/pidcat/blob/master/pidcat.py
# unpack the current terminal width/height
data = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, '1234')
HEIGHT, WIDTH = struct.unpack('hh',data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment