summaryrefslogtreecommitdiff
path: root/ar/.local/bin/opentasktui
blob: 1db6bef82e10cca8f975369b1080f235cfc0055b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

# Capture the current session name
current_session=$(tmux display-message -p '#S')

# Parse the task description from the argument
task_description="$1"

# Create a new tmux session named 'new-task-session' and run 'tui -r current'
tmux new-session -d -s new-task-session "taskwarrior-tui -r current"

# Sleep for a bit to allow tui to load
sleep 0.1

# Send the keystrokes needed to filter tasks by description to the target pane
tmux send-keys -t new-task-session:1.1 "/description:$task_description" C-m

# Attach to the new session
tmux switch-client -t new-task-session

# Wait for the session to be closed, either by the user or some other way
while tmux has-session -t new-task-session 2>/dev/null; do
  sleep 0.1
done

# Switch back to the original session
tmux switch-client -t "$current_session"