diff --git a/cmd/pttodo-cli/cli.go b/cmd/pttodo-cli/cli.go index eb1ed84..8b248d7 100644 --- a/cmd/pttodo-cli/cli.go +++ b/cmd/pttodo-cli/cli.go @@ -61,13 +61,25 @@ func edit(dry bool, filepath string) error { return nil } vi := func() error { - vibin, err := exec.LookPath("vi") + bin := "vim" + if editor := os.Getenv("EDITOR"); editor != "" { + bin = editor + } + editorbin, err := exec.LookPath(bin) + if err != nil { + editorbin, err = exec.LookPath("vi") + } if err != nil { return err } + args := []string{editorbin, tempFile} + vimrc := path.Join(os.Getenv("HOME"), ".vimrc") + if _, err := os.Stat(vimrc); err == nil { + args = append(args, "-u", vimrc) + } cpid, err := syscall.ForkExec( - vibin, - []string{vibin, tempFile}, + editorbin, + args, &syscall.ProcAttr{ Dir: "", Env: os.Environ(), diff --git a/todo.yaml b/todo.yaml index 9eef4cc..fede9cc 100644 --- a/todo.yaml +++ b/todo.yaml @@ -1,8 +1,6 @@ todo: -- todo: crap losing on a bad edit hurts - details: | - ? -- vim doesnt source vimrc +- vim doesnt source vimrc, so stuff like tab width and tab characters, also syntax + highlight :( - todo: when to run scheduled modifier? like, syncthing could have conflicts if I modify only file on remote ts: 1641007992 @@ -39,3 +37,7 @@ done: ts: 1641007992 subtasks: - a +- todo: crap losing on a bad edit hurts + ts: 1641008278 + details: | + ?