Coding agents refuse to persist trust for $HOME, so the keybinding and menu launches -- which inherit the session's ~ cwd -- re-asked on every single session. ~/Work is already the work root Omarchy creates, and trust there sticks. Only applies when the cwd is exactly $HOME, so the inline alias still starts in whatever project directory it was run from. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
1.5 KiB
Bash
Executable File
73 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Launch the default coding agent in a terminal
|
|
# omarchy:args=[--inline] [prompt...]
|
|
# omarchy:examples=omarchy launch agent | omarchy launch agent "Review this project"
|
|
|
|
if [[ ${1:-} == "--inline" ]]; then
|
|
inline=true
|
|
shift
|
|
else
|
|
inline=false
|
|
fi
|
|
|
|
# Agents refuse to remember trust for $HOME, so launches from the keybinding or
|
|
# menu start in the work directory instead of re-asking on every session.
|
|
[[ $PWD == "$HOME" && -d $HOME/Work ]] && cd "$HOME/Work"
|
|
|
|
agent=$(omarchy-default-agent)
|
|
|
|
if omarchy-cmd-missing "$agent"; then
|
|
echo "$agent is not installed. Choose an installed agent with: omarchy default agent <name>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if (($# > 0)); then
|
|
prompt="$*"
|
|
fi
|
|
|
|
case "$agent" in
|
|
opencode)
|
|
if [[ -n ${prompt:-} ]]; then
|
|
command=(opencode --prompt "$prompt")
|
|
else
|
|
command=(opencode)
|
|
fi
|
|
;;
|
|
gemini)
|
|
if [[ -n ${prompt:-} ]]; then
|
|
command=(gemini --prompt-interactive "$prompt")
|
|
else
|
|
command=(gemini)
|
|
fi
|
|
;;
|
|
copilot)
|
|
if [[ -n ${prompt:-} ]]; then
|
|
command=(copilot --interactive "$prompt")
|
|
else
|
|
command=(copilot)
|
|
fi
|
|
;;
|
|
crush)
|
|
if [[ -n ${prompt:-} ]]; then
|
|
command=(crush run "$prompt")
|
|
else
|
|
command=(crush)
|
|
fi
|
|
;;
|
|
pi | omp | claude | codex | grok)
|
|
command=("$agent")
|
|
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
|
;;
|
|
*)
|
|
echo "Unsupported default agent: $agent" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [[ $inline == "true" ]]; then
|
|
exec "${command[@]}"
|
|
else
|
|
exec omarchy-launch-tui "${command[@]}"
|
|
fi
|