I use taskwarrior as my project management tool, and when I’m working on a given project, I always have a tmux pane in the project’s root folder that I use for dealing with taskwarrior tasks.

Having to add pro:my_project to each and every command is a pain, so I came up with this function (I’ve added it to my .zshrc, but you can make a stand alone script with it):

function t() {
    project=$(basename `pwd`);
    tp=( $(task _projects | grep $project) );

    if [[ -n $tp ]]; then
        task "$@" project:$project;
    else
        task "$@"
    fi
}

As you can see, this function assumes that your project in taskwarrior is called exactly like your project root folder.

So now, when you use t instead task, if you’re not in one of your projects root folder, it will work as usual:

daniel@malbec ~ » t
[task next]

ID Project       Pri Due A Age Urgency Description                                                     
 3 my_project_1  H          1h       7 re dek headings on new meta                                     
 2 my_project_2             2h       1 Tutorial: How to use an image instead of "open" and "closed"    

2 tasks

but if you are in one of your projects folder:

daniel@malbec Sites/my_project_1 (server/dev %) » t
[task next project:my_project_1]

ID Project       Pri Due A Age Urgency Description                    
 3 my_project_1  H          1h       7 re dek headings on new meta    

1 task

daniel@malbec Sites/my_project_1 (server/dev %) » t add "my test task"
Created task 4.
The project 'my_project_1' has changed.  Project 'my_project_1' is 0% complete (3 of 3 tasks remaining).

daniel@malbec Sites/my_project_1 (server/dev %) » t
[task next project:my_project_1]

ID Project       Pri Due A Age Urgency Description                    
 3 my_project_1 H          1h       7 re dek headings on new meta    
 4 my_project_1            2s       1 my test task                   

2 tasks

daniel@malbec Sites/my_project_1 (server/dev %) » t 4 del
Permanently delete task 4 'my test task'? (yes/no) y
Deleting task 4 'my test task'.
Deleted 1 task.
The project 'my_project_1' has changed.  Project 'my_project_1' is 0% complete (2 of 2 tasks remaining).

daniel@malbec Sites/my_project_1 (server/dev %) » t long
ID Project       Pri Added     Started Due Recur Countdown Age Deps Tags Description                
 3 my_project_1  H   1/21/2013                 -            1h           re dek headings on new meta

1 task