better docs, configure editor by an env var
This commit is contained in:
parent
f48445f3b6
commit
234e3d6efc
59
readme.md
59
readme.md
@ -1,38 +1,61 @@
|
||||
# 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.
|
||||
- `HJKL` to move a task in and between subtask lists.
|
||||
- `g` to go to the top of the list.
|
||||
- `G` to go to the bottom of the list.
|
||||
- `d` to go down 5 tasks
|
||||
- `u` to go up 5 tasks
|
||||
- `D` to delete a task (with a confirmation dialog)
|
||||
- `x` to cut a task
|
||||
- `p` to paste a cut task
|
||||
- Vim-like keybindings for navigation:
|
||||
- `hjkl` to navigate 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 bottom of the list.
|
||||
- `d` to go down 5 tasks
|
||||
- `u` to go up 5 tasks
|
||||
- `D` to delete a task (with a confirmation dialog)
|
||||
- `x` to cut a task
|
||||
- `p` to paste a cut task
|
||||
|
||||
|
||||
3. **Task Operations**:
|
||||
- `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).
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user