Taskwarrior: My task-switch for fast switching between multiple databases

Sprache ändern:

Taskwarrior logo Taskwarrior: My task switch for fast switching between multiple databasesTaskwarrior is a command-line todo list manager
I use it at work and at home, but that made some problems to me. It has become very confusing which task belongs to which group of my life.
Do i have to call Mr. Miller for private thing or for business ?

For solving this problem i wrote a tiny bash script and i want to share it with you

#!/bin/bash
status() {
        if [[ $(grep data.location /home/$USER/.taskrc) == data.location=/home/$USER/.task/work ]]; then #Using work?
                echo "Task is using WORK"
        elif [[ $(grep data.location /home/$USER/.taskrc) == data.location=/home/$USER/.task/home ]]; then #Using home?
                echo "Task is using HOME"
        else
                echo "Error"
        fi
}

if [[ $1 == home ]]; then
        echo "HOME activated" #Activates home
        sed -i 's/^data.location=\/home\/'${USER}'\/.task\/work/data.location=\/home\/'${USER}'\/.task\/home/' /home/$USER/.taskrc
elif [[ $1 == work ]]; then
        echo "Work activated" #Activates work
        sed -i 's/^data.location=\/home\/'${USER}'\/.task\/home/data.location=\/home\/'${USER}'\/.task\/work/' /home/$USER/.taskrc
else
        status
fi
exit 0

Just put that script to /usr/local/bin and name it task-switch

editor /usr/local/bin/task-switch

And copy the script text to it – There is an button for source view when hovering it.
Make it executable using:

chmod a+x /usr/local/bin/task-switch

Those who are into bash will notice that the .taskrc located in you /home-folder is modified. In order to make that possible you will have to create two directories in .task like that:

cd
cd .task
mkdir home work
mv *.data home-oder-work

For the last line you will have to chose if you want to migrate your existing database to ‘work’ or to ‘home’.
Use:

mv *.data home # For home

or

mv *.data work # For work

Now you have to edit the .taskrc and change the value of data.location= like that:

data.location=/home/'${USER}'/.task

change it to:

data.location=/home/'${USER}'/.task/home

Now the active database is set to ‘home’.
When executing task-switch you should get similar output:

claw@claw-hp625:~$ task-switch
Task is using HOME

If you want to switch to another database execute task followed by the database name you want to use:

claw@claw-hp625:~$ task-switch work
Work activated

If this is not working well in anyway feel free to contact me. I will try to fix your problems as soon as i can icon wink Taskwarrior: My task switch for fast switching between multiple databases

Leave a Reply

Connect with:

Your email address will not be published.


+ 4 = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>