Add notes session akin to agent session

This commit is contained in:
2026-05-21 12:13:06 +01:00
parent daf76780eb
commit 6f1d30c1b7
3 changed files with 49 additions and 0 deletions

27
notes-cmd.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Open neovim in the notes directory.
# Detaches the client if all panes in the window are dead afterwards.
notes_dir="$HOME/Documents/Notes"
nvim "$notes_dir" || true
# Brief delay to let tmux update pane status
sleep 0.1
window_id=$(tmux display-message -p '#{window_id}')
my_pane=$(tmux display-message -p '#{pane_id}')
# Count live sibling panes (not us, not dead)
other_live=$(tmux list-panes -t "$window_id" -F '#{pane_id} #{pane_dead}' \
| awk -v me="$my_pane" '$1 != me && $2 == "0"' | wc -l | tr -d ' ')
if [ "$other_live" -eq 0 ]; then
# No live siblings — close the popup and kill the window
# (also cleans up any dead siblings).
tmux detach-client
tmux kill-window -t "$window_id" 2>/dev/null || true
else
# User has split off other live panes — only kill ours, keep popup open.
tmux kill-pane 2>/dev/null || true
fi