Skip to content

Commit 034f904

Browse files
Fall back to open() if no editor is defined
Signed-off-by: Chris Cummer <[email protected]>
1 parent 4567050 commit 034f904

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

til.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const (
2929
commitMessage: "build, save, push"
3030
committerEmail: [email protected]
3131
committerName: "TIL Autobot"
32-
editor: "mvim"
32+
editor: ""
3333
targetDirectory: "~/Documents/til"
3434
`
35+
defaultEditor = "open"
3536

3637
fileExtension = "md"
3738

@@ -407,9 +408,10 @@ func createNewPage(title string) string {
407408
}
408409

409410
// Tell the OS to open the newly-created page in the editor (as specified in the config)
410-
editor, err1 := globalConfig.String("editor")
411-
if err1 != nil {
412-
Fail(err1)
411+
// If there's no editor explicitly defined by the user, tell the OS to try and open it
412+
editor := globalConfig.UString("editor", defaultEditor)
413+
if editor == "" {
414+
editor = defaultEditor
413415
}
414416

415417
cmd := exec.Command(editor, filePath)

0 commit comments

Comments
 (0)