pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

draft (755B)


      1 #!/bin/sh
      2 
      3 # use arg as title and set post file path
      4 TITLE=$1
      5 RND=$2
      6 
      7 if [ "$RND" = "mov" ] || [ "$RND" = "lit" ] ; then
      8 	ENTRY="entry/rnd.${RND}.rec:_${TITLE}.md"
      9 else
     10 	ENTRY="entry/${TITLE}.md"
     11 fi
     12 
     13 # checkout the correct branch
     14 if [ "$RND" = "mov" ] || [ "$RND" = "lit" ] ; then
     15 	git checkout -q rnd.${RND}.rec
     16 	git merge main
     17 else
     18 	git branch | grep ${TITLE} && \
     19 		git checkout -q ${TITLE} || \
     20 		$(git checkout -q main && git checkout -q -b ${TITLE}) || exit 1
     21 fi
     22 
     23 # if post file does not exist yet touch it
     24 [ -f "${ENTRY}" ] || touch "${ENTRY}"
     25 
     26 # open post file in favourite editor
     27 vim "${ENTRY}"
     28 
     29 # when vim closes add and commit the changes
     30 # if there are any
     31 git status | grep "${ENTRY}" || exit 0
     32 git add "${ENTRY}"
     33 git commit -S -m "${TITLE}"