diff options
author | Austin Ziegler <[email protected]> | 2014-10-14 22:48:55 -0400 |
---|---|---|
committer | spf13 <[email protected]> | 2014-12-12 11:33:52 -0500 |
commit | ec4b6c03a8139988d6456195fe098b3dcfaca91d (patch) | |
tree | 23bf2296294661abe05255c2637088bbe32cfd59 /create | |
parent | 2c8e9a79313f91a55e5c99fd20f88acc4035bd2d (diff) | |
download | hugo-ec4b6c03a8139988d6456195fe098b3dcfaca91d.tar.gz hugo-ec4b6c03a8139988d6456195fe098b3dcfaca91d.zip |
Trigger an editor after `hugo new`.
- Trigger permanently with NewContentEditor in config.{toml,yaml,json}.
- Trigger on an individual basis with --editor.
Diffstat (limited to 'create')
-rw-r--r-- | create/content.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/create/content.go b/create/content.go index f1a2a3350..c3c1747a2 100644 --- a/create/content.go +++ b/create/content.go @@ -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 } |