Closed andrewboni closed 8 years ago
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 notifications@github.com 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
you can just write a function in your .profile e.g on windows using powershell with vscode
function hexoNew {
param (
[Object]$name
)
Set-Location path/to/your/hexo_blog_repo ; hexo new $name ; Set-Location ./source/_posts
$new = Get-ChildItem | Where-Object { $_.CreationTime -gt (Get-Date).AddSeconds(-5) } | ForEach-Object {$_.Name}
code ./$new
}
*nix users can modify some commad and that's not hard for you.
Hi, I'm wondering how to run some custom commands after doing a
hexo new "My post"
. I'd like to immediately open themy-post.md
file in my editor of choice (with avi my-post.md
). Anyone have a solution to this? Thanks!