Same functions as before, but modified slightly.

I basically pull up a terminal/ssh, screen -R blog-jekyll, then can run $ restart-jekyll and everything should come up. Control-a, d, and I’m out.

I run $ new-post to create a new post and jump right into an editor. I haven’t extended this to work over SSH, but it seems doable.

The file ~/blog/bin/activate.bash:

blog () 
{ 
    cd ~/blog
}
restart-jekyll () 
{ 
    blog;
    stop-jekyll;
    if ! [[ -f .pid.jekyll ]]; then
        bundle exec jekyll serve --host 0.0.0.0 --watch & echo $! > .pid.jekyll;
    fi
}
stop-jekyll () 
{ 
    blog;
    if [[ -f .pid.jekyll ]]; then
        kill $(cat .pid.jekyll);
        rm -rf .pid.jekyll;
    fi
}
new-post () 
{ 
    read -p "New Title: " title;
    read -p "new-post-slug-name: " slug;
    read -p "categories: " categories;
    blog;
    filename=_posts/$(date +"%Y-%m-%d")"-"$slug.markdown;
    cat >>"$filename" <<EOF
---
layout:     post
date:       $(date +'%Y-%m-%d %H:%M:%S %z %Z')
title:      "$title"
categories: $categories
---

EOF
    subl -a "$filename"
}
echo -e "\tBlog functions loaded."