Last active
August 29, 2015 13:56
-
-
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
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
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