Support bash commands when REPL mode

Resolved 💬 12 comments Opened Apr 17, 2025 by maheshrijal Closed Dec 18, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator) responded on this thread — see the highlighted reply below.

Codex doesn't have a bash / shell mode. When in REPL mode, it would enable the user to run commands in the terminal without exiting codex.
Example:
!Image
I have a local implementation of this done mostly by codex itself. If you're open to merging it I can post a PR. Thanks!

View original on GitHub ↗

12 Comments

tibo-openai collaborator · 1 year ago

Could you share a bit about the implementation first so we can discuss here and then once we feel pretty good about it I would gladly accept a PR!

maheshrijal contributor · 1 year ago

Sorry I'm not too familiar with typescript to comment on that. I yolo'ed the implementation with codex :D

This would be a great feature addition tho. Couple of use cases I can think about:

  • Using grep to search logs and immediately process results in the REPL.
  • Use cat,awk etc to filter data & pipe data to REPL and ask questions
  • Running makefile commands

Now one could argue all of this could be done by codex. But, it would be much faster to do it manually whenever required.

maheshrijal contributor · 1 year ago

I created PR https://github.com/openai/codex/pull/349. This is by no means ready and just meant to be a example.

leandrojo · 1 year ago

Hi @maheshrijal, I really like the idea and I’ll look into the effort required to implement it.

AndrewHannigan · 1 year ago

+1 I think this is a necessary feature in order to attach context to a codex session. The shell command and output should be visible to codex.

golergka · 1 year ago
Could you share a bit about the implementation first so we can discuss here and then once we feel pretty good about it I would gladly accept a PR!

I hope it's OK to mention other tools as reference. Both aider and claude code have the same functionality: if you begin your input with !, everything after it is treated as input to user's standard shell. After this command exits (or user breaks it's execution), all of it's output is added as a message to chat history on user's confirmation.

golergka · 1 year ago
I created PR #349. This is by no means ready and just meant to be a example.

That's exactly what I would expect, with improvements (probably obvious already) in the order of priority:

  • Stream Bash command output live (use a pty/ptyproc for unbuffered output)
  • Allow users to abort with Ctrl-C or Esc (forward SIGINT/SIGTERM)
  • Surface the exit code in the UI and chat history
  • After execution, prompt the user: "Send this output to the model?" (default to No for large outputs)
  • When input starts with "!", enter Command Mode (visually highlight the input field and display a header)
  • Handle TUIs (e.g., Vim, Lazygit, Vitest watch mode):
  1. Detect isTTY and ANSI-heavy output → reject with explanation ("The tool you ran is a TUI. Its output contains escape sequences and is not useful to the model. Try running it with flags like --no-watch or --plain.")
  2. (Advanced) Capture only the final screen buffer state and send that snapshot
  • Run all commands in the same long-living terminal session as the codex's commands
benglewis · 10 months ago

@tibo-openai @fouad-openai Are you open to external PRs attempting to add this behavior? I would be happy to give Codex a try at adding this feature and testing it out 🙏 :)

rajohns08 · 9 months ago

This is the biggest feature I miss from Claude Code currently

thiscantbeserious · 7 months ago

There is codex exec for this isn't it ?

etraut-openai contributor · 7 months ago

It's not clear to me what this feature request is asking for. It's quite outdated at this point, since it was filed back in April. The entire CLI has been rewritten since then.

I'm going to close this one, but if you think that there's something here that you'd like to see, please open a new feature request with details about the functionality you want.

benglewis · 7 months ago

What does the rewrite in Rust have anything to do with the desire of people to have this functionality? I, for one, would still like to have this functionality