default to nano and warn if $EDITOR not set
parent
491adc5290
commit
251c250a8d
|
@ -0,0 +1 @@
|
|||
patch type="fixed" "default to nano and warn if no $EDITOR set"
|
|
@ -1,6 +1,8 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
|
@ -61,6 +63,17 @@ func (graffiti *Graffiti) Event(state *ui.State, event vaxis.Event) (processed b
|
|||
}
|
||||
|
||||
func editGraffiti(state *ui.State) {
|
||||
// if $EDITOR isn't set, warn about it, and use nano
|
||||
editor := os.ExpandEnv(os.Getenv("EDITOR"))
|
||||
if editor == "" {
|
||||
editor = "nano"
|
||||
state.Suspend()
|
||||
fmt.Print("$EDITOR not found, using nano. press ↵ to continue")
|
||||
input := bufio.NewScanner(os.Stdin)
|
||||
input.Scan()
|
||||
state.Resume()
|
||||
}
|
||||
|
||||
state.HideCursor()
|
||||
vt := term.New()
|
||||
vt.TERM = os.Getenv("TERM")
|
||||
|
|
15
app/menu.go
15
app/menu.go
|
@ -1,6 +1,8 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -129,13 +131,24 @@ func showManpage(state *ui.State) {
|
|||
}
|
||||
|
||||
func newFeels(state *ui.State) {
|
||||
// if $EDITOR isn't set, warn about it, and use nano
|
||||
editor := os.ExpandEnv(os.Getenv("EDITOR"))
|
||||
if editor == "" {
|
||||
editor = "nano"
|
||||
state.Suspend()
|
||||
fmt.Print("$EDITOR not found, using nano. press ↵ to continue")
|
||||
input := bufio.NewScanner(os.Stdin)
|
||||
input.Scan()
|
||||
state.Resume()
|
||||
}
|
||||
|
||||
state.HideCursor()
|
||||
vt := term.New()
|
||||
vt.TERM = os.Getenv("TERM")
|
||||
vt.Attach(state.PostEvent())
|
||||
vt.Focus()
|
||||
now := time.Now()
|
||||
err := vt.Start(exec.Command(os.ExpandEnv(os.Getenv("EDITOR")), path.Join(ttbp.PathUserEntries, now.Format("20060102")+".txt")))
|
||||
err := vt.Start(exec.Command(editor, path.Join(ttbp.PathUserEntries, now.Format("20060102")+".txt")))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue