Skip to content

Instantly share code, notes, and snippets.

@IdlePhysicist
Created October 2, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IdlePhysicist/f5549d0cb7de0a13aae1469879f8e7e2 to your computer and use it in GitHub Desktop.
Save IdlePhysicist/f5549d0cb7de0a13aae1469879f8e7e2 to your computer and use it in GitHub Desktop.
A simple python script for *NIX to wait for terminal input.
def getch():
import sys, tty, termios
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment