Compare commits

...

2 Commits

Author SHA1 Message Date
Kacper Marzecki
234e3d6efc better docs, configure editor by an env var 2025-03-20 21:31:08 +01:00
Kacper Marzecki
f48445f3b6 keybind help adjustment 2025-03-19 00:59:32 +01:00
3 changed files with 56 additions and 24 deletions

View File

@ -1,20 +1,43 @@
# td
> This readme is automatically generated by [create-ink-app](https://github.com/vadimdemedes/create-ink-app)
## Install
## Install (this was generated by Ink starter, dunno if that works)
```bash
$ npm install --global td
```
# Dependencies
fzf https://github.com/junegunn/fzf
for searching & selectors
tmux
for displaying an editor in a side pane
IMPORTANT: this must be run inside tmux
Ive got a comfy tmux config I can share later if U'd want it :)
# ENV vars
TD_EDITOR
Editor for ask editing, CLI only (recommend neovim (again Ive got a comfy config I can share later if U'd want it :)))
TD_TASK_DIR
Directory for storing tasks.json and logs. Assumed to be a git repo
set them before running `td`
```bash
$ tmux
$ export TD_EDITOR=nvim
$ export TD_TASK_DIR=/home/omnissiah/git/tasks/
$ npm run buid
$ node dist/cli.js
```
or in Your .bashrc
# Manual
P.S. A more complete summary of keybinds can be displayed on `?` keybind
1. **Task Management**:
- Create, edit, delete tasks.
- View lists in a ranger-like UI https://github.com/ranger/ranger
- Tasks can have subtasks.
2. **Navigation**:
- Vim-like keybindings for navigation:
- `hjkl` to navigate in and between subtask lists.
@ -32,7 +55,7 @@ $ npm install --global td
- `a` to add a new task.
- `A` to add a new subtask.
- `a` to add a new task.
- `e` to edit the selected task using neovim.
- `e` to edit the selected task using external editor.
- `d` to delete the selected task. (with confirmation using fzf)
- `space` to toggle the completion status of a task.
@ -40,9 +63,7 @@ $ npm install --global td
- Uses neovim for text editing.
5. **Persistence**:
- Save and load tasks from a file ($HOME/.config/td/tasks.json)
- TODO: configurable location
- Save and load tasks from a file
6. **Search**:
- `/` to search for tasks (fzf).

View File

@ -7,6 +7,8 @@ import { loadTasks, saveTasks, commitAndPushTasks, pullTasks, addLog, readLog, s
import { Tabs, Tab } from 'ink-tab';
import Scrollbar from "./scrollbar.js";
// got it set to `n` - my alias for neovim
const EDITOR = process.env.TD_EDITOR || "n"
const countIncompleteSubtasks = (task) => {
if (!task.subtasks || task.subtasks.length === 0) return 0;
@ -111,11 +113,11 @@ export default function TaskApp() {
const tempFile = "/tmp/task_edit.txt";
fs.writeFileSync(tempFile, task.content || task.name);
try {
// Run Neovim in a tmux split and use "wait-for" to track when it closes
execSync(`tmux split-window -h 'n ${tempFile}; tmux wait-for -S nvim_done'`);
// Run editor in a tmux split and use "wait-for" to track when it closes
execSync(`tmux split-window -h '${EDITOR} ${tempFile}; tmux wait-for -S editing_done'`);
// Wait for Neovim to exit (blocks execution until the user quits Neovim)
execSync("tmux wait-for nvim_done");
// Wait for editor to exit (blocks execution until the user quits the editor)
execSync("tmux wait-for editing_done");
} catch (error) {
// If tmux is not available, open Neovim normally
spawn("n", [tempFile], { stdio: "inherit" });
@ -292,7 +294,12 @@ export default function TaskApp() {
if (input === "\\") {
execSync("tmux-td")
try {
execSync("command -v tmux-td");
execSync("tmux-td");
} catch (error) {
log("tmux-td is not available");
}
}
@ -311,6 +318,9 @@ export default function TaskApp() {
D - remove task
g/G - Go to top/bottom
h/l - Navigate parent/subtasks
x - cut a task
p - paste the task
P - paste the task as a subtask
a - Add task
A - Add subtask
e - Edit task in Neovim

View File

@ -7,6 +7,7 @@ if (!process.env.TD_TASK_DIR) {
const TASK_FILE = path.join(process.env.TD_TASK_DIR, "tasks.json");
const QUERY_FILE = path.join(process.env.TD_TASK_DIR, "query");
const LOG_FILE = path.join(process.env.TD_TASK_DIR, "log");
if (fs.existsSync(LOG_FILE)) {
fs.rmSync(LOG_FILE)
}