mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-30 06:56:06 +02:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a023da1f8 | ||
|
|
333e42b5af | ||
|
|
d217d05374 | ||
|
|
c891b750b0 | ||
|
|
6aa16696d5 | ||
|
|
8d10cc9488 |
@@ -23,6 +23,14 @@ Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
|||||||
[](https://mstdn.social/@ohmyzsh)
|
[](https://mstdn.social/@ohmyzsh)
|
||||||
[](https://discord.gg/ohmyzsh)
|
[](https://discord.gg/ohmyzsh)
|
||||||
|
|
||||||
|
<a href="https://commitgoods.com/collections/oh-my-zsh?utm_source=github">
|
||||||
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.shopify.com/s/files/1/0101/8752/files/commitgoods-badge-stacked-navy-dark.svg">
|
||||||
|
<img src="https://cdn.shopify.com/s/files/1/0101/8752/files/commitgoods-badge-stacked-navy.svg" height="28" alt="Official merch on commitgoods.com">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Table of Contents</summary>
|
<summary>Table of Contents</summary>
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ function chruby_prompt_info \
|
|||||||
azure_prompt_info \
|
azure_prompt_info \
|
||||||
tf_prompt_info \
|
tf_prompt_info \
|
||||||
conda_prompt_info \
|
conda_prompt_info \
|
||||||
|
go_prompt_info \
|
||||||
{
|
{
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,3 +39,18 @@ plugins=(... golang)
|
|||||||
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
|
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
|
||||||
| gove | `go version` | Prints Go version |
|
| gove | `go version` | Prints Go version |
|
||||||
| gow | `go work` | Work provides access to operations on workspaces |
|
| gow | `go work` | Work provides access to operations on workspaces |
|
||||||
|
|
||||||
|
## Prompt
|
||||||
|
|
||||||
|
This plugin provides the `go_prompt_info` function to add the installed Go
|
||||||
|
version to your prompt.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
PROMPT="%~$ "
|
||||||
|
RPROMPT='$(go_prompt_info)'
|
||||||
|
```
|
||||||
|
changes your prompt to:
|
||||||
|
```
|
||||||
|
~/go/project$ ▋ 1.22.3
|
||||||
|
```
|
||||||
|
|||||||
@@ -36,3 +36,12 @@ alias gotofx='go tool fix'
|
|||||||
alias gov='go vet'
|
alias gov='go vet'
|
||||||
alias gove='go version'
|
alias gove='go version'
|
||||||
alias gow='go work'
|
alias gow='go work'
|
||||||
|
|
||||||
|
## prompt
|
||||||
|
function go_prompt_info() {
|
||||||
|
(( $+commands[go] )) || return
|
||||||
|
local go_prompt
|
||||||
|
go_prompt=$(go version | awk '{ print substr($3, 3) }')
|
||||||
|
[[ -z "${go_prompt}" ]] && return
|
||||||
|
echo "${ZSH_THEME_GO_PROMPT_PREFIX}${go_prompt:gs/%/%%}${ZSH_THEME_GO_PROMPT_SUFFIX}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ plugins=(... laravel)
|
|||||||
| `pami` | `php artisan make:interface` |
|
| `pami` | `php artisan make:interface` |
|
||||||
| `pamtr` | `php artisan make:trait` |
|
| `pamtr` | `php artisan make:trait` |
|
||||||
| `pamv` | `php artisan make:view` |
|
| `pamv` | `php artisan make:view` |
|
||||||
|
| `pammig` | `php artisan make:migration` |
|
||||||
|
|
||||||
## Clears
|
## Clears
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ alias pamen='php artisan make:enum'
|
|||||||
alias pami='php artisan make:interface'
|
alias pami='php artisan make:interface'
|
||||||
alias pamtr='php artisan make:trait'
|
alias pamtr='php artisan make:trait'
|
||||||
alias pamv='php artisan make:view'
|
alias pamv='php artisan make:view'
|
||||||
|
alias pammig='php artisan make:migration'
|
||||||
|
|
||||||
|
|
||||||
# Clears
|
# Clears
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
# opencode plugin
|
||||||
|
|
||||||
|
This plugin adds completion and aliases for the [OpenCode](https://opencode.ai) CLI.
|
||||||
|
Install OpenCode using its [installation instructions](https://opencode.ai/docs/#install),
|
||||||
|
and make sure `opencode` is available on your `$PATH`.
|
||||||
|
|
||||||
|
To enable it, add `opencode` to the plugins array in your `.zshrc`:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... opencode)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Learning OpenCode from the terminal
|
||||||
|
|
||||||
|
Use tab completion to explore commands and their descriptions without leaving the
|
||||||
|
shell. For example, these are some of the candidates shown by the CLI:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ opencode <TAB>
|
||||||
|
agent -- manage agents
|
||||||
|
models -- list all available models
|
||||||
|
run -- run opencode with a message
|
||||||
|
session -- manage sessions
|
||||||
|
stats -- show token usage and cost statistics
|
||||||
|
...
|
||||||
|
|
||||||
|
$ opencode session <TAB>
|
||||||
|
delete -- delete a session
|
||||||
|
list -- list sessions
|
||||||
|
|
||||||
|
$ opencode run --<TAB>
|
||||||
|
--agent -- agent to use
|
||||||
|
--continue -- continue the last session
|
||||||
|
--file -- file(s) to attach to message
|
||||||
|
--model -- model to use in the format of provider/model
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Completion works through the aliases too. Type a partial command or option and
|
||||||
|
press Tab to finish it:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ opc session li<TAB>
|
||||||
|
$ opc session list
|
||||||
|
|
||||||
|
$ opcr --att<TAB>
|
||||||
|
$ opcr --attach
|
||||||
|
|
||||||
|
$ opcc --log-l<TAB>
|
||||||
|
$ opcc --log-level
|
||||||
|
```
|
||||||
|
|
||||||
|
Candidates depend on your installed OpenCode version. In OpenCode 1.18.29, the
|
||||||
|
CLI's completion output omits top-level TUI flags such as `--model` and `--fork`,
|
||||||
|
even though those flags work when typed. Use `opencode --help` or
|
||||||
|
`opencode run --help` for the full options, and see the
|
||||||
|
[CLI reference](https://opencode.ai/docs/cli/) for more workflows.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------ | --------------------- | ----------------------------------- |
|
||||||
|
| `opc` | `opencode` | Launch the terminal UI |
|
||||||
|
| `opcc` | `opencode --continue` | Continue the last session |
|
||||||
|
| `opcr` | `opencode run` | Run a prompt without opening the UI |
|
||||||
|
|
||||||
|
To keep completion but skip the aliases, set this in your `.zshrc`, above the line
|
||||||
|
that sources Oh My Zsh:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# ~/.zshrc
|
||||||
|
zstyle ':omz:plugins:opencode' aliases no
|
||||||
|
|
||||||
|
plugins=(... opencode)
|
||||||
|
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common workflows
|
||||||
|
|
||||||
|
All aliases accept additional arguments:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# Open a project
|
||||||
|
opc ~/projects/my-app
|
||||||
|
|
||||||
|
# Explore a different approach by forking the last session
|
||||||
|
opcc --fork
|
||||||
|
|
||||||
|
# Ask a question without entering the terminal UI
|
||||||
|
opcr "Explain the test setup in this project"
|
||||||
|
|
||||||
|
# Reuse an already running backend to avoid MCP server cold starts
|
||||||
|
opcr --attach http://localhost:4096 "Explain this project's architecture"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Completion
|
||||||
|
|
||||||
|
Completion queries the installed OpenCode CLI on demand for commands and options,
|
||||||
|
including through the aliases above. It falls back to Zsh's default completion when
|
||||||
|
the CLI returns no candidates. No OpenCode process is started at shell startup,
|
||||||
|
and no generated completion cache is needed.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
Based on the OpenCode plugin proposals by
|
||||||
|
[pranavavva](https://github.com/pranavavva) in
|
||||||
|
[#13545](https://github.com/ohmyzsh/ohmyzsh/pull/13545) and
|
||||||
|
[mskadu](https://github.com/mskadu) in
|
||||||
|
[#13794](https://github.com/ohmyzsh/ohmyzsh/pull/13794).
|
||||||
|
The completion adapter is derived from OpenCode's `opencode completion` output.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#compdef opencode
|
||||||
|
|
||||||
|
# Adapted from `opencode completion`, using the CLI's live Yargs completions.
|
||||||
|
local -a reply
|
||||||
|
reply=("${(@f)$(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" \
|
||||||
|
command opencode --get-yargs-completions "${words[@]}" < /dev/null 2> /dev/null)}")
|
||||||
|
|
||||||
|
if [[ -n "${reply[1]}" ]]; then
|
||||||
|
_describe 'values' reply
|
||||||
|
else
|
||||||
|
_default
|
||||||
|
fi
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if (( ! $+commands[opencode] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
alias opc='opencode'
|
||||||
|
alias opcc='opencode --continue'
|
||||||
|
alias opcr='opencode run'
|
||||||
@@ -4,8 +4,8 @@ export LSCOLORS=dxFxCxDxBxegedabagacad
|
|||||||
|
|
||||||
local git_branch='$(git_prompt_info)%{$reset_color%}$(git_remote_status)'
|
local git_branch='$(git_prompt_info)%{$reset_color%}$(git_remote_status)'
|
||||||
|
|
||||||
PROMPT="%{$fg[green]%}╭─%n@%m %{$reset_color%}%{$fg[yellow]%}in %~ %{$reset_color%}${git_branch}
|
PROMPT="%{%(#~$fg[red]~$fg[green])%}╭─%n@%m %{$reset_color%}%{$fg[yellow]%}in %~ %{$reset_color%}${git_branch}
|
||||||
%{$fg[green]%}╰\$ %{$reset_color%}"
|
%{%(#~$fg[red]~$fg[green])%}╰%(#~#~\$) %{$reset_color%}"
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}on "
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}on "
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||||
|
|||||||
Reference in New Issue
Block a user