# codex_exec local shell setup # ============================ # # This file is valid Bash. Copy it to $HOME/.bash_aliases, then reload your # shell with: # # source $HOME/.bashrc # # It defines one command: # # runx # # runx launches $HOME/codex_auto_run.py with a tmux session prefix derived from # the current directory. That keeps watcher state and logs separate per project. # # Install from a fresh clone: # # git clone https://huggingface.co/yitongl/codex_exec ~/codex_exec # cp ~/codex_exec/codex_auto_run.py ~/codex_auto_run.py # chmod +x ~/codex_auto_run.py # cp ~/codex_exec/LOCAL_SETUP.txt ~/.bash_aliases # source ~/.bashrc # # If you keep codex_auto_run.py somewhere other than $HOME/codex_auto_run.py, # edit CODEX_AUTORUN_SCRIPT below before copying this file. unalias runx 2>/dev/null || true CODEX_AUTORUN_SCRIPT="${CODEX_AUTORUN_SCRIPT:-$HOME/codex_auto_run.py}" _codex_autorun_dir_name() { local rel if [[ "$PWD" == "$HOME" ]]; then rel="home" elif [[ "$PWD" == "$HOME/"* ]]; then rel="${PWD#"$HOME"/}" else rel="${PWD#/}" fi rel="${rel//\//-}" rel="${rel//[^A-Za-z0-9_-]/-}" while [[ "$rel" == *--* ]]; do rel="${rel//--/-}" done while [[ -n "$rel" && ! "${rel:0:1}" =~ [A-Za-z0-9] ]]; do rel="${rel:1}" done [[ -n "$rel" ]] || rel="home" # codex_auto_run.py limits a session prefix to 48 characters. Leave room # for the "-x" suffix. if (( ${#rel} > 45 )); then rel="${rel:0:28}-${rel: -16}" fi printf '%s' "$rel" } runx() { local base base="$(_codex_autorun_dir_name)" python3 "$CODEX_AUTORUN_SCRIPT" --session-prefix "${base}-x" "$@" } # Examples: # # cd $HOME/code/my_project # runx -p "Inspect the project, make the requested changes, and run tests." # # Enable Codex web search: # # runx -p "Research and complete the task." -- --search # # Disable broad MCP/app or directory-trust auto approval when needed: # # runx --no-approve-mcp -p "Work without app/tool auto approval." # runx --no-auto-trust-directory -p "Work without automatic directory trust." # # Status, logs, and daemon control from the same project directory: # # runx --status # tail -f ~/.runtime/$(_codex_autorun_dir_name)-x/approve-debug.log # runx --stop-daemon