Created
January 28, 2026 22:20
-
-
Save greggdonovan/66a935f9621eaa312c2232ef08e36d97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import hashlib | |
| import json | |
| import os | |
| import shlex | |
| import shutil | |
| import subprocess | |
| import sys | |
| from typing import Optional | |
| def _collapse(text: str) -> str: | |
| return " ".join(text.split()) | |
| def _truncate(text: str, limit: int) -> str: | |
| text = _collapse(text) | |
| if len(text) <= limit: | |
| return text | |
| if limit <= 3: | |
| return text[:limit] | |
| return text[: limit - 3].rstrip() + "..." | |
| def _load_payload(): | |
| raw = None | |
| if len(sys.argv) > 1 and sys.argv[1] not in ("", "-"): | |
| raw = sys.argv[1] | |
| elif not sys.stdin.isatty(): | |
| raw = sys.stdin.read().strip() | |
| if not raw: | |
| return None | |
| try: | |
| data = json.loads(raw) | |
| except Exception: | |
| return None | |
| return data if isinstance(data, dict) else None | |
| def _project_name(cwd: str) -> str: | |
| project = os.path.basename(cwd.rstrip("/")) or cwd | |
| try: | |
| top = subprocess.check_output( | |
| ["git", "-C", cwd, "rev-parse", "--show-toplevel"], | |
| text=True, | |
| stderr=subprocess.DEVNULL, | |
| ).strip() | |
| except Exception: | |
| return project | |
| if not top: | |
| return project | |
| return os.path.basename(top.rstrip("/")) or project | |
| def _notify_terminal_notifier(title: str, message: str, subtitle: str, group: str) -> None: | |
| args = [ | |
| "terminal-notifier", | |
| "-title", | |
| title, | |
| "-message", | |
| message, | |
| "-group", | |
| group, | |
| ] | |
| if subtitle: | |
| args += ["-subtitle", subtitle] | |
| execute = os.environ.get("CODEX_NOTIFY_EXECUTE", "").strip() | |
| if execute: | |
| args += ["-execute", execute] | |
| activate = os.environ.get("CODEX_NOTIFY_ACTIVATE", "").strip() | |
| if activate: | |
| args += ["-activate", activate] | |
| sound = os.environ.get("CODEX_NOTIFY_SOUND", "").strip() | |
| if sound: | |
| args += ["-sound", sound] | |
| subprocess.run(args, check=False) | |
| def _iterm_session_id() -> Optional[str]: | |
| raw = os.environ.get("ITERM_SESSION_ID", "").strip() | |
| if not raw: | |
| return None | |
| if ":" in raw: | |
| return raw.split(":", 1)[1].strip() or None | |
| return raw or None | |
| def _build_execute_command(session_id: str) -> str: | |
| python = shlex.quote(sys.executable or "python3") | |
| script = shlex.quote(os.path.abspath(__file__)) | |
| sid = shlex.quote(session_id) | |
| return f"{python} {script} --jump {sid}" | |
| def _iterm_jump(session_id: str) -> None: | |
| script = """on run argv | |
| set targetId to item 1 of argv | |
| tell application "iTerm2" | |
| repeat with w in windows | |
| repeat with t in tabs of w | |
| repeat with s in sessions of t | |
| if id of s is targetId then | |
| select t | |
| select s | |
| activate | |
| return | |
| end if | |
| end repeat | |
| end repeat | |
| end repeat | |
| end tell | |
| end run | |
| """ | |
| subprocess.run( | |
| ["osascript", "-", session_id], | |
| input=script, | |
| text=True, | |
| check=False, | |
| ) | |
| def main() -> int: | |
| if len(sys.argv) > 1 and sys.argv[1] == "--jump": | |
| if sys.platform != "darwin": | |
| return 0 | |
| session_id = sys.argv[2] if len(sys.argv) > 2 else "" | |
| if session_id: | |
| _iterm_jump(session_id) | |
| return 0 | |
| if sys.platform != "darwin": | |
| return 0 | |
| payload = _load_payload() | |
| if not payload or payload.get("type") != "agent-turn-complete": | |
| return 0 | |
| cwd = payload.get("cwd") or os.getcwd() | |
| if not os.path.isdir(cwd): | |
| cwd = os.getcwd() | |
| project = _project_name(cwd) | |
| last_assistant = (payload.get("last-assistant-message") or "Turn complete").strip() | |
| user_msgs = payload.get("input-messages") or [] | |
| last_user = (user_msgs[-1] if user_msgs else "").strip() | |
| title = f"Codex done: {project}" | |
| message_source = last_user or last_assistant or "Turn complete" | |
| message = _truncate(message_source, 220) | |
| subtitle = _truncate(last_assistant, 180) | |
| thread_id = (payload.get("thread-id") or "").strip() | |
| if not thread_id: | |
| thread_id = hashlib.sha1(cwd.encode("utf-8")).hexdigest()[:10] | |
| group = f"codex-{thread_id}" | |
| if not shutil.which("terminal-notifier"): | |
| return 0 | |
| session_id = _iterm_session_id() | |
| if session_id: | |
| if not os.environ.get("CODEX_NOTIFY_EXECUTE", "").strip(): | |
| os.environ["CODEX_NOTIFY_EXECUTE"] = _build_execute_command(session_id) | |
| if not os.environ.get("CODEX_NOTIFY_ACTIVATE", "").strip(): | |
| os.environ["CODEX_NOTIFY_ACTIVATE"] = "com.googlecode.iterm2" | |
| _notify_terminal_notifier(title, message, subtitle, group) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = "gpt-5.2-codex" | |
| model_reasoning_effort = "xhigh" | |
| tool_output_token_limit = 25000 | |
| model_auto_compact_token_limit = 233000 | |
| notify = ["python3", "/Users/gdonovan/.codex/codex-notify.py"] | |
| approval_policy = "never" | |
| sandbox_mode = "danger-full-access" | |
| [sandbox_workspace_write] | |
| network_access = true | |
| [features] | |
| web_search_request = true | |
| unified_exec = true | |
| shell_snapshot = true | |
| steer = true | |
| collab = true | |
| collaboration_modes = true | |
| [projects."/Users/gdonovan/development/sciences"] | |
| trust_level = "trusted" | |
| [notice] | |
| "hide_gpt-5.1-codex-max_migration_prompt" = true | |
| [notice.model_migrations] | |
| "gpt-5.1-codex-max" = "gpt-5.2-codex" | |
| [mcp_servers.chrome-devtools] | |
| command = "npx" | |
| args = ["-y", "chrome-devtools-mcp@latest"] | |
| [mcp_servers.glean_default] | |
| url = "https://etsy-be.glean.com/mcp/default" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment