pyratelog

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

draft (821B)


      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 elif [ "$TITLE" == "main" ] ; then
     18 	echo "on main branch"
     19 	exit 1
     20 else
     21 	git branch | grep ${TITLE} && \
     22 		git checkout -q ${TITLE} || \
     23 		$(git checkout -q main && git checkout -q -b ${TITLE}) || exit 1
     24 fi
     25 
     26 # if post file does not exist yet touch it
     27 [ -f "${ENTRY}" ] || touch "${ENTRY}"
     28 
     29 # open post file in favourite editor
     30 vim "${ENTRY}"
     31 
     32 # when vim closes add and commit the changes
     33 # if there are any
     34 git status | grep "${ENTRY}" || exit 0
     35 git add "${ENTRY}"
     36 git commit -S -m "${TITLE}"