Onionr/onionr/utils/getconsolewidth.py

15 lines
321 B
Python
Raw Normal View History

2019-07-30 05:19:22 +00:00
import os
def get_console_width():
'''
Returns an integer, the width of the terminal/cmd window
'''
columns = 80
try:
columns = int(os.popen('stty size', 'r').read().split()[1])
except:
# if it errors, it's probably windows, so default to 80.
pass
return columns