commit bb1d2d36571da252d1cccc0c41ba797e164c2b44 parent 37e48a618ca0767bac08901a01dcc7d453bf18c5 Author: Ed van Bruggen <edvb@uw.edu> Date: Thu, 19 Apr 2018 21:21:49 -0700 Add pub script Diffstat:
_data/projects.yml | | | 2 | ++ |
projects/pub.md | | | 24 | ++++++++++++++++++++++++ |
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/_data/projects.yml b/_data/projects.yml @@ -28,6 +28,8 @@ main: desc: 'set title of a terminal' - name: 'tg' desc: 'quickly tag files' + - name: 'pub' + desc: 'prepare post to be published' - name: 'echk' desc: 'functions to display shell error code' - name: 'g' diff --git a/projects/pub.md b/projects/pub.md @@ -0,0 +1,24 @@ +--- +title: pub +description: prepare post to be published +--- + +```bash +#!/usr/bin/env bash + +# pub: prepare post to be published +# +# Moves given draft into the posts directory and prefixes the filename with the +# date so that it is ready to be published. + +if [[ $# == 0 || $# > 2 || ! -f "$1" ]]; then + echo "usage: pub FILE [POSTDIR]" + exit 1 +fi + +date=$(date +"%Y-%m-%d") +file=$(basename "$1") +postsdir=${2:-_posts} + +mv "$1" "$postsdir"/"$date"-"$file" +```