mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user