Use ctermid() instead of hardcoding /dev/tty

This commit is contained in:
Kovid Goyal
2018-08-04 20:58:01 +05:30
parent 05b817f5f5
commit d964146f8c
6 changed files with 14 additions and 8 deletions

View File

@@ -2,11 +2,12 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
from kitty.cli import parse_args
from ..tui.operations import styled
from ..tui.operations import styled
OPTIONS = '''\
--title
@@ -17,7 +18,7 @@ The title for the error message.
def real_main(args):
error_message = sys.stdin.buffer.read().decode('utf-8')
sys.stdin = open('/dev/tty')
sys.stdin = open(os.ctermid())
msg = 'Show an error message'
args, items = parse_args(args, OPTIONS, '', msg, 'hints')
print(styled(args.title, fg_intense=True, fg='red', bold=True))