Przeglądaj źródła

List files with colour

Lucas Stadler 9 lat temu
rodzic
commit
0bc1ff7929
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      go/explore/explore.go

+ 3 - 0
go/explore/explore.go

@ -12,6 +12,7 @@ import (
12 12
var options struct {
13 13
	listFiles bool
14 14
}
15
var lsOpts = []string{"--color=auto", "--group-directories-first"}
15 16
16 17
func init() {
17 18
	flag.BoolVar(&options.listFiles, "l", false, "Always list files")
@ -39,6 +40,7 @@ func main() {
39 40
40 41
	if options.listFiles {
41 42
		cmd := exec.Command("ls", dir)
43
		cmd.Args = append(cmd.Args, lsOpts...)
42 44
		cmd.Stdin = os.Stdin
43 45
		cmd.Stdout = os.Stdout
44 46
		cmd.Stderr = os.Stderr
@ -67,6 +69,7 @@ func main() {
67 69
68 70
		if len(rs) == 0 {
69 71
			cmd = exec.Command("ls", dir)
72
			cmd.Args = append(cmd.Args, lsOpts...)
70 73
		} else {
71 74
			if options.listFiles {
72 75
				fmt.Println()