Skip to content

Instantly share code, notes, and snippets.

@vindolin
Last active August 29, 2015 14:10
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 vindolin/476b946e5953401a7d70 to your computer and use it in GitHub Desktop.
Save vindolin/476b946e5953401a7d70 to your computer and use it in GitHub Desktop.
import fcntl
import termios
import sys
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~termios.ECHO # disable echo
termios.tcsetattr(fd, termios.TCSANOW, new)
fcntl.ioctl(fd, termios.TIOCSTI, '\021') # ^Q quote control characters
command = 'df -h'
for c in command:
fcntl.ioctl(fd, termios.TIOCSTI, c)
termios.tcsetattr(fd, termios.TCSANOW, old) # restore settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment