From 25a120401b340602b34207412a581d699704a8b2 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 10 Sep 2016 22:39:16 +0900 Subject: [PATCH 1/2] use go-isatty since ssh/terminal is bigger --- options.go | 6 +++--- sift.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/options.go b/options.go index d9e20bf7..3e1438a6 100644 --- a/options.go +++ b/options.go @@ -30,7 +30,7 @@ import ( "strconv" "strings" - "golang.org/x/crypto/ssh/terminal" + "github.com/mattn/go-isatty" ) type Options struct { @@ -714,7 +714,7 @@ func (o *Options) performAutoDetections(patterns []string, targets []string) { if o.Color == "auto" { // auto activate colored output only if STDOUT is a terminal if o.Output == "" { - if runtime.GOOS != "windows" && terminal.IsTerminal(int(os.Stdout.Fd())) { + if isatty.IsTerminal(os.Stdout.Fd()) { o.Color = "on" } else { o.Color = "off" @@ -725,7 +725,7 @@ func (o *Options) performAutoDetections(patterns []string, targets []string) { } if o.GroupByFile { - if !terminal.IsTerminal(int(os.Stdout.Fd())) { + if !isatty.IsTerminal(os.Stdout.Fd()) { o.GroupByFile = false } } diff --git a/sift.go b/sift.go index 3b55134b..5c9dab90 100644 --- a/sift.go +++ b/sift.go @@ -31,10 +31,10 @@ import ( "sync" "time" + "github.com/mattn/go-isatty" "github.com/svent/go-flags" "github.com/svent/go-nbreader" "github.com/svent/sift/gitignore" - "golang.org/x/crypto/ssh/terminal" ) const ( @@ -641,7 +641,7 @@ func main() { if len(args) == 0 { // check whether there is input on STDIN - if !terminal.IsTerminal(int(os.Stdin.Fd())) { + if !isatty.IsTerminal(os.Stdin.Fd()) { targets = []string{"-"} } else { targets = []string{"."} From 044828d75048dc24989f5589cf3a113f3e32bf06 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 10 Sep 2016 22:42:28 +0900 Subject: [PATCH 2/2] wrap with go-colorable on windows --- options.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/options.go b/options.go index 3e1438a6..a20a8734 100644 --- a/options.go +++ b/options.go @@ -30,6 +30,7 @@ import ( "strconv" "strings" + "github.com/mattn/go-colorable" "github.com/mattn/go-isatty" ) @@ -716,6 +717,9 @@ func (o *Options) performAutoDetections(patterns []string, targets []string) { if o.Output == "" { if isatty.IsTerminal(os.Stdout.Fd()) { o.Color = "on" + if runtime.GOOS == "windows" { + global.outputFile = colorable.NewColorableStdout() + } } else { o.Color = "off" }