How to Manage Your Todo Tasks From The Linux Terminal With todo.txt
todo.txt is a plain text file that follows a special formatting rule. A single line in this todo.txt file represents one todo task. Instead of manually handling this text file, we can use the todo.txt-cli (todo.sh
)tool to manage it.
This tutorial is a guide on how to install todo.txt-cli and start using the todo.sh
script for managing your todo tasks from the Linux terminal.
1. INSTALLING todo.txt-cli
For installing todo.txt-cli (todo.sh
), we have to clone the official git repository and use the make
command to install it.
First, we need to install git
and make
. On Ubuntu, we can install them with apt
,
sudo apt install -y git make
After installing git
and make
, we can proceed to clone the git repository.
git clone https://github.com/todotxt/todo.txt-cli.git
cloning into 'todo.txt-cli'... remote: Enumerating objects: 21, done. remote: Counting objects: 100% (21/21), done. remote: Compressing objects: 100% (18/18), done. remote: Total 2322 (delta 8), reused 5 (delta 3), pack-reused 2301 Receiving objects: 100% (2322/2322), 5.63 MiB | 2.48 MiB/s, done. Resolving deltas: 100% (1392/1392), done.
Next, cd
into the todo.txt-cli
folder and run the make
command.
cd todo.txt-cli make
We could run make install
now, but that would install it in the default location of /usr/local/bin
. That will be very inconvenient for the script to work properly unless we are logged in as root. So, to avoid such problems, we will install the script into the bin
folder in our home directory.
sudo make install CONFIG_DIR=$HOME/.todo INSTALL_DIR=$HOME/bin BASH_COMPLETION=/usr/share/bash-completion/completions
INSTALL_DIR
: PATH for executables (default /usr/local/bin
)
CONFIG_DIR
: PATH for todo.txt config
BASH_COMPLETION
: PATH for autocompletion scripts (default to /etc/bash_completion.d
)
Then we need to correct some permissions,
sudo chown -R reiri:reiri $HOME/bin sudo chown -R reiri:reiri $HOME/.todo
Note: Replace reiri
it with your username.
Now we need to copy the default config file (todo.cfg
) into the .todo
folder in our home directory.
cp todo.cfg $HOME/.todo/config
Next, If your home bin
folder is not already in the PATH
variable, or if you are unsure about it, run the following command. It will add the home bin
folder to the PATH
variable.
source ~/.profile
Note: If you are using a Linux desktop environment, a log-off and log back in will be required to make the above action persist onto to newly opened terminal windows.
Run the following command and see if todo.sh
is working.
todo.sh
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description] Try 'todo.sh -h' for more information.
2. USING todo.txt-cli
Now, we can start using todo.sh
for our todo list needs.
I. ADD A TASK
We can use the add
option to add a task onto our todo list.
todo.sh add "Buy milk"
1 Buy milk TODO: 1 added.
One more example,
todo.sh add "Buy rice"
2 Buy rice TODO: 2 added.
II. SEE THE TASKS
To list the tasks we added, we can use the list
or ls
option.
todo.sh list
1 Buy milk 2 Buy rice 4 Do laundry 6 Do the dishes 3 Feed the fish 5 Make dinner -- TODO: 6 of 6 tasks shown
To list tasks that contain the word "do" in it,
todo.sh ls do
4 Do laundry 6 Do the dishes -- TODO: 2 of 6 tasks shown
To list tasks that does not contain the word "do" in it,
todo.sh ls -do
1 Buy milk 2 Buy rice 3 Feed the fish 5 Make dinner -- TODO: 4 of 6 tasks shown
III. MARK AS DONE
To mark a task as done, we can use the done
or do
option along with the task number.
todo.sh done 3
3 x 2020-12-22 Feed the fish TODO: 3 marked as done. x 2020-12-22 Feed the fish TODO: /home/reiri/bin/todo.txt archived.
IV. DELETE A TASK
To delete a task from the todo list, we can use the del
or rm
option along with the task number. It will ask for confirmation before removing the entry from the list.
todo.sh del 4
Delete 'Make dinner'? (y/n)
y
4 Make dinner
TODO: 4 deleted.