Blog |Follow Nick on Mastodon| About
 

For the last few months I've felt better at managing my actions and tasks thanks to Steve Losh's T. T is a simple python script that allows you to manage a simple task list from your shell prompt.

I use my shell all the time to ping stuff, renice processes and you know, whatever (like in the image below).....

Screenshot of T in
iTerm

... having my todo list right there in front of me has been really helpful (The numbers in the square brackets!). Steve's website suggests a quick update to your shell profile to add your task list to your prompt but I found running a python script each time I do anything quite slow, especially since I have two lists.

Below is my bash .profile file, there you can see the rather OTT change(s) I've made to integrate my todo lists into my shell prompt. I have two lists (work & personal) the number of things to do shown in my shell prompt gets updated each time the lists change (thanks to md5).... and I hide my work list over the weekend ;)

#!/bin/bash
alias p='python ~/bin/t/t.py --task-dir ~/Dropbox/Tasks --list personal.tasks --delete-if-empty'
alias w='python ~/bin/t/t.py --task-dir ~/Dropbox/Tasks --list work.tasks --delete-if-empty'

function nick_PS1 {

        if [ -e "/Users/nick/Dropbox/Tasks/Personal.tasks" ]
        then
                CurrentPersonalMD5=`md5 ~/Dropbox/Tasks/Personal.tasks | awk '{print $4}' | cat `

                if [ -e "~/.tasks.personal.md5" ]
                then
                        LastPersonalMD5=`cat ~/.tasks.personal.md5`
                fi

                if [ "$CurrentPersonalMD5" == "$LastPersonalMD5" ]
                then
                        if [ -e "~/.tasks.personal.no" ]
                        then
                                NumOfPersonal=`cat ~/.tasks.personal.no`
                        fi
                else
                        NumOfPersonal=`p | wc -l | sed -e's/ *//'`
                        echo $NumOfPersonal > ~/.tasks.personal.no
                        echo $CurrentPersonalMD5 > ~/.tasks.personal.md5
                fi

                if [ $NumOfPersonal -ne 0 ]
                then
                        LEFT='['
                        RIGHT=']'
                        Personal="p:$NumOfPersonal"
                fi

        else
                NumOfPersonal=0
        fi

DayOfWeek=`date "+%u"`
if [ $DayOfWeek -lt 6 ]
then
        if [ -e "/Users/nick/Dropbox/Tasks/Work.tasks" ]
        then
                CurrentWorkMD5=`md5 ~/Dropbox/Tasks/Work.tasks | awk '{print $4}'`

                if [ -e "~/.tasks.work.md5" ]
        then
                LastWorkMD5=`cat ~/.tasks.work.md5`
        fi

                if [ "$CurrentWorkMD5" == "$LastWorkMD5" ]
        then
                        if [ -e "~/.tasks.work.no" ]
                        then
                                NumOfWork=`cat ~/.tasks.work.no`
                        fi
                else
                                        NumOfWork=`w | wc -l | sed -e's/ *//'`
                                        echo $NumOfWork > ~/.tasks.work.no
                                        echo $CurrentWorkMD5 > ~/.tasks.work.md5
                fi

                if [ $NumOfWork -ne 0 ]
                then
                        LEFT='['
                        RIGHT=']'
                        Work="w:$NumOfWork"
                fi

        else
                NumOfWork=0
        fi
else
 NumOfWork=0
fi

        if [ $NumOfPersonal -ne 0 ]
        then
                if [ $NumOfWork -ne 0 ]
                then
                        SEP="|"
                fi
         fi

        RESULT="$LEFT$Personal$SEP$Work$RIGHT"

        if [ -z $RESULT ] 
        then
                RESULT="linickx@macbookpro"
        fi

        echo $RESULT
}

export PS1="\$(nick_PS1) \W \$"

... I think my next stop will be using geektool show the list/reminders on my desktop.

 

 
Nick Bettison ©