Skip to content
Merged
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
16 changes: 11 additions & 5 deletions internal/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package cmd

import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/spf13/cobra"
Expand All @@ -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
Expand Down