From 3c0ea6784e26abc27d21781b0fdd3518e2576598 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 20 Dec 2010 10:02:54 -0600 Subject: [PATCH] Added 'editpost' function for jekyll plugins --- plugins/jekyll.plugins.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 3ad9d0d..546bb63 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -1,5 +1,31 @@ #!/bin/bash +editpost() { + builtin cd "$JEKYLL_LOCAL_ROOT/_posts" + + COUNTER=1 + NUMBER="$RANDOM" + + for POST in * + do + DATE=`echo $POST | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"` + TITLE=`cat $POST | grep -oE "title: (.+)"` + TITLE=`echo $TITLE | sed 's/title: //'` + TMPFILE="/tmp/editpost-$NUMBER" + echo "$COUNTER) $DATE | $TITLE" >> "$TMPFILE" + POSTS[$COUNTER]=$POST + COUNTER=`expr $COUNTER + 1` + done + less $TMPFILE + read -p "Number of post to edit: " POST_TO_EDIT + if [ -z "$EDITOR" ] + then + nano "${POSTS[$POST_TO_EDIT]}" + else + "$EDITOR" "${POSTS[$POST_TO_EDIT]}" + fi +} + newpost() { # 'builtin cd' into the local jekyll root -- 2.17.1