Skip to content

Commit

Permalink
PoC for opening new note in editor
Browse files Browse the repository at this point in the history
When creating a new note, the first thing we want to do is start editing
that note. If 'zb' can open the file in an editor for us that will help
to reduce friction to writing down what's needed.
  • Loading branch information
msp301 committed May 17, 2024
1 parent 82cd931 commit 7227f31
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/spf13/viper"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"time"
Expand Down Expand Up @@ -44,7 +45,24 @@ var newCmd = &cobra.Command{
log.Fatalf("Error getting absolute path: %s", err)
}

fmt.Println(fullPath)
command := exec.Command("nvim", fullPath)
command.Stdin = os.Stdin
command.Stdout = os.Stdout
command.Stderr = os.Stderr

err = command.Start()
if err != nil {
log.Printf("Error opening note in vim: %s\n", err)
fmt.Println(fullPath)
os.Exit(1)
}

err = command.Wait()
if err != nil {
log.Printf("Error waiting for vim to close: %s\n", err)
fmt.Println(fullPath)
os.Exit(1)
}
},
}

Expand Down

0 comments on commit 7227f31

Please sign in to comment.