diff --git a/clean_files.txt b/clean_files.txt
index 53765a5f..0e6c39f5 100644
--- a/clean_files.txt
+++ b/clean_files.txt
@@ -97,6 +97,7 @@ plugins/available/history-search.plugin.bash
plugins/available/history-substring-search.plugin.bash
plugins/available/history.plugin.bash
plugins/available/hub.plugin.bash
+plugins/available/jekyll.plugin.bash
plugins/available/jump.plugin.bash
plugins/available/less-pretty-cat.plugin.bash
plugins/available/node.plugin.bash
diff --git a/plugins/available/jekyll.plugin.bash b/plugins/available/jekyll.plugin.bash
index f647d4a0..b613db2d 100644
--- a/plugins/available/jekyll.plugin.bash
+++ b/plugins/available/jekyll.plugin.bash
@@ -7,8 +7,8 @@ function editpost() {
param '1: site directory'
group 'jekyll'
- local SITE site POST DATE TITLE POSTS TMPFILE POST_TO_EDIT
- local -i COUNTER
+ local SITE site POST DATE TITLE POSTS
+ local -i COUNTER=1 POST_TO_EDIT
if [[ -z "${1:-}" ]]; then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
@@ -29,20 +29,16 @@ function editpost() {
builtin cd "${SITE}/_posts" || return
- COUNTER=1
- TMPFILE="/tmp/editpost-$RANDOM"
-
for POST in *; do
DATE="$(echo "${POST}" | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")"
TITLE="$(grep -oE "title: (.+)" < "${POST}")"
TITLE="${TITLE/title: /}"
- echo "${COUNTER}) ${DATE} ${TITLE}" >> "${TMPFILE}"
+ echo "${COUNTER}) ${DATE} ${TITLE}"
POSTS[COUNTER]="$POST"
COUNTER="$((COUNTER + 1))"
- done
- less "${TMPFILE}"
+ done | less
read -rp "Number of post to edit: " POST_TO_EDIT
- "${JEKYLL_EDITOR:-${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}}}" "${POSTS[$POST_TO_EDIT]}"
+ "${JEKYLL_EDITOR:-${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}}}" "${POSTS[POST_TO_EDIT]}"
}
function newpost() {
@@ -52,23 +48,22 @@ function newpost() {
local SITE site FNAME_POST_TITLE FNAME YAML_DATE
local JEKYLL_FORMATTING FNAME_DATE OPTIONS OPTION POST_TYPE POST_TITLE
- if [ -z "$1" ]; then
+ local -i loc=0
+ if [[ -z "${1:-}" ]]; then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
- if [ -z "$SITE" ]; then
+ if [[ -z "${SITE}" ]]; then
echo "No such site."
return 1
fi
- loc=0
-
for site in "${SITES[@]}"; do
- if [ "${site##*/}" = "$1" ]; then
- SITE=$site
- JEKYLL_FORMATTING=${MARKUPS[$loc]}
+ if [[ "${site##*/}" == "$1" ]]; then
+ SITE="$site"
+ JEKYLL_FORMATTING="${MARKUPS[loc]}"
break
fi
loc=$((loc + 1))
@@ -88,32 +83,32 @@ function newpost() {
if [[ $JEKYLL_FORMATTING == "markdown" || $JEKYLL_FORMATTING == "textile" ]]; then
select OPTION in "${OPTIONS[@]}"; do
- if [[ $OPTION = "Text" ]]; then
+ if [[ $OPTION == "Text" ]]; then
POST_TYPE="Text"
break
fi
- if [[ $OPTION = "Quote" ]]; then
+ if [[ $OPTION == "Quote" ]]; then
POST_TYPE="Quote"
break
fi
- if [[ $OPTION = "Image" ]]; then
+ if [[ $OPTION == "Image" ]]; then
POST_TYPE="Image"
break
fi
- if [[ $OPTION = "Audio" ]]; then
+ if [[ $OPTION == "Audio" ]]; then
POST_TYPE="Audio"
break
fi
- if [[ $OPTION = "Video" ]]; then
+ if [[ $OPTION == "Video" ]]; then
POST_TYPE="Video"
break
fi
- if [[ $OPTION = "Link" ]]; then
+ if [[ $OPTION == "Link" ]]; then
POST_TYPE="Link"
break
fi
@@ -133,31 +128,27 @@ function newpost() {
FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING"
# And, finally, create the actual post file. But we're not done yet...
- # Write a little stuff to the file for the YAML Front Matter
+ {
+ # Write a little stuff to the file for the YAML Front Matter
+ echo "---"
- echo "---" >> "${FNAME}"
+ # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of the file
+ YAML_DATE="$(date "+%B %d %Y %X")"
- # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of
- # the file
+ # Echo the YAML Formatted date to the post file
+ echo "date: $YAML_DATE"
- YAML_DATE="$(date "+%B %d %Y %X")"
+ # Echo the original post title to the YAML Front Matter header
+ echo "title: $POST_TITLE"
- # Echo the YAML Formatted date to the post file
+ # And, now, echo the "post" layout to the YAML Front Matter header
+ echo "layout: post"
- echo "date: $YAML_DATE" >> "${FNAME}"
+ # Close the YAML Front Matter Header
+ echo "---"
- # Echo the original post title to the YAML Front Matter header
-
- echo "title: $POST_TITLE" >> "${FNAME}"
-
- # And, now, echo the "post" layout to the YAML Front Matter header
-
- echo "layout: post" >> "${FNAME}"
-
- # Close the YAML Front Matter Header
-
- echo "---" >> "${FNAME}"
- echo >> "${FNAME}"
+ echo
+ } > "${FNAME}"
# Generate template text based on the post type
@@ -167,31 +158,31 @@ function newpost() {
fi
if [[ $POST_TYPE == "Quote" ]]; then
- echo "> Quote" >> "${FNAME}"
- echo >> "${FNAME}"
- echo "— Author" >> "${FNAME}"
+ echo "> Quote"
+ echo
+ echo "— Author"
fi
if [[ $POST_TYPE == "Image" ]]; then
- echo "" >> "${FNAME}"
+ echo ""
fi
if [[ $POST_TYPE == "Audio" ]]; then
- echo "" >> "${FNAME}"
+ echo ""
fi
if [[ $POST_TYPE == "Video" ]]; then
- echo "" >> "${FNAME}"
+ echo ""
fi
if [[ $POST_TYPE == "Link" ]]; then
- echo "[link][1]" >> "${FNAME}"
- echo >> "${FNAME}"
- echo "> Quote" >> "${FNAME}"
- echo >> "${FNAME}"
- echo "[1]: url" >> "${FNAME}"
+ echo "[link][1]"
+ echo
+ echo "> Quote"
+ echo
+ echo "[1]: url"
fi
- fi
+ fi >> "${FNAME}"
if [[ $JEKYLL_FORMATTING == "textile" ]]; then
if [[ $POST_TYPE == "Text" ]]; then
@@ -199,29 +190,29 @@ function newpost() {
fi
if [[ $POST_TYPE == "Quote" ]]; then
- echo "bq. Quote" >> "${FNAME}"
- echo >> "${FNAME}"
- echo "— Author" >> "${FNAME}"
+ echo "bq. Quote"
+ echo
+ echo "— Author"
fi
if [[ $POST_TYPE == "Image" ]]; then
- echo "!url(alt text)" >> "${FNAME}"
+ echo "!url(alt text)"
fi
if [[ $POST_TYPE == "Audio" ]]; then
- echo "" >> "${FNAME}"
+ echo ""
fi
if [[ $POST_TYPE == "Video" ]]; then
- echo "" >> "${FNAME}"
+ echo ""
fi
if [[ $POST_TYPE == "Link" ]]; then
- echo "\"Site\":url" >> "${FNAME}"
- echo >> "${FNAME}"
- echo "bq. Quote" >> "${FNAME}"
+ echo "\"Site\":url"
+ echo
+ echo "bq. Quote"
fi
- fi
+ fi >> "${FNAME}"
# Open the file in your favorite editor
@@ -299,7 +290,7 @@ function deploysite() {
fi
for site in "${SITES[@]}"; do
- if [ "${site##*/}" == "$1" ]; then
+ if [[ "${site##*/}" == "$1" ]]; then
SITE="$site"
REMOTE="${REMOTES[loc]}"
break