Works on Windows using Git shell;
- Save the shell script in the "\tasks" folder on your blog.
- Use command to execute:
sh .\tasks\post.sh "A Brilliant Post"
The last line will open the new post in Brackets.
| #!/usr/bin/env bash | |
| if [ -z "$1" ]; then | |
| echo "Usage: provide a title argument." | |
| exit -1 | |
| else | |
| title="$@" | |
| fi | |
| d=$(date +"%Y-%m-%d") | |
| slug=$(echo $title | tr '[:upper:]' '[:lower:]' | tr '[:space:]' '-') | |
| slug="${slug:0:${#slug}-1}" | |
| post="./_posts/$d-$slug.md" | |
| body="" | |
| read -d '' body <<EOF | |
| --- | |
| layout: post | |
| title: $title | |
| categories: | |
| - | |
| --- | |
| EOF | |
| echo "$body" > $post | |
| brackets $post |