Skip to content

Commit

Permalink
Merge pull request #9 from shanehull/fix/zet-template
Browse files Browse the repository at this point in the history
fix: add front matter to zet template
  • Loading branch information
shanehull authored Feb 8, 2024
2 parents 0687c55 + 1c1e6d5 commit d32da8e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/shed/shed_zet.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ var vimCmd = "vim"

var defaultSubDir = "0-inbox"

var fileTemplate = `# %s
var fileTemplate = `---
date: %s
tags:
-
---
# %s
Links:
%s
`

var zetCommand = &cli.Command{
Expand Down Expand Up @@ -99,16 +104,16 @@ var zetCommand = &cli.Command{

initialFileContents := fmt.Sprintf(
fileTemplate,
titleCase(strings.ReplaceAll(filename, "-", " ")),
time.Now().Format("2006-01-02"),
titleCase(strings.ReplaceAll(filename, "-", " ")),
)

if err := os.WriteFile(fullFilePath, []byte(initialFileContents), 0o644); err != nil {
fmt.Println(err)
os.Exit(1)
}

cmd := exec.Command(vimCmd, "+normal ggzzA", "+startinsert!", fullFilePath)
cmd := exec.Command(vimCmd, "+normal G", "+startinsert!", fullFilePath)

cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
Expand Down

0 comments on commit d32da8e

Please sign in to comment.