This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import termios | |
import fcntl | |
import os | |
import struct | |
with open(os.ctermid(), 'r') as fd: | |
packed = fcntl.ioctl(fd, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)) | |
rows, cols, h_pixels, v_pixels = struct.unpack('HHHH', packed) | |
print rows, cols, h_pixels, v_pixels |