Add hugo helper script
This commit is contained in:
parent
0f3f1a0c6b
commit
f3c32f21b8
33
config/bash/.local/bin/hu
Executable file
33
config/bash/.local/bin/hu
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# hu.sh:
|
||||
# Hugo wrapper script around hugo static site generator
|
||||
# Relies on BLOG_DIR to be set from environment
|
||||
|
||||
hu() {
|
||||
cd "$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
|
||||
cd "$BLOG_DIR" && hugo list all | sed 1d | awk -F',' '{print $1, $(NF-4)}' | column -t
|
||||
fi
|
||||
|
||||
if [ "$1" == "fzf" ]; then
|
||||
cd "$BLOG_DIR" && hugo list all | sed 1d | awk -F',' '{print $1, $(NF-4)}' | column -t | fzf | awk '{print $1}'
|
||||
fi
|
||||
|
||||
$SHELL
|
||||
}
|
||||
|
||||
hu "$@"
|
||||
Loading…
x
Reference in New Issue
Block a user