[PR #13766] Add /! and /shell commands to interactive mode #76673

Open
opened 2026-05-05 09:19:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13766
Author: @ljluestc
Created: 1/18/2026
Status: 🔄 Open

Base: mainHead: feat/interactive-shell-commands


📝 Commits (3)

  • a3a7229 feat(cmd): add /! and /shell commands to interactive mode
  • 4911e76 feat(cmd): add /! and /shell commands to interactive mode
  • 4e90f2c refactor(cmd): cleanup interactive shell commands implementation

📊 Changes

2 files changed (+55 additions, -4 deletions)

View changed files

📝 cmd/interactive.go (+14 -4)
cmd/interactive_shell.go (+41 -0)

📄 Description

Description

This PR implements the requested feature to run shell commands and spawn a subshell directly from the interactive CLI mode (#1943). This improves the user experience by allowing users to check files, run diagnostics, or perform other system tasks without leaving the Ollama session.

Changes

  • New Commands:
    • /! <command>: Executes a single shell command and returns to the prompt (e.g., /! ls -la).
    • /shell: Suspends the Ollama session and drops the user into their preferred shell (defined by $SHELL or defaults to bash/sh/cmd).
  • Implementation Details:

Testing

  • Verified /! echo hello prints to stdout and returns to the prompt.
  • Verified /shell opens a new shell session and exit returns cleanly to Ollama.
  • Verified behavior on Linux (bash).
  • Verified go build ./... passes.

Fixes #1943


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13766 **Author:** [@ljluestc](https://github.com/ljluestc) **Created:** 1/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/interactive-shell-commands` --- ### 📝 Commits (3) - [`a3a7229`](https://github.com/ollama/ollama/commit/a3a7229471240a76ec194afe633a35c6e1f8f421) feat(cmd): add /! and /shell commands to interactive mode - [`4911e76`](https://github.com/ollama/ollama/commit/4911e76241c397ce7a473c604e74342b533eb7c0) feat(cmd): add /! and /shell commands to interactive mode - [`4e90f2c`](https://github.com/ollama/ollama/commit/4e90f2cbd38d4554ecec7e080a22be56f20bfea3) refactor(cmd): cleanup interactive shell commands implementation ### 📊 Changes **2 files changed** (+55 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `cmd/interactive.go` (+14 -4) ➕ `cmd/interactive_shell.go` (+41 -0) </details> ### 📄 Description ## Description This PR implements the requested feature to run shell commands and spawn a subshell directly from the interactive CLI mode (#1943). This improves the user experience by allowing users to check files, run diagnostics, or perform other system tasks without leaving the Ollama session. ## Changes - **New Commands**: - `/! <command>`: Executes a single shell command and returns to the prompt (e.g., `/! ls -la`). - `/shell`: Suspends the Ollama session and drops the user into their preferred shell (defined by `$SHELL` or defaults to `bash`/`sh`/[cmd](cci:7://file:///home/calelin/dev/ollama/cmd:0:0-0:0)). - **Implementation Details**: - Added [cmd/interactive_shell.go](cci:7://file:///home/calelin/dev/ollama/cmd/interactive_shell.go:0:0-0:0) containing platform-agnostic helper functions ([runShellCommand](cci:1://file:///home/calelin/dev/ollama/cmd/interactive_shell.go:1:0-16:1), [startShell](cci:1://file:///home/calelin/dev/ollama/cmd/interactive_shell.go:18:0-33:1)) for Windows and Unix-like systems. - Updated [cmd/interactive.go](cci:7://file:///home/calelin/dev/ollama/cmd/interactive.go:0:0-0:0) to register the new slash commands and handle the execution loop. - Added help text to the `/?` usage output. ## Testing - Verified `/! echo hello` prints to stdout and returns to the prompt. - Verified `/shell` opens a new shell session and `exit` returns cleanly to Ollama. - Verified behavior on Linux (bash). - Verified `go build ./...` passes. ## Related Issue Fixes #1943 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:19:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76673