Last active
January 3, 2016 17:49
-
-
Save mariolopjr/8498204 to your computer and use it in GitHub Desktop.
Automates creating a new post with Octopress, just do "post Title of post" and the script will do the rest!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# post.sh | |
# | |
# Originally created by: | |
# Hilton Lipschitz (http://www.hiltmon.com) @hiltmon | |
# Use and modify freely, attribution appreciated | |
# | |
# Create a new Octopress post, isolate it, generate the site and leave me with a | |
# preview thread running. | |
# | |
# Recreated in bash by: | |
# Mario Lopez | |
# | |
# Usage | |
# $ post This is a post | |
# | |
# NOTE: Do not wrap the parameters in quotes | |
# | |
# | |
# Variables | |
# | |
# Location to your Octopress installation root | |
StrFileName="" # Holds the file name of the post | |
StrOctopressRoot="$HOME/Documents/Projects/techsym.com/octopress" | |
StrPostTitle="" # Holds the Title of the post | |
StrTemp="" # Temp variable that holds the current argument | |
# | |
# Script Execution | |
# | |
# Change to the directory that houses your Octopress instance | |
cd $StrOctopressRoot | |
# Sets the file name based upon the input args | |
StrPostTitle="$@" | |
# Creates the post and saves the resultant output into StrFileName for parsing | |
StrFileName=$(rake new_post["$StrPostTitle"]) | |
# Parse out the generated file name | |
StrFileName=${StrFileName#*s/} # Strips away any characters before file name | |
StrFileName=${StrFileName%.*} # Strips away the file extension | |
# Isolate, generate and preview | |
if [ ! -z "$StrFileName" ]; then | |
rake isolate["$StrFileName"] | |
rake generate | |
rake preview | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment