Created
July 30, 2020 16:16
-
-
Save ricardofalasca/70cf4a34964f441ba2a4bb3c23d17db3 to your computer and use it in GitHub Desktop.
How to close vim externally on Linux (devpts)
This file contains hidden or 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
#!/usr/bin/env python3 | |
pts = 15 # set the pts your vim instance is running | |
""" Run this as super user """ | |
import os, fcntl, termios | |
fd = os.open(f'/dev/pts/{pts}', os.O_RDWR) | |
vim_cmd = '\033:wqa!\n' | |
for i in vim_cmd: | |
fcntl.ioctl(fd, termios.TIOCSTI, i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment