{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreieqogpnc2ms3qls3zhnhqomn7rgiol3cmzhbw4e73vhus5rqad5ky",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3moqzunfvsya2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreih3mjalp4unouh5okma5bgq3awdipdo7swwolpxl2tspnv2num7my"
},
"mimeType": "image/webp",
"size": 72880
},
"path": "/shinshin86/open-codex-desktop-from-the-macos-terminal-with-the-current-project-selected-1iln",
"publishedAt": "2026-06-20T22:51:28.000Z",
"site": "https://dev.to",
"tags": [
"codex"
],
"textContent": "I wanted a quick way to open Codex app directly from the macOS terminal with the current project folder already selected.\n\nAdd 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.\n\nThis assumes Codex app is installed on macOS. It uses `python3` only to URL-encode the local path safely.\n\n\n\n # Open Codex app with the current directory as a new thread workspace.\n # Usage:\n # cdxnew\n # cdxnew .\n # cdxnew ~/your/project\n # cdxnew ../other-project\n cdxnew() {\n local target=\"${1:-$PWD}\"\n\n if [ ! -d \"$target\" ]; then\n echo \"cdxnew: directory not found: $target\" >&2\n return 1\n fi\n\n local abs_path\n abs_path=\"$(cd \"$target\" && pwd)\"\n\n local encoded\n encoded=\"$(CODEX_PATH=\"$abs_path\" python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ[\"CODEX_PATH\"]))')\"\n\n open \"codex://new?path=$encoded\"\n }\n",
"title": "Open Codex app from the macOS Terminal with the Current Project Selected"
}