Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sts10
Last active August 29, 2015 13:56
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 sts10/8837128 to your computer and use it in GitHub Desktop.
Save sts10/8837128 to your computer and use it in GitHub Desktop.
A bash function for creating a new Octopress post from anywhere in the terminal
function octo_new {
cwd=$(pwd) #save pwd as cwd
cd /Users/$USER/Documents/code/sts10.github.io
echo "Creating new octopress post called \""$1"\""
rake new_post["$1"]
cd source/_posts
FILENAME=`ls -t | head -1`
open $FILENAME
read -p "Would you like to commit & push your git and publish your Octopress blog now? (y/n) " -n 1 -r # Maybe give a "(d)elete this post" option
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# commit git and publish blog
cd ../../
git add .
git commit -m "Used octo_new to publish a new post called "$FILENAME"." # $FILENAME ?
git push origin source
rake generate
rake deploy
cd $cwd
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment