Generate New Posts by Shell Scripts

Mar 27, 2018

This is the shell script I use to create a new post.

The script is modified from @AamnahAkram . For more functions, you are suggested to visit the link.

#!/bin/bash
# About: Bash script to create new Jekyll posts
# Author: @AamnahAkram
# URL: https://gist.github.com/aamnah/f89fca7906f66f6f6a12
# Description: This is a very basic version of the script

# VARIABLES
######################################################

# Define the post directory (where to create the file)
HUGO_POSTS_DIR='content/posts/'

# Post title
TITLE=''

for var in "$@"
do
    TITLE=$TITLE" $var"
done

# Replace spaces in title with hyphen
TITLE_STRIPPED=${TITLE// /-}

# Date
DATE=`date +%Y-%m-%d`

# Post Type (markdown, md, textile)
TYPE='.md'

# File name structure
FILENAME=${DATE}${TITLE_STRIPPED}${TYPE}

# COMMANDS
#######################################################

# go to post directory
cd ${HUGO_POSTS_DIR}

# make a new post file
touch ${FILENAME}

# add YAML front matter and trim leading blank line
echo -e "
---
date: ${DATE}
title: ${TITLE}
categories:
    -
tags:
    -
---
" | sed '/./,$!d' > ${FILENAME}
csblogscript

Multiplicative Chernoff v.s. Additive Chernoff: Which One Is Stronger?

An Application of Doob's Martingale Inequality

comments powered by Disqus