Last month, I wrote about my experiment with iOS and a remote server from Digital Ocean. It’s working very well, but Emacs can feel a bit sluggish at times, served up remotely over a crowded public wi-fi network. Vim is speedy, and since I use Evil on Emacs, it’s not too painful to switch occasionally. Any pain comes from the loss of the automation with all of those Emacs functions I’ve written and collected over the years.
I thought about writing some scripts in Elisp, but settled on functions in the Fish Shell. The first function creates an appropriately named Markdown file with YAML front-matter. The important parts come from Marc Ransome:
function draft -d "Open default editor with date prepended filename and specified title for jekyll posts."cd ~/Dropbox/blog-draftsnn# Create filen set title (date +"%Y-%m-%d") n switch (count $argv) n case 0n echo "No post title was specified." return 1n case 1n set lower_arg (echo $argv | tr A-Z a-z) set title $title-$lower_arg.mdn case * for arg in $argvn set lower_arg (echo $arg | tr A-Z a-z) set title $title-$lower_argn end set title $title.mdn end n# Append YAMLnecho "---" >> $titlenecho "layout: post" >> $titlenecho "title: " $argv >> $titlenecho "tags:" >> $titlenecho "- " >> $titlenecho "comments: true" >> $titlenecho "date:" (date +"%Y-%m-%d %H:%M:%S") >> $titlenecho "---" >> $titlenn# Open file in VIMn EDITOR $titlenend
The other two functions were very simple – one to move a completed draft to the _posts folder, and another to commit the new post and push to Github with the imaginative commit message, “New post”:
“` fishnfunction postn mv $argv ~/Sites/rlridenour.github.io/_postsnend
function publishn cd ~/Sites/rlridenour.github.ion git add . git commit -m “New post.”n git pushnendn““