Hi, I'm wondering how to run some custom commands after doing a hexo new "My post". I'd like to immediately open the my-post.md file in my editor of choice (with a vi my-post.md). Anyone have a solution to this? Thanks!
You can try to listen to the new event. For example:
var spawn = require('child_process').spawn;
// Hexo 2.x
hexo.on('new', function(path){
spawn('vi', [path]);
});
// Hexo 3
hexo.on('new', function(data){
spawn('vi', [data.path]);
});
Thanks for the reply. Where should this live?
On Sun, Jan 25, 2015 at 7:47 PM, Tommy Chen [email protected]
wrote:
You can try to listen to the new event. For example:
var spawn = require('child_process').spawn;
// Hexo 2.x
hexo.on('new', function(path){
spawn('vi', [path]);
});
// Hexo 3
hexo.on('new', function(data){
spawn('vi', [data.path]);
});—
Reply to this email directly or view it on GitHub
https://github.com/hexojs/hexo/issues/1007#issuecomment-71411711.
You can add a JavaScript file to scripts folder.
http://hexo.io/docs/plugins.html#Script
Closed for no more update.
var spawn = require('child_process').spawn;
// Hexo 3
hexo.on('new', function(data){
spawn('vi', [data.path]);
});
For me, this failed to open Vim in terminal.
I added { stdio: 'inherit' } option to let Vim use parent's stdios.
var spawn = require('child_process').spawn;
// Hexo 3
hexo.on('new', function(data){
spawn('vim', [data.path], { stdio: 'inherit' });
});
It opens Vim in terminal now.
hexo 5 Not working
Most helpful comment
For me, this failed to open
Vimin terminal.I added
{ stdio: 'inherit' }option to letVimuse parent's stdios.It opens
Vimin terminal now.