2025-03-16 02:26:30 -04:00

31 lines
696 B
Bash
Executable File

#!/bin/bash
# hu.sh:
# Hugo wrapper script around hugo static site generator
# Relies on BLOG_DIR to be set from environment
hu() {
echo "$BLOG_DIR"
if [ "$1" == "np" ]; then
POST_NAME="$2"
if [ -z "$POST_NAME" ]; then
read -p "Enter a post title (omitting .md): " POST_NAME
fi
hugo new posts/$POST_NAME.md;
fi
if [ "$1" == "rm" ]; then
rm "$BLOG_DIR/content/posts/$2.md"
fi
if [ "$1" == "ls" ]; then
hugo list all -s "$BLOG_DIR" | sed 1d | awk -F',' '{print $1, $(NF-4)}' | column -t
fi
if [ "$1" == "fzf" ]; then
hugo list all -s "$BLOG_DIR" | sed 1d | awk -F',' '{print $1, $(NF-4)}' | column -t | fzf | awk '{print $1}'
fi
}
hu "$@"