From 541d232f1c30ec0d59f820f1877021e46e6039c1 Mon Sep 17 00:00:00 2001 From: Igor Fedorenko Date: Thu, 20 Sep 2018 09:50:29 -0400 Subject: [PATCH] termstatus: detect and respect dumb terminals on Unix Signed-off-by: Igor Fedorenko --- internal/ui/termstatus/terminal_unix.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/ui/termstatus/terminal_unix.go b/internal/ui/termstatus/terminal_unix.go index e49d62d40..d82c032d9 100644 --- a/internal/ui/termstatus/terminal_unix.go +++ b/internal/ui/termstatus/terminal_unix.go @@ -4,6 +4,7 @@ package termstatus import ( "io" + "os" "golang.org/x/sys/unix" @@ -24,7 +25,15 @@ func moveCursorUp(wr io.Writer, fd uintptr) func(io.Writer, uintptr, int) { // canUpdateStatus returns true if status lines can be printed, the process // output is not redirected to a file or pipe. func canUpdateStatus(fd uintptr) bool { - return isatty.IsTerminal(fd) + if !isatty.IsTerminal(fd) { + return false + } + term := os.Getenv("TERM") + if term == "" { + return false + } + // TODO actually read termcap db and detect if terminal supports what we need + return term != "dumb" } // getTermSize returns the dimensions of the given terminal.