Skip to content

Instantly share code, notes, and snippets.

@burtlo
Last active October 5, 2015 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burtlo/8f4773f5ea16ddf1b589 to your computer and use it in GitHub Desktop.
Save burtlo/8f4773f5ea16ddf1b589 to your computer and use it in GitHub Desktop.
This is a shortcut to change into my journal directory, create a new article, and then immediately start editing it.
read () {
open "http://franklinwebber.com"
}
article () {
# change in to the directory where I keep my journal project
cd ~/journal
echo "Creating article '$@'"
# Run the command to generate the article with the tool I use
output=$(middleman article "$@")
# The output of that command:
#
# WARN: Unresolved specs during Gem::Specification.reset:
# rack (>= 1.0, >= 1.4.5)
# thor (< 2.0, >= 0.15.2)
# activesupport (~> 3.2.6)
# rb-fsevent (>= 0.9.3)
# rb-inotify (>= 0.9)
# ffi (>= 0.5.0)
# WARN: Clearing out unresolved specs.
# Please report a bug if this causes problems.
# [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
# create source/entries/2015-09-13-me11.html.markdown
#
# We want the last line, and then we want the filepath.
# I found it hard to retrieve the filepath because of some ANSI color that Thor
# uses in the output so I use awk to grap the third term.
#
# echo $(echo $output |& tail -1 | awk '{print $3;}')
new_article=$(echo $output |& tail -1 | awk '{print $3;}')
# echo "vim $new_article"
vim $new_article
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment