···1package knit
23-import "errors"
000045// DefaultHost is the default host for tangled.sh services
6const DefaultHost = "tangled.sh"
···11// ErrRequiresAuth is returned when a command requires authentication but the
12// user has not authenticated with the host
13var ErrRequiresAuth = errors.New("authentication required")
000000000000000000
···1package knit
23+import (
4+ "errors"
5+ "os"
6+ "os/exec"
7+)
89// DefaultHost is the default host for tangled.sh services
10const DefaultHost = "tangled.sh"
···15// ErrRequiresAuth is returned when a command requires authentication but the
16// user has not authenticated with the host
17var ErrRequiresAuth = errors.New("authentication required")
18+19+func Editor() string {
20+ e := os.Getenv("EDITOR")
21+ if e != "" {
22+ return e
23+ }
24+25+ options := []string{"nvim", "vim", "nano"}
26+ for _, opt := range options {
27+ _, err := exec.LookPath(opt)
28+ if err != nil {
29+ continue
30+ }
31+ return opt
32+ }
33+34+ return "vi"
35+}