Compare commits

..

No commits in common. "234e3d6efc78ff7e83a80345ef23090c6a16adfd" and "96ba769603b74dc63cbf9adf08d93319ef902b7d" have entirely different histories.

3 changed files with 24 additions and 56 deletions

View File

@ -1,61 +1,38 @@
# td # td
## Install (this was generated by Ink starter, dunno if that works) > This readme is automatically generated by [create-ink-app](https://github.com/vadimdemedes/create-ink-app)
## Install
```bash ```bash
$ npm install --global td $ 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 # Manual
P.S. A more complete summary of keybinds can be displayed on `?` keybind
1. **Task Management**: 1. **Task Management**:
- Create, edit, delete tasks. - Create, edit, delete tasks.
- View lists in a ranger-like UI https://github.com/ranger/ranger - View lists in a ranger-like UI https://github.com/ranger/ranger
- Tasks can have subtasks. - Tasks can have subtasks.
2. **Navigation**: 2. **Navigation**:
- Vim-like keybindings for navigation: - Vim-like keybindings for navigation:
- `hjkl` to navigate in and between subtask lists. - `hjkl` to navigate in and between subtask lists.
- `HJKL` to move a task in and between subtask lists. - `HJKL` to move a task in and between subtask lists.
- `g` to go to the top of the list. - `g` to go to the top of the list.
- `G` to go to the bottom of the list. - `G` to go to the bottom of the list.
- `d` to go down 5 tasks - `d` to go down 5 tasks
- `u` to go up 5 tasks - `u` to go up 5 tasks
- `D` to delete a task (with a confirmation dialog) - `D` to delete a task (with a confirmation dialog)
- `x` to cut a task - `x` to cut a task
- `p` to paste a cut task - `p` to paste a cut task
3. **Task Operations**: 3. **Task Operations**:
- `a` to add a new task. - `a` to add a new task.
- `A` to add a new subtask. - `A` to add a new subtask.
- `a` to add a new task. - `a` to add a new task.
- `e` to edit the selected task using external editor. - `e` to edit the selected task using neovim.
- `d` to delete the selected task. (with confirmation using fzf) - `d` to delete the selected task. (with confirmation using fzf)
- `space` to toggle the completion status of a task. - `space` to toggle the completion status of a task.
@ -63,7 +40,9 @@ P.S. A more complete summary of keybinds can be displayed on `?` keybind
- Uses neovim for text editing. - Uses neovim for text editing.
5. **Persistence**: 5. **Persistence**:
- Save and load tasks from a file - Save and load tasks from a file ($HOME/.config/td/tasks.json)
- TODO: configurable location
6. **Search**: 6. **Search**:
- `/` to search for tasks (fzf). - `/` to search for tasks (fzf).

View File

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

View File

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