Hugo Custom Deployment Script Using rsync With Version Checking

You know, there are moments in life that spark a bit of annoyance—like when you see double quotes misaligned on a shop sign. My wife has a talent for identifying these little quirks, often asking, “Do you know what I hate?” It’s endearing, really. While I might not keep a formal list of grievances with the world at large, I certainly have a catalog of digital frustrations. Take, for example, the maintenance of my personal website. I cherish having a digital space to call my own, but the upkeep? Not so much. After a few weeks away, I find myself grappling with the intricacies of updating git submodules or deciphering the commit hashes that seem to have a vendetta against me. It’s enough to make anyone wish for a bit of automation. ...

March 25, 2025 · 5 min · 1009 words

Streamlining Hugo Post Creation with Bash

If you find it annoying to have to manually create a specific directory structure every time you want to create a post in Hugo using the Academic theme, then you need this simple bash script to do the steps for you!

August 11, 2020 · 3 min · 557 words

Read a Filtered List of Files from a Directory and Ask the User to Choose One (Bash)

One of the standout features of Docksal is its extensibility through Bash scripting, making it a valuable tool for automating various tasks. A common scenario is the need to import databases when initializing projects. The snippet below serves this purpose by scanning a directory for database files and allowing the user to select which one to import. # Get a list of *.mysql | *.sql.gz | *.sql in /db/ and let the user choose which to import unset options i while IFS= read -r -d $'\0' f; do options[i++]="$f" done < <(find ${PROJECT_ROOT}/db/ -maxdepth 1 -type f \( -name "*.mysql" -o -name "*.sql.gz" -o -name "*.sql" \) -print0) echo "Press [Enter] to choose a DB to import" read -t5 -p "(times out in 5 seconds) " if [ $? -gt 0 ]; then echo "" echo "Timed out waiting for response. Skipping DB import..." else select opt in "${options[@]}" "Skip DB Import" do case $opt in *.mysql | *.sql.gz | *.sql) echo "Importing $opt ..." fin db import $opt break ;; "Skip DB Import") echo "Skipping DB Import..." break ;; *) echo "Invalid choice, please enter the number of your choice above." ;; esac done fi This script effectively searches a specified directory for files that match certain extensions and prompts the user to make a selection. The inclusion of a timeout is a thoughtful touch, especially for scripts designed to run unattended or as part of a larger automation workflow. ...

September 30, 2019 · 2 min · 369 words