Use Codex to Build a Fully Agentic Workspace
Managing terminal panes and running multiple commands can be a repetitive and manual process. This lesson demonstrates how to transform your terminal into a dynamic, AI-driven workspace by feeding the help documentation of your CLI tools directly into an AI agent.
The workflow demonstrated in this lesson:
- Provide an AI agent with the
--helpoutput from a terminal multiplexer (cmux) and another CLI tool (gemini). - Use natural language to instruct the agent to create, manage, and close terminal panes.
- Chain commands together, instructing the agent to create new panes and run specific
geminicommands within each to generate unique content. - Have the agent read the output from multiple panes, consolidate the results, and write them to a new markdown file.
- Dynamically retitle and re-layout panes based on the content generated by previous commands.
Key benefits:
- Enables a powerful, natural language interface for complex terminal operations.
- Seamlessly integrates and orchestrates multiple CLI tools within a single workflow.
- Allows the AI agent to interact with and process the output of the commands it runs.
- Automates intricate tasks that would otherwise require significant manual effort.
This lesson showcases a powerful paradigm where the AI agent becomes a true terminal assistant, capable of understanding your tools and executing sophisticated, multi-step workflows on your behalf.
Summary
This lesson shows how to use an AI agent to control your terminal with natural language. By providing the agent with the --help documentation for your CLI tools (like a terminal multiplexer and the Gemini CLI), you can instruct it to perform complex, multi-step tasks. The video demonstrates creating and closing panes, running different commands in each pane, reading the output, consolidating it into a file, and even retitling and re-laying out the panes based on the generated content. This turns the AI into a powerful assistant that can orchestrate multiple tools and automate your terminal workflow.
Prompts
Please create two new panes in our workspace.
Please close the two other panes.
Please open two new panes and in each pane run Gemini with a command to generate a poem, and in each of those create a different poem.
Grab the two resulting poems from each Gemini command and write them to a single markdown file.
Please close those two panes.
Please create four new panes, give each of them a title based on a section of the poems that we created.
Please balance out the panes so they're equally laid out or they have equal dimensions for each pane.
Commands
! cmux --help
! gemini --help
# Agent runs two commands to create new panescmux new-pane --focus true && cmux new-pane --focus false
# Agent focuses each pane and then closes the active surfacecmux focus-pane --pane 89 --workspace workspace:17 && cmux close-surface --workspace workspace:17 && cmux focus-pane --pane 90 --workspace workspace:17 && cmux close-surface --workspace workspace:17
# Agent reads the screen from two panes and writes the content to a filecat > gemini-poems.md <<'EOF'# Gemini Poems## Poem 1: Lighthouse in a StormThe iron tower stands, a salt-scarred ghost,Against the churning, black Atlantic host.A single eye of gold begins to sweep,Above the white-fanged hunters of the deep.The thunder cracks like timber in the gale,While stinging spray obscures the distant sail.Unmoved by every mountain-surge of dread,It throws a lifeline from its lantern head.## Poem 2: Robot Bread SongA robot with whisk and a digital soul,Poured flour and yeast in a titanium bowl.He kneaded the dough with a rhythmic "beep-clack,"Till a musical spark hit his logic-board stack.The oven hummed low in a groovy G-flat,As the robot began a melodic "rat-tat."He sang of the crust and the rise and the heat,A sourdough anthem with a synthesizer beat.The bread didn't rise, it just started to dance,Lost in the rhythm of a carb-heavy trance.Though the loaf was a brick, the tune was a hit,The first bakery bop from a chef made of bit.EOF
Code Snippets
# Gemini Poems## Poem 1: Lighthouse in a StormThe iron tower stands, a salt-scarred ghost,Against the churning, black Atlantic host.A single eye of gold begins to sweep,Above the white-fanged hunters of the deep.The thunder cracks like timber in the gale,While stinging spray obscures the distant sail.Unmoved by every mountain-surge of dread,It throws a lifeline from its lantern head.## Poem 2: Robot Bread SongA robot with whisk and a digital soul,Poured flour and yeast in a titanium bowl.He kneaded the dough with a rhythmic "beep-clack,"Till a musical spark hit his logic-board stack.The oven hummed low in a groovy G-flat,As the robot began a melodic "rat-tat."He sang of the crust and the rise and the heat,A sourdough anthem with a synthesizer beat.The bread didn't rise, it just started to dance,Lost in the rhythm of a carb-heavy trance.Though the loaf was a brick, the tune was a hit,The first bakery bop from a chef made of bit.