1#!/bin/bash 2# 3# Generate a TODO with a unique hash and priority level to allow tracking. 4# 5# Usage: ./gen_todo.sh 2 "Implement this." 6# 7# Output: TODO(P2-a07e5416): Implement this. 8 9# Quit if any command produces an error. 10set -e 11 12# Check the positional arguments, assign defaults or prompt the user. 13if [ $# -lt 2 ]; 14then 15 read -p "Priority (ex: 0, 1, 2 or 3):" 16 if [ -z $REPLY ] 17 then 18 PRIORITY="?" 19 else 20 PRIORITY=$REPLY 21 fi 22 23 read -p "Description (ex: 'Implement this.'):" 24 TODO_TEXT=$REPLY 25else 26 PRIORITY=$1 27 TODO_TEXT=$2 28fi 29 30# Build the TODO string. 31TIME=`date +%s.%N` 32SHASUM=`echo $TIME | shasum` 33TODO_ID=${SHASUM:0:6} 34TODO_STR="TODO(P$PRIORITY-$TODO_ID): $TODO_TEXT" 35echo $TODO_STR 36