Trigger an editor after hugo new.

- Trigger permanently with NewContentEditor in config.{toml,yaml,json}.
- Trigger on an individual basis with --editor.
This commit is contained in:
Austin Ziegler
2014-10-14 22:48:55 -04:00
committed by spf13
parent 2c8e9a7931
commit ec4b6c03a8
2 changed files with 24 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ import (
"bytes"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"time"
@@ -104,6 +106,21 @@ func NewContent(kind, name string) (err error) {
}
jww.FEEDBACK.Println(helpers.AbsPathify(filepath.Join(viper.GetString("contentDir"), name)), "created")
editor := viper.GetString("NewContentEditor")
if editor != "" {
jww.FEEDBACK.Printf("Editing %s in %s.\n", name, editor)
cmd := exec.Command(editor, path.Join(viper.GetString("contentDir"), name))
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err = cmd.Run(); err != nil {
return
}
}
return nil
}