Directories created under $BASEDIR are treated as profiles (if they exist). The default profile is assumed to be 'default'.
Directories created under $BASEDIR are treated as profiles (if they exist). The default profile is assumed to be 'default'.
Specify -p <profile> as the first argument to $0 to operate on a different one
Specify -p <profile> as the first argument to $0 to operate on a different one
Run with "asset" to spin up a new empty file with an asset tag. This is currently assumed to be plain text that complements the log, but makes little sense to included.
At some point this will be expanded to handle other files
Run with "asset <ID>" to open said asset.
Run with "review" ($0 review), and you will get a rundown of complete and incomplete tasks for the week.
Run with "review" ($0 review), and you will get a rundown of complete and incomplete tasks for the week.
@ -62,6 +58,7 @@ EOF
}
}
function review() {
function review() {
shift
DATE_START=${1:-"-7 days"}
DATE_START=${1:-"-7 days"}
DATE_END=${2:-"yesterday"}
DATE_END=${2:-"yesterday"}
@ -103,7 +100,8 @@ function review() {
}
}
function schedule() {
function schedule() {
if [ ${1:--1} -eq -1 ] || [ "$1" == "edit" ]; then
shift
if [ "$1" == "edit" ]; then
if [ -f "$CLDIR/schedule"* ];then
if [ -f "$CLDIR/schedule"* ];then
vi -p "$CLDIR/schedule"*
vi -p "$CLDIR/schedule"*
@ -148,55 +146,25 @@ function captains_log() {
# Create files if they don't exist
# Create files if they don't exist
if [ ${1-x} == 'x' ]; then
for i in YESTERDAY TODAY TOMORROW; do
for i in YESTERDAY TODAY TOMORROW; do
if ! [ -f "$CLDIR/${!i}" ]; then
generate_file ${!i}
done
if [ -f "$CLDIR/backlog" ]; then
vi $CLDIR/{$YESTERDAY,$TODAY,$TOMORROW,backlog} -s <( echo -e ":vsplit\n:wincmd w\n:next\n:vsplit\n:wincmd w\n:next\n:split\n:wincmd w\n:next")
else
vi -O $CLDIR/{$YESTERDAY,$TODAY,$TOMORROW}
fi
else
generate_file $1
vi $CLDIR/$(date -d "$1" "+%F")
fi
asset generate_links
if [ $GIT -ne 0 ]; then
echo Updating git...
if [ $( git -C "$CLDIR" status -s |wc -l) -ne 0 ]; then
git -C "$CLDIR" add -A
git -C "$CLDIR" commit -qm "Auto-Commit by $(basename $0)"
git -C "$CLDIR" push -q
fi
fi
}
function generate_file() {
# Create files if they don't exist
F=$(date -d "${1:-$(date +%F)}" "+%F")
if ! [ -f "$CLDIR/${F}" ]; then
# If there's a template and it's executable, execute it and output the result to the file,
# If there's a template and it's executable, execute it and output the result to the file,
# If it's not executable, replate {{DATE <date-compatible formate>}} with said date/formate
# If it's not executable, replate {{DATE <date-compatible formate>}} with said date/formate
if [ "$DATE_ARGS" == 'DATE' ]; then DATE_ARGS='%A %d %B %Y'; fi
if [ "$DATE_ARGS" == 'DATE' ]; then DATE_ARGS='%A %d %B %Y'; fi
debug "From static template with DATE_ARGS=$DATE_ARGS"
debug "From static template with DATE_ARGS=$DATE_ARGS"
sed "s/{{DATE[^}]*}}/$(date "+$DATE_ARGS" -d ${F})/g" $CLDIR/template > $CLDIR/${F}
sed "s/{{DATE[^}]*}}/$(date "+$DATE_ARGS" -d ${!i})/g" $CLDIR/template > $CLDIR/${!i}
else
else
echo -e "$(date "+%A %d %B %Y" -d ${!F})\nWhat do you want to accomplish today?\n\nWhat are your notes for today?\n\nWhat do you need to follow up tomorrow?\n" > "$CLDIR/${!F}"
echo -e "$(date "+%A %d %B %Y" -d ${!i})\nWhat do you want to accomplish today?\n\nWhat are your notes for today?\n\nWhat do you need to follow up tomorrow?\n" > "$CLDIR/${!i}"
fi
fi
fi
fi
done
# Read from the "scheduled" file, and put lines into the appropriate file if extant
# Read from the "scheduled" file, and put lines into the appropriate file if extant
@ -205,19 +173,21 @@ function generate_file() {
SCHEDULED=0
SCHEDULED=0
SCHED=$(echo $line|cut -d' ' -f1)
SCHED=$(echo $line|cut -d' ' -f1)
TASK=$(echo $line|cut -d' ' -f2-)
TASK=$(echo $line|cut -d' ' -f2-)
# Check if the schedule is DATE_FORMAT=MATCH_EXPRESSION otherwise assume %F