Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (
"strconv"
"strings"

"golang.org/x/crypto/ssh/terminal"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
)

type Options struct {
Expand Down Expand Up @@ -714,8 +715,11 @@ 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"
if runtime.GOOS == "windows" {
global.outputFile = colorable.NewColorableStdout()
}
} else {
o.Color = "off"
}
Expand All @@ -725,7 +729,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
}
}
Expand Down
4 changes: 2 additions & 2 deletions sift.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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{"."}
Expand Down