Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/create
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2014-10-15 06:48:55 +0400
committerspf13 <steve.francia@gmail.com>2014-12-12 19:33:52 +0300
commitec4b6c03a8139988d6456195fe098b3dcfaca91d (patch)
tree23bf2296294661abe05255c2637088bbe32cfd59 /create
parent2c8e9a79313f91a55e5c99fd20f88acc4035bd2d (diff)
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.go17
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
}