Skip to content

Instantly share code, notes, and snippets.

@marcransome
Last active December 20, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcransome/6096005 to your computer and use it in GitHub Desktop.
Save marcransome/6096005 to your computer and use it in GitHub Desktop.
A fish shell function that opens the default editor with a date prepended filename and the specified title for jekyll posts.
function jp -d "Open default editor with date prepended filename and specified title for jekyll posts."
set title (date +"%Y-%m-%d")
switch (count $argv)
case 0
echo "No post title was specified."
return 1
case 1
set lower_arg (echo $argv[1] | tr A-Z a-z)
set title $title-$lower_arg.md
case \*
for arg in $argv
set lower_arg (echo $arg | tr A-Z a-z)
set title $title-$lower_arg
end
set title $title.md
end
EDITOR $title
end
@marcransome
Copy link
Author

Put this file in your ~/.config/fish/functions directory. If you haven't already defined an EDITOR function, add an editor.fish file to the same directory, with the following code:

function EDITOR
        vim $argv
end

Finally, create a blog post about your adventures:

$ jp My wonderful new blog post

*Note: quotes around the post title are optional.

@marcransome
Copy link
Author

All text will be converted to lowercase when using the latest revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment