mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-20 11:57:19 +02:00
34 lines
1.0 KiB
Bash
34 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
export SHELL="/bin/bash"
|
|
export PATH="${HOME}/.local/bin:/usr/local/bin:/usr/bin:/bin:${PATH:-}"
|
|
|
|
workspace="${CODEX_TERMINAL_WORKSPACE:-${HOME}/workspace}"
|
|
session_name="${CODEX_TMUX_SESSION:-codex}"
|
|
|
|
if [ ! -d "$workspace" ]; then
|
|
echo "Codex workspace does not exist: $workspace" >&2
|
|
exit 1
|
|
fi
|
|
|
|
new_session=0
|
|
if ! tmux has-session -t "$session_name" 2> /dev/null; then
|
|
tmux new-session -d -s "$session_name" -c "$workspace" /bin/bash -l
|
|
new_session=1
|
|
fi
|
|
|
|
if [ "$new_session" -eq 1 ]; then
|
|
tmux send-keys -t "$session_name" \
|
|
"printf '\\nChatGPT Codex add-on\\n login: codex-login\\n optimized: codex-headroom\\n direct: codex-direct\\n savings: rtk gain && headroom perf\\n\\n'" C-m
|
|
if [ "${CODEX_AUTO_START:-1}" = "1" ]; then
|
|
if [ "${CODEX_USE_HEADROOM:-1}" = "1" ]; then
|
|
tmux send-keys -t "$session_name" "codex-headroom" C-m
|
|
else
|
|
tmux send-keys -t "$session_name" "codex-direct" C-m
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
exec tmux attach-session -t "$session_name"
|