diff --git a/internal/cmd/edit.go b/internal/cmd/edit.go index 5a3163b..a8dc9b7 100644 --- a/internal/cmd/edit.go +++ b/internal/cmd/edit.go @@ -2,10 +2,10 @@ package cmd import ( "fmt" - "log" "os" "os/exec" "path/filepath" + "strings" "time" "github.com/spf13/cobra" @@ -28,13 +28,19 @@ func newEditCmd() *editCmd { return err } - editor := os.Getenv("EDITOR") - if editor == "" { + editor := strings.Fields(os.Getenv("EDITOR")) + if len(editor) == 0 { return fmt.Errorf("no $EDITOR set") } - log.Printf("%s %s\n", editor, tmp) - edit := exec.Command(editor, tmp) + editorCmd := editor[0] + var editorArgs []string + if len(editor) > 1 { + editorArgs = append(editorArgs, editor[1:]...) + } + editorArgs = append(editorArgs, tmp) + + edit := exec.Command(editorCmd, editorArgs...) edit.Stderr = os.Stderr edit.Stdout = os.Stdout edit.Stdin = os.Stdin