Skip to content

Instantly share code, notes, and snippets.

@gcla
Created June 16, 2019 19:38
Show Gist options
  • Save gcla/29628006828e57ece336554f26e0bde9 to your computer and use it in GitHub Desktop.
Save gcla/29628006828e57ece336554f26e0bde9 to your computer and use it in GitHub Desktop.
Run gowid applications in a different tty
diff --git a/tscreen_linux.go b/tscreen_linux.go
index 79602f4..6514956 100644
--- a/tscreen_linux.go
+++ b/tscreen_linux.go
@@ -33,10 +33,19 @@ func (t *tScreen) termioInit() error {
var ioc uintptr
t.tiosp = &termiosPrivate{}
- if t.in, e = os.OpenFile("/dev/tty", os.O_RDONLY, 0); e != nil {
+ intty := "/dev/tty"
+ outtty := "/dev/tty"
+
+ gwtty := os.Getenv("GOWID_TTY")
+ if gwtty != "" {
+ intty = gwtty
+ outtty = gwtty
+ }
+
+ if t.in, e = os.OpenFile(intty, os.O_RDONLY, 0); e != nil {
goto failed
}
- if t.out, e = os.OpenFile("/dev/tty", os.O_WRONLY, 0); e != nil {
+ if t.out, e = os.OpenFile(outtty, os.O_WRONLY, 0); e != nil {
goto failed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment