Use fzf to pick the agent in agent-cmd.sh
Move agent discovery out of `agent.sh` so the picker runs on every new pane, including manual splits. Set the agent session's default-command to agent-cmd.sh and re-apply session options on every invocation so changes propagate to live sessions.
This commit is contained in:
26
agent-cmd.sh
26
agent-cmd.sh
@@ -1,8 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wrapper that runs an agent command, then detaches if all panes in window are dead
|
||||
# Detect available agents, prompt with fzf, run the selected one.
|
||||
# Detaches the client if all panes in the window are dead afterwards.
|
||||
|
||||
# Run the agent command (don't use set -e, agent may exit non-zero)
|
||||
"$@" || true
|
||||
agents=()
|
||||
command -v claude &>/dev/null && agents+=(claude)
|
||||
command -v opencode &>/dev/null && agents+=(opencode)
|
||||
command -v gemini &>/dev/null && agents+=(gemini)
|
||||
command -v codex &>/dev/null && agents+=(gemini)
|
||||
|
||||
if [ ${#agents[@]} -eq 0 ]; then
|
||||
echo "No agent commands found (claude, opencode, gemini)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
agent=$(printf '%s\n' "${agents[@]}" | fzf \
|
||||
--prompt='agent> ' \
|
||||
--reverse \
|
||||
--border=rounded \
|
||||
--margin=25%,30% \
|
||||
--padding=1)
|
||||
|
||||
if [ -n "$agent" ]; then
|
||||
"$agent" || true
|
||||
fi
|
||||
|
||||
# Brief delay to let tmux update pane status
|
||||
sleep 0.1
|
||||
|
||||
Reference in New Issue
Block a user