Skip to content

Instantly share code, notes, and snippets.

@espinz
Created May 9, 2019 23:59
Show Gist options
  • Select an option

  • Save espinz/462548d4b5886ce12c41eb422a0dae8b to your computer and use it in GitHub Desktop.

Select an option

Save espinz/462548d4b5886ce12c41eb422a0dae8b to your computer and use it in GitHub Desktop.
Jekyll posting script
#!/bin/bash
length=8
printf -v line '%*s' "$length"
echo ""
printf "%s\n" "New Post"
echo ${line// /-}
NEWPOST(){
echo -n "Title: "
read title
echo -n "Categories: "
read categor
echo -n "Tags: "
read tags
date=`date +%Y-%m-%d`
post=$date-$title.markdown
folder="/absolutepath/to/my_collections/_posts"
enterPost="$(printf "%s" `echo "$post"`)"
#touch $(printf "%s" `echo "$folder/$post"`)
cd ${folder}
#cat << END > "$folder/$enterPost"
cat << END > $enterPost
---
layout: post
title: $title
date: $date
categories: [$categor]
tags: [$tags]
---
END
vim -s ~/Bin/commands $enterPost #vim macro that enters inserts mode
cd ../..
bundle exec jekyll build && \
rsync -pvru --delete /absolutepath to jekyll/_site/* /absolute path to/site folder that will upload to github
}
NEWPOST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment