Open Codex app from the macOS Terminal with the Current Project Selected

작성자

카테고리:

← 피드로
DEV Community · Yuki Shindo · 2026-06-21 개발(SW)

Yuki Shindo

I wanted a quick way to open Codex app directly from the macOS terminal with the current project folder already selected.

Add the following function to your local Zsh config file, such as ~/.zshrc. It opens a new Codex thread using the current directory as the workspace. You can also pass a directory path as an argument.

This assumes Codex app is installed on macOS. It uses python3 only to URL-encode the local path safely.

# Open Codex app with the current directory as a new thread workspace.
# Usage:
#   cdxnew
#   cdxnew .
#   cdxnew ~/your/project
#   cdxnew ../other-project
cdxnew() {
  local target="${1:-$PWD}"

  if [ ! -d "$target" ]; then
    echo "cdxnew: directory not found: $target" >&2
    return 1
  fi

  local abs_path
  abs_path="$(cd "$target" && pwd)"

  local encoded
  encoded="$(CODEX_PATH="$abs_path" python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["CODEX_PATH"]))')"

  open "codex://new?path=$encoded"
}

Enter fullscreen mode Exit fullscreen mode

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다