Persistent shell mode - keep shell session alive after executing commands #4703

Open
opened 2026-02-16 17:45:07 -05:00 by yindo · 2 comments
Owner

Originally created by @everhopingandwaiting on GitHub (Jan 11, 2026).

Originally assigned to: @rekram1-node on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Description

Problem

Currently, when using the ! command to enter shell mode in opencode TUI, the shell session exits immediately after executing a single command. This requires users to repeatedly type ! to execute multiple shell commands, which disrupts workflow efficiency.

Current Behavior

  1. Type ! to enter shell mode
  2. Execute a command (e.g., ls -la)
  3. Shell automatically exits and returns to opencode TUI
  4. Must type ! again for the next command

Expected Behavior

Option to keep shell session persistent:

  1. Type ! to enter shell mode
  2. Execute multiple commands without re-entering shell mode
  3. Use exit or ctrl+d to manually exit shell mode

Use Cases

  • Rapid file system exploration requiring multiple ls, cd, find commands
  • Git operations requiring multiple commands (git status, git log, git diff)
  • Development workflow with multiple build/test commands
  • System administration tasks requiring multiple shell commands

Proposed Solutions

  1. Persistent Shell Mode Toggle: Add a configuration option to enable persistent shell mode
  2. Shell Mode Indicator: Visual indicator showing when in shell mode
  3. Graceful Exit: Use exit command or ctrl+d to leave persistent shell mode
  4. Command History: Maintain shell command history across sessions

Implementation Ideas

  • Environment variable: OPENCODE_PERSISTENT_SHELL=true
  • Config file option: tui.persistent_shell: true
  • Command toggle: /persistent-shell to enable/disable mode
  • Visual indicator in status bar when in persistent shell mode

Benefits

  • Improved workflow efficiency for multi-command operations
  • Reduced context switching between opencode and shell
  • Better user experience for shell-heavy workflows
  • Maintains opencode's integration benefits while providing shell flexibility

Operating System

All platforms (Linux, macOS, Windows)

Terminal

All supported terminals

OpenCode Version

Latest version (1.x)


Additional Notes

This issue is related to the current shell mode implementation where the ! command provides temporary shell access but exits after each command execution. The request is to enhance this feature to support persistent shell sessions for improved developer productivity.

References

  • Related to issue #6248 about shell mode selection problems
  • Complements the existing bash command functionality documented at https://opencode.ai/docs/tui#bash-commands
  • Aligns with opencode's goal of providing seamless development workflow integration
Originally created by @everhopingandwaiting on GitHub (Jan 11, 2026). Originally assigned to: @rekram1-node on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Description ### Problem Currently, when using the `!` command to enter shell mode in opencode TUI, the shell session exits immediately after executing a single command. This requires users to repeatedly type `!` to execute multiple shell commands, which disrupts workflow efficiency. ### Current Behavior 1. Type `!` to enter shell mode 2. Execute a command (e.g., `ls -la`) 3. Shell automatically exits and returns to opencode TUI 4. Must type `!` again for the next command ### Expected Behavior Option to keep shell session persistent: 1. Type `!` to enter shell mode 2. Execute multiple commands without re-entering shell mode 3. Use `exit` or `ctrl+d` to manually exit shell mode ### Use Cases - Rapid file system exploration requiring multiple `ls`, `cd`, `find` commands - Git operations requiring multiple commands (`git status`, `git log`, `git diff`) - Development workflow with multiple build/test commands - System administration tasks requiring multiple shell commands ### Proposed Solutions 1. **Persistent Shell Mode Toggle**: Add a configuration option to enable persistent shell mode 2. **Shell Mode Indicator**: Visual indicator showing when in shell mode 3. **Graceful Exit**: Use `exit` command or `ctrl+d` to leave persistent shell mode 4. **Command History**: Maintain shell command history across sessions ### Implementation Ideas - Environment variable: `OPENCODE_PERSISTENT_SHELL=true` - Config file option: `tui.persistent_shell: true` - Command toggle: `/persistent-shell` to enable/disable mode - Visual indicator in status bar when in persistent shell mode ### Benefits - Improved workflow efficiency for multi-command operations - Reduced context switching between opencode and shell - Better user experience for shell-heavy workflows - Maintains opencode's integration benefits while providing shell flexibility ### Operating System All platforms (Linux, macOS, Windows) ### Terminal All supported terminals ### OpenCode Version Latest version (1.x) --- ## Additional Notes This issue is related to the current shell mode implementation where the `!` command provides temporary shell access but exits after each command execution. The request is to enhance this feature to support persistent shell sessions for improved developer productivity. ## References - Related to issue #6248 about shell mode selection problems - Complements the existing bash command functionality documented at https://opencode.ai/docs/tui#bash-commands - Aligns with opencode's goal of providing seamless development workflow integration
yindo added the opentuidiscussion labels 2026-02-16 17:45:07 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

This issue might be a duplicate of or closely related to existing issues. Please check:

  • #6248: [Bug] Can't select options when in shell mode
  • #5310: Shell mode (! command) doesn't work on Windows
  • #4671: shell mode (!) is broken on Windows Powershell
  • #3228: [Feature] Allow the user to run their favorite shell in opencode (with persistent session and state)
  • #6488: Bash Fork Issues - includes proposed persistent shell pool architecture
  • #6004: Bug: Desktop embedded terminal freezes when shell exits via Ctrl+D or exit command
  • #4683: [FEATURE]: allow multiple shell setups and switching at runtime

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of or closely related to existing issues. Please check: - #6248: [Bug] Can't select options when in shell mode - #5310: Shell mode (! command) doesn't work on Windows - #4671: shell mode (`!`) is broken on Windows Powershell - #3228: [Feature] Allow the user to run their favorite shell in opencode (with persistent session and state) - #6488: Bash Fork Issues - includes proposed persistent shell pool architecture - #6004: Bug: Desktop embedded terminal freezes when shell exits via Ctrl+D or `exit` command - #4683: [FEATURE]: allow multiple shell setups and switching at runtime Feel free to ignore if none of these address your specific case.
Author
Owner

@arsham commented on GitHub (Jan 11, 2026):

This is an interesting idea. I would recommend keeping the current ! behaviour, and only use a !! for entering this mode .

@arsham commented on GitHub (Jan 11, 2026): This is an interesting idea. I would recommend keeping the current `!` behaviour, and only use a `!!` for entering this mode .
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4703