justfiles for automating various tasks on my workstation
at main 3.6 kB view raw
1# New blog entry 2[group('blogging')] 3newblog slug: 4 #!/usr/bin/env bash 5 BLOG_DIR="${HOME}/repos/knot.moonshadow.dev/hyperreal.coffee/http" 6 FILENAME_DATE=$(date '+%Y-%m-%d') 7 POST_DATE=$(date '+%Y-%m-%d %H:%M:%S') 8 FILENAME="${FILENAME_DATE}-{{ slug }}.md" 9 cat <<EOF >"${BLOG_DIR}/content/posts/${FILENAME}" 10 +++ 11 title = '' 12 date = $POST_DATE 13 tags = [] 14 +++ 15 16 EOF 17 nvim "${BLOG_DIR}/content/posts/${FILENAME}" 18 echo "To convert to gemlog:" 19 echo "blog2gemlog ${BLOG_DIR}/content/posts/${FILENAME} \"Blog title\"" 20 21# Convert website page changes to gemtext and send to capsule 22[group('blogging')] 23board-capsule: 24 #!/usr/bin/env bash 25 WEBSITE_DIR="${HOME}/repos/knot.moonshadow.dev/hyperreal.coffee/http" 26 CAPSULE_DIR="${HOME}/repos/knot.moonshadow.dev/hyperreal.coffee/gemini" 27 28 find "${WEBSITE_DIR}/content" \ 29 -maxdepth 1 \ 30 -type f \ 31 -not -name "_index.md" \ 32 -exec md2gemini -w -d "$CAPSULE_DIR" -f -m {} \; 33 34 echo "To push and deploy changes, run push-deploy" 35 36# Push hyperreal.coffee changes to git and deploy website and capsule 37[group('blogging')] 38push-deploy: 39 #!/usr/bin/env bash 40 set -euo pipefail 41 42 HC_DIR="${HOME}/repos/knot.moonshadow.dev/hyperreal.coffee" 43 cd "$HC_DIR" 44 msg_info="$(( $(git rev-list --count HEAD) + 1)) $(date '+%Y-%m-%d %H:%M:%S')" 45 git add . 46 git commit -m "Update: ${msg_info}" 47 git push -u origin main 48 49 WEBSITE_DIR="${HC_DIR}/http" 50 CAPSULE_DIR="${HC_DIR}/gemini" 51 PUBLIC_DIR="${HOME}/public_html" 52 53 rm -rf "${PUBLIC_DIR}/"* 54 hugo --gc --minify -d "${PUBLIC_DIR}" -s "$WEBSITE_DIR" 55 rsync \ 56 -az \ 57 --delete \ 58 "${PUBLIC_DIR}"/ \ 59 hyperreal@hyperreal.carp-wyvern.ts.net:/home/hyperreal/staging/html 60 ssh hyperreal@hyperreal.carp-wyvern.ts.net \ 61 -- doas rsync -a --chown root:daemon --delete /home/hyperreal/staging/html/ /var/www/htdocs/hyperreal.coffee 62 63 rsync \ 64 -avz \ 65 --delete \ 66 "$CAPSULE_DIR"/ \ 67 hyperreal@hyperreal.carp-wyvern.ts.net:/home/hyperreal/staging/gemini 68 ssh hyperreal@hyperreal.carp-wyvern.ts.net \ 69 -- doas -u _gmid rsync -a --delete /home/hyperreal/staging/gemini/ /var/gemini/hyperreal.coffee 70 71 echo 72 echo "Website and capsule successfully deployed" 73 74# New feelslog entry 75[group('blogging')] 76newfeels tags: 77 #!/usr/bin/env bash 78 DATE=$(date '+%Y-%m-%d') 79 TAGS="$@" 80 FEELSDIR="${HOME}/repos/tildegit.org/hyperreal/feelslog" 81 PREV_ENTRY=$(find "$FEELSDIR/src" -name "*.md" -exec basename {} \; | sort | tail -1 | cut -c 18-21) 82 NEXT_ENTRY="00$(echo "$PREV_ENTRY" + "1" | bc)" 83 NEXT_ENTRY_FILENAME="${FEELSDIR}/src/${DATE}-entry-${NEXT_ENTRY}.md" 84 URL="$(echo "$DATE" | tr "-" "/")/entry-${NEXT_ENTRY}/" 85 cat <<EOF >"$NEXT_ENTRY_FILENAME" 86 --- 87 title: Entry $NEXT_ENTRY 88 date: $(date '+%Y-%m-%d %H:%M:%S %z') 89 tags: $(echo "${TAGS// /, }") 90 slug: entry-$NEXT_ENTRY 91 --- 92 93 EOF 94 nvim "$NEXT_ENTRY_FILENAME" 95 echo "URL: https://feels.hyperreal.coffee/${URL}" 96 97# Publish feelslog 98[group('blogging')] 99publish-feels: 100 #!/usr/bin/env bash 101 set -euo pipefail 102 BSSG_DIR="${HOME}/repos/brew.bsd.cafe/stefano/BSSG" 103 if [ ! -d "$BSSG_DIR" ]; then 104 mkdir -p "${HOME}/repos/brew.bsd.cafe/stefano" 105 git clone https://brew.bsd.cafe/stefano/BSSG.git "$BSSG_DIR" 106 else 107 cd "$BSSG_DIR" || exit 1 108 git pull 109 fi 110 FEELS_CONFIG="${HOME}/repos/tildegit.org/hyperreal/feelslog/config.sh.local" 111 "${BSSG_DIR}/bssg.sh" build --config "$FEELS_CONFIG" 112 113# vim: ts=4 sts=4 sw=4 et ft=just