44 lines
		
	
	
		
			843 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			44 lines
		
	
	
		
			843 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								#!/usr/bin/env bash
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								export ED='tilde'
							 | 
						||
| 
								 | 
							
								# export ED='vi'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Help()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								   # Display Help
							 | 
						||
| 
								 | 
							
								   echo "Add a new post to a hugo blog"
							 | 
						||
| 
								 | 
							
								   echo
							 | 
						||
| 
								 | 
							
								   echo "Syntax: new -c contentType -t 'some title'"
							 | 
						||
| 
								 | 
							
								   echo "options:"
							 | 
						||
| 
								 | 
							
								   echo "c    Content Type: 'post', 'podcast', 'reading'"
							 | 
						||
| 
								 | 
							
								   echo "t    Content Title: \"Any Plain Text At All\""
							 | 
						||
| 
								 | 
							
								   echo "h    This display."
							 | 
						||
| 
								 | 
							
								   exit 0
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								while getopts c:t:h flag
							 | 
						||
| 
								 | 
							
								do
							 | 
						||
| 
								 | 
							
								    case "${flag}" in
							 | 
						||
| 
								 | 
							
								        c) contentType=${OPTARG};;
							 | 
						||
| 
								 | 
							
								        t) title=${OPTARG};;
							 | 
						||
| 
								 | 
							
								        h) Help
							 | 
						||
| 
								 | 
							
								    esac
							 | 
						||
| 
								 | 
							
								done
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if [ -z "$contentType" ]; then
							 | 
						||
| 
								 | 
							
								    echo "Specify a content type. Eg. '-c post'"
							 | 
						||
| 
								 | 
							
								    exit 1
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if [ -z "$title" ]; then
							 | 
						||
| 
								 | 
							
								    echo "Specify an entry title. Eg. '-t \"The Hamburg Happening\"'"
							 | 
						||
| 
								 | 
							
								    exit 1
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								tmp=${title// /-}
							 | 
						||
| 
								 | 
							
								filename=${tmp,,}
							 | 
						||
| 
								 | 
							
								echo $filename
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								hugo new ${contentType}/${filename}.md
							 | 
						||
| 
								 | 
							
								$ED content/${contentType}/${filename}.md
							 |