Todo.txt TUI

Todo.txt TUI is a highly customizable terminal-based application for managing your todo tasks. It follows the todo.txt format and offers a wide range of configuration options to suit your needs.

Installation

crates.io

You can install the application directly from crates.io using the following command:

cargo install todotxt-tui

Manual Installation

  1. Clone the repository.

  2. Build the application using Rust's package manager, Cargo:

cargo build --release

Copy the executable from the target directory to a directory included in your system's PATH:

cp target/release/todotxt-tui /usr/local/bin/

Initial Setup

To set up the basic configuration, create a directory named todotxt-tui in your configuration folder (the default is $HOME/.config). Then, export the default configuration to this directory:

todotxt-tui --export-default-config "$HOME/.config/todotxt-tui/todotxt-tui.toml"

If todotxt-tui does not find the configuration folder, it will prompt you to create one.

Next, open the configuration file and set the todo_path to the path of your todo.txt file. Environment variables or ~ will be expanded if the path is in UTF-8 format.

Autocomplete

You can generate an autocomplete script for Bash and source it:

todotxt-tui --export-autocomplete ./autocomplete-todotxt-tui.sh
source ./autocomplete-todotxt-tui.sh

Alternatively, if you prefer on-the-fly autocompletion, you can add this to your .bashrc:

source <(todotxt-tui --export-autocomplete /dev/stdout)

Usage

Todo.txt TUI is a powerful and flexible terminal-based interface designed to simplify task management. Its customization options allow you to tailor the tool to fit your workflow. Below, you'll find a comprehensive list of keybindings and actions, organized by category, to help you get started. All actions can be customized in the configuration file to suit your preferences.

Keybindings

Navigation:

  • j: Move down to the next task in the list.
  • k: Move up to the previous task in the list.
  • g: Jump directly to the first task in the list.
  • G: Jump directly to the last task in the list.

Managing Tasks:

  • Enter: Show task in preview.
  • U: Move the currently selected task up in the list.
  • D: Move the currently selected task down in the list.
  • x: Remove the selected task permanently from the list.
  • d: Toggle a task's status between pending and done.
  • I: Input a new task into the list.
  • E: Edit the currently selected task to update its details.

Widget Navigation:

  • J: Jump to the widget located below the current one.
  • K: Jump to the widget located above the current one.
  • H: Move to the widget on the left side of the current one.
  • L: Move to the widget on the right side of the current one.

Filtering and Searching Tasks:

  • Backspace: Apply a filter to display specific categories in the pending or done lists.
  • /: Search for a keyword or phrase within the current list.
  • n: Navigate to the next occurrence of the search term.
  • N: Navigate to the previous occurrence of the search term.
  • h: Clear the current search term and reset the list view.

File Operations:

  • S: Save all current tasks to the todo.txt file.
  • u: Reload tasks from the todo.txt file to update the list with external changes.

Quit:

  • q: Quit Todo.txt TUI and save any unsaved changes.

Task Input Bar

The task input bar allows you to add or edit tasks. Press Enter to confirm the input and save the task, or press Esc to cancel. Additionally, common Bash/Emacs keybindings are supported:

  • Ctrl+w: Delete the previous word.
  • Ctrl+e: Move the cursor to the end of the line.
  • Ctrl+a: Move the cursor to the beginning of the line.
  • Ctrl+k: Delete from the cursor to the end of the line.
  • Ctrl+u: Delete from the cursor to the beginning of the line.

Configuration

Todo.txt TUI provides extensive customization options through a TOML configuration file located in the todotxt-tui/todotxt-tui.toml directory. Configuration settings can be overridden using flags or environment variables, with the following priority order:

  1. Flags
  2. Environment variables
  3. Configuration file

For a complete list of available flags, use the help option (--help).

Configuration Folder Lookup

The application checks for the configuration folder in the following order:

  1. $XDG_CONFIG_HOME
  2. If $XDG_CONFIG_HOME is not set, $HOME/.config is used.

The default configuration folder can be changed using the --config-path <PATH> flag.

Relationship Between Flags, Environment Variables, and Configuration Keys

Flags, environment variables, and configuration keys share a consistent naming pattern:

  • Flags use kebab-case (e.g., --pending-sort).
  • Environment variables are in uppercase, use underscores instead of hyphens, and are prefixed with TODOTXT_TUI_ (e.g., $TODOTXT_TUI_PENDING_SORT).
  • Configuration keys use snake_case (e.g., pending_sort).

Value Consistency

Most values are interchangeable between flags, environment variables, and configuration keys. However, when using the configuration file, values should be written in PascalCase instead of kebab-case.

Example

For alphanumeric-reverse:

  • Flag: --alphanumeric-reverse
  • Environment variable: $TODOTXT_TUI_ALPHANUMERIC_REVERSE
  • Configuration key (in the TOML file): AlphanumericReverse

UI

Flag: -i, --init-widget
Env: $TODOTXT_TUI_INIT_WIDGET
Conf: init_widget
The widget that will be active when the application starts.
  • Possible values (flag, env): list, done, project, context, hashtag, preview
  • Possible values (config): List, Done, Project, Context, Hashtag, Preview
  • Default: List

Flag: -t, --window-title
Env: $TODOTXT_TUI_WINDOW_TITLE
Conf: window_title
The title of the window when `todotxt-tui` is opened.
  • Default: ToDo TUI

Flag: -W, --window-keybinds
Env: $TODOTXT_TUI_WINDOW_KEYBINDS
Conf: window_keybinds
Defines the keybinds for window actions.

Default:

I  = "InsertMode"
L  = "MoveRight"
q  = "Quit"
K  = "MoveUp"
"/" = "SearchMode"
S  = "Save"
u  = "Load"
H  = "MoveLeft"
J  = "MoveDown"
E  = "EditMode"

Flag: -R, --list-refresh-rate
Env: $TODOTXT_TUI_LIST_REFRESH_RATE
Conf: list_refresh_rate
Specifies the refresh rate for the UI when no keys are pressed. This is particularly useful if the to-do list is modified by a different program.
  • Default value: 5 seconds
  • The configuration can also specify nanoseconds for finer granularity.

Configuration Example:

[list_refresh_rate]
secs = 5
nanos = 0

Flag: -S, --save-state-path
Env: $TODOTXT_TUI_SAVE_STATE_PATH
Conf: save_state_path
The path to save the application's state (currently unused).

Flag: -l, --layout
Env: $TODOTXT_TUI_LAYOUT
Conf: layout
The layout setting allows you to define a custom layout for the application using blocks `[]`. You can specify the orientation of the blocks as either `Direction: Vertical` or `Direction: Horizontal`, along with the size of each block as a percentage or value. Within these blocks, you can include various widgets, such as:
  • List: The main list of tasks.
  • Preview: The task preview section.
  • Done: The list of completed tasks.
  • Projects: The list of projects.
  • Contexts: The list of contexts.
  • Hashtags: The list of hashtags.

Here's an example of a custom layout configuration:

[
    Direction: Horizontal,
    Size: 50%,
    [
        List: 50%,
        Preview,
    ],
    [ Direction: Vertical,
      Done,
      [
        Contexts,
        Projects,
      ],
    ],
]

This example creates a layout with a horizontal split, where the list takes up 50% of the width, and the preview occupies the remaining space. On the right side, there's a vertical split with the list of completed tasks, contexts, and projects.


To-do list

Flag: --use-done
Env: $TODOTXT_TUI_USE_DONE
Conf: use_done
Determines whether projects, contexts, and tags from completed tasks should be included in the lists of available projects, contexts, and tags.
  • Default: false

Flag: --pending-sort
Env: $TODOTXT_TUI_PENDING_SORT
Conf: pending_sort
Specifies the sorting option for pending tasks.
  • Possible Values (Flag): none, reverse, priority, alphanumeric, alphanumeric-reverse
  • Possible Values (Config): None, Reverse, Priority, Alphanumeric, AlphanumericReverse
  • Default: None

Sorting Options:

  • None: No specific sorting; tasks appear in the order they were added.
  • Reverse: Reverse the order of tasks.
  • Priority: Sort tasks by priority.
  • Alphanumeric: Sort tasks in alphanumeric order.
  • AlphanumericReverse: Sort tasks in reverse alphanumeric order.

Flag: --done-sort
Env: $TODOTXT_TUI_DONE_SORT
Conf: done_sort
Specifies the sorting option for completed tasks.
  • Possible Values (Flag): none, reverse, priority, alphanumeric, alphanumeric-reverse
  • Possible Values (Config): None, Reverse, Priority, Alphanumeric, AlphanumericReverse
  • Default: None

Flag: --delete-final-date
Env: $TODOTXT_TUI_DELETE_FINAL_DATE
Conf: delete_final_date
Specifies whether to delete the final date (if it exists) when a task is moved from completed back to pending.
  • Default: true

Flag: --set-final-date
Env: $TODOTXT_TUI_SET_FINAL_DATE
Conf: set_final_date
Configures how the final date is handled when a task is marked as completed.
  • Possible Values (Flag): override, only-missing, never
  • Possible Values (Config): Override, OnlyMissing, Never
  • Default: OnlyMissing

Final Date Options:

  • Override: Set the final date every time a task is marked as completed.
  • OnlyMissing: Set the final date only if it is not already set.
  • Never: Never set the final date.

File worker

Flag: --todo-path
Env: $TODOTXT_TUI_TODO_PATH
Conf: todo_path
Specifies the path to the `todo.txt` file that serves as the main task database. This file contains all your active tasks and is essential for managing your to-do list within the application.

default: $HOME/todo.txt


Flag: --archive-path
Env: $TODOTXT_TUI_ARCHIVE_PATH
Conf: archive_path
Specifies the path to the `archive.txt` file, where completed tasks are stored. If not provided, completed tasks are moved to the `todo.txt` file instead of being saved in a separate archive file.

Flag: -d, --autosave-duration
Env: $TODOTXT_TUI_AUTOSAVE_DURATION
Conf: autosave_duration
Defines the interval, in seconds, for automatic saving of changes to the `todo.txt` file. Is used only if `save_policy` is set to `AutoSave`.

default: 900


Flag: -f, --file-watcher
Env: $TODOTXT_TUI_INIT_WIDGET
Conf: file_watcher
Enables or disables the file-watcher functionality. When enabled, the application monitors the `todo.txt` (_and optionally `archive.txt`_) file for external changes and automatically reloads.

default: true


Flag: -i, --save-policy
Env: $TODOTXT_TUI_SAVE_POLICY
Conf: save_policy
Determines the policy for saving changes to the todo.txt file and, optionally, the archive.txt file.
  • ManualOnly: Requires explicit user action to save changes.
  • AutoSave: Automatically saves changes at intervals defined by `autosave_duration.
  • OnChange: Saves changes immediately whenever modifications occur.

default: OnChange


Widget

Flag: -T, --tasks-keybind
Env: $TODOTXT_TUI_TASKS_KEYBIND
Conf: tasks_keybind
Defines the keybindings used for interacting with task items within the application. These bindings allow you to quickly navigate, edit, and perform actions on tasks.

default:

d = "MoveItem"
x = "RemoveItem"
D = "SwapDownItem"
n = "NextSearch"
U = "SwapUpItem"
Enter = "Select"
N = "PrevSearch"

Flag: -C, --category-keybind
Env: $TODOTXT_TUI_CATEGORY_KEYBIND
Conf: category_keybind
Specifies the keybindings for managing and navigating categories such as projects and contexts. These categories help you organize tasks effectively.

default:

Enter = "Select"
n = "NextSearch"
N = "PrevSearch"
Backspace = "Remove"

Flag: -i, --border-type
Env: $TODOTXT_TUI_BORDER_TYPE
Conf: border_type
Defines the style of borders used in the application's user interface. Options include:

possible values (flag, env): plain, rounded, double, thick possible values (conf): Plain, Rounded, Double, Thick default: Rounded


List

Flag: -s, --list-shift
Env: $TODOTXT_TUI_LIST_SHIFT
Conf: list_shift
Determines the number of lines displayed above and below the currently active item in a list when scrolling. This helps maintain context around the active task during navigation.

default: 4


Flag: -L, --list-keybind
Env: $TODOTXT_TUI_LIST_KEYBIND
Conf: list_keybind
Configures the keybindings for interacting with task lists. These bindings enable efficient scrolling, selection, and manipulation of list items.

default:

G = "ListLast"
h = "CleanSearch"
k = "ListUp"
g = "ListFirst"
j = "ListDown"

Preview

Defines the format string used to generate the preview pane, which provides a detailed view of the selected task. You can use placeholders to include dynamic content based on task attributes and apply text styling with the new format syntax.

Formatting Rules

Text Colors: Enclose text in [...] and specify the style in parentheses. As style you can use any color definition from Colors

Examples:

  • [some text](Red) sets the text to have a red foreground.
  • [some text](^Red) sets the text to have a red background.
  • [some text](Blue Bold) sets the text to have a bold, blue foreground.

Dynamic Variables: Insert task-specific values using $name. You can use the following variables to represent task attributes:

VariableDescription
$pendingNumber of pending tasks.
$doneNumber of completed tasks.
$subjectTask subject.
$priorityTask priority.
$create_dateTask creation date.
$finish_dateTask finish date.
$finishedTask finished status (true or false).
$threshold_dateTask threshold date.
$due_dateTask due date.
$contextsTask contexts.
$projectsTask projects.
$hashtagsTask hashtags.
otherSpecial values for custom key-value pairs in the todo.txt format

Example format string:

[Pending: $pending](#ff0000) [Done: $done](^Green)
[Subject: $subject](Blue Bold)
[Priority: $priority](priority:A)
[Created: $create_date](^Yellow)
[Link: $link](^9)

This example configures the preview pane with styled text for pending and completed tasks, task details, and dynamic values based on attributes.

Options

Flag: -p, --preview-format
Env: $TODOTXT_TUI_PREVIEW_FORMAT
Conf: preview_format

Defines the format string used to generate the preview pane, which provides a detailed view of the selected task. Placeholders allow dynamic content customization based on task attributes. Format description is above.

default:

Pending: $pending Done: $done
Subject: $subject
Priority: $priority
Create date: $create_date
Link: $link"""

Flag: -w, --wrap-preview
Env: $TODOTXT_TUI_INIT_WIDGET
Conf: wrap_preview
Determines whether the text in the preview pane should wrap to fit the available display width. When enabled, long lines are broken into multiple lines for better readability.

default: true


Colors

In Todo.txt TUI, you can customize the colors and text styles for various elements to suit your preferences. The customization options include setting foreground (fg) and background (bg) colors, as well as applying text modifiers to style the text.

Defining Colors

You can specify colors in the following formats:

  • Named Colors: Use standard color names, e.g., "Black", "Red", etc.
  • RGB Values: Use hexadecimal codes, e.g., "#ff0000" for red.
  • Terminal Index: Use terminal color indices, e.g., "9" for bright red.

Applying Text Modifiers

Modifiers allow you to style text with additional visual effects. Available modifiers include:

  • Bold: Makes the text bold.
  • Italic: Applies italic styling.
  • Underlined: Underlines the text.

Example Configuration

To configure custom colors and text modifiers for the project +todo-tui, update your Todo.txt TUI application's TOML configuration file as follows:

[custom_category_style."+todo-tui"]
fg = "#ff0000"      # Set foreground color to red (RGB value)
bg = "Black"        # Set background color to black (named color)
modifiers = "Italic"  # Apply italic styling

This configuration will style the text for +todo-tui with a red foreground, black background, and italicized text.

Options

Flag: -A, --list-active-color
Env: $TODOTXT_TUI_LIST_ACTIVE_COLOR
Conf: list_active_color
Specifies the visual style used to highlight the currently active item in a list. This style helps you quickly identify the selected task.

default:

bg = "LightRed"

Flag: -P, --pending-active-color
Env: $TODOTXT_TUI_PENDING_ACTIVE_COLOR
Conf: pending_active_color
Specifies the text style for highlighting active tasks in the pending list. This overrides `list_active_color`.

Flag: -D, --done-active-color
Env: $TODOTXT_TUI_DONE_ACTIVE_COLOR
Conf: done_active_color
Specifies the text style for highlighting active tasks in the completed list. This overrides `list_active_color`.

Flag: --category-active-color
Env: $TODOTXT_TUI_CATEGORY_ACTIVE_COLOR
Conf: category_active_color
Specifies the text style for highlighting active categories. This overrides `list_active_color`.

Flag: --projects-active-color
Env: $TODOTXT_TUI_PROJECTS_ACTIVE_COLOR
Conf: projects_active_color
Specifies the text style for highlighting active projects. This overrides `category_active_color`.

Flag: --contexts-active-color
Env: $TODOTXT_TUI_CONTEXTS_ACTIVE_COLOR
Conf: contexts_active_color
Specifies the text style for highlighting active contexts. This overrides `category_active_color`.

Flag: --tags-active-color
Env: $TODOTXT_TUI_TAGS_ACTIVE_COLOR
Conf: tags_active_color
Specifies the text style for highlighting active tags. This overrides `category_active_color`.

Styles

Flag: --active-color
Env: $TODOTXT_TUI_ACTIVE_COLOR
Conf: active_color
Sets the color used to indicate the active window or element within the application. This provides a visual cue for the currently focused UI component.

default: Red


Flag: --priority-style
Env: $TODOTXT_TUI_PRIORITY_STYLE
Conf: priority_style
Defines the styles applied to tasks based on their priority levels.

default:

A.fg = "Red"
B.fg = "Yellow"
C.fg = "Blue"

Flag: --projects-style
Env: $TODOTXT_TUI_PROJECTS_STYLE
Conf: projects_style
Specifies the text style for displaying projects within the task list. Projects are identified by their `+ProjectName` syntax.

Flag: --contexts-style
Env: $TODOTXT_TUI_CONTEXTS_STYLE
Conf: contexts_style
Sets the text style for displaying contexts in the task list. Contexts are identified by their `@ContextName` syntax.

Flag: --hashtags-style
Env: $TODOTXT_TUI_HASHTAGS_STYLE
Conf: hashtags_style
Configures the text style for displaying hashtags in the task list. Hashtags are identified by their `#HashtagName` syntax.

Flag: --category-style
Env: $TODOTXT_TUI_CATEGORY_STYLE
Conf: category_style
Defines the default text style for displaying projects, contexts, and hashtags. This serves as the base style and is overridden by specific configurations for individual categories.

Flag: --category-select-style
Env: $TODOTXT_TUI_CATEGORY_SELECT_STYLE
Conf: category_select_style
Specifies the text style applied to categories when they are selected for filtering.

default:

fg = "Green"

Flag: --category-remove-style
Env: $TODOTXT_TUI_CATEGORY_REMOVE_STYLE
Conf: category_remove_style
Specifies the text style applied to categories that are filtered out from the view.

default:

fg = "Red"

Flag: --custom-category-style
Env: $TODOTXT_TUI_CUSTOM_CATEGORY_STYLE
Conf: custom_category_style
Allows custom text styles to be applied to specific categories by name. Note: Custom styles defined here will override all other category-specific styles, including `category_style`, `category_select_style`, and `category_remove_style`

default:

"+todo-tui".fg = "LightBlue"

Flag: --highlight
Env: $TODOTXT_TUI_HIGHLIGHT
Conf: highlight
Specifies the text style for highlighting elements in the task list that match a search query.

default:

bg = "Yellow"

Hooks

Flag: --pre-new-task
Env: $TODOTXT_TUI_PRE_NEW_TASK
Conf: pre_new_task
Path to the script executed before creating a new task. If none, no action is taken before a new task is created

Flag: --post-new-task
Env: $TODOTXT_TUI_POST_NEW_TASK
Conf: post_new_task
Path to the script executed after creating a new task. If none, no action is taken after a new task is created

Flag: --pre-remove-task
Env: $TODOTXT_TUI_PRE_REMOVE_TASK
Conf: pre_remove_task
Path to the script executed before removing a task. If none, no action is taken before a task is removed

Flag: --post-remove-task
Env: $TODOTXT_TUI_POST_REMOVE_TASK
Conf: post_remove_task
Path to the script executed after removing a task. If none, no action is taken after a task is removed

Flag: --pre-move-task
Env: $TODOTXT_TUI_PRE_MOVE_TASK
Conf: pre_move_task
Path to the script executed before moving a task. If none, no action is taken before a task is moved

Flag: --post-move-task
Env: $TODOTXT_TUI_POST_MOVE_TASK
Conf: post_move_task
Path to the script executed after moving a task. If none, no action is taken after a task is moved

Flag: --pre-update-task
Env: $TODOTXT_TUI_PRE_UPDATE_TASK
Conf: pre_update_task
Path to the script executed before updating a task. If none, no action is taken before a task is updated

Flag: --post-update-task
Env: $TODOTXT_TUI_POST_UPDATE_TASK
Conf: post_update_task
Path to the script executed after updating a task. If none, no action is taken after a task is updated