From 8c06691381964cf370e213b4dd8b588ca018590e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 29 Mar 2015 05:13:37 +0200 Subject: posts.sh now manages linking posts into lists --- posts.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/posts.sh b/posts.sh index a259dd4..464def8 100755 --- a/posts.sh +++ b/posts.sh @@ -2,6 +2,13 @@ shopt -s extglob nullglob +add_to_list() { + list=$(basename "$1") + file=$(basename "$2") + last_link=$(find ./lists/"$list" -regex '.*/[0-9]*$' -printf '%f\n' | sort | tail -n1) + new_link=$(printf '%03d\n' $(($last_link + 1))) + ln -s ../../posts/"$file" ./lists/"$list"/"$new_link" +} new_post() { filename="$1" @@ -9,15 +16,13 @@ new_post() { cat >posts/$filename <&2 '%s: %s\n' "${0##*/}" "$OPTLERR" exit 1;; -- cgit v1.2.3