Skip to content

Instantly share code, notes, and snippets.

@bryant1410
Last active April 26, 2022 06:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryant1410/f134401c5866e96a81a7991678779f57 to your computer and use it in GitHub Desktop.
Save bryant1410/f134401c5866e96a81a7991678779f57 to your computer and use it in GitHub Desktop.
Quick workaround to change PyCharm's remote terminal width
# See https://youtrack.jetbrains.com/issue/PY-40900#focus=streamItem-27-4082296.0-0
width = 215; print("Terminal width:", width)
if sys.stdout.isatty():
import fcntl, struct, sys, termios; fcntl.ioctl(sys.stdin, termios.TIOCSWINSZ, struct.pack("HHHH", 0, width, 0, 0))
else: # In case it's not remote.
import os; os.environ["COLUMNS"] = str(width) # It doesn't work everywhere, but it's something.
os.environ["LINES"] = "21" # Some programs need both env vars set for any to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment