diff options
Diffstat (limited to 'utilities.go')
| -rw-r--r-- | utilities.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/utilities.go b/utilities.go new file mode 100644 index 0000000..5a9b69f --- /dev/null +++ b/utilities.go @@ -0,0 +1,22 @@ +package main + +import ( + "os" + "os/exec" + + tea "charm.land/bubbletea/v2" +) + +type editorFinishedMsg struct { + err error +} + +func openEditor(path string) tea.Cmd { + editor := os.Getenv("EDITOR") + if editor == "" { + editor = "vim" + } + return tea.ExecProcess(exec.Command(editor, path), func(err error) tea.Msg { + return editorFinishedMsg{err: err} + }) +} |
