mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-27 21:46:08 +02:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a023da1f8 | ||
|
|
333e42b5af |
+4
-10
@@ -14,16 +14,10 @@ FX=(
|
|||||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build the tables with array operations instead of a 256-iteration loop
|
for color in {000..255}; do
|
||||||
() {
|
FG[$color]="%{[38;5;${color}m%}"
|
||||||
setopt localoptions noksharrays
|
BG[$color]="%{[48;5;${color}m%}"
|
||||||
local -a codes fg bg
|
done
|
||||||
codes=({000..255})
|
|
||||||
fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" )
|
|
||||||
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
|
|
||||||
FG=( ${codes:^fg} )
|
|
||||||
BG=( ${codes:^bg} )
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show all 256 colors with color number
|
# Show all 256 colors with color number
|
||||||
function spectrum_ls() {
|
function spectrum_ls() {
|
||||||
|
|||||||
+1
-6
@@ -31,12 +31,7 @@ function title {
|
|||||||
else
|
else
|
||||||
# Try to use terminfo to set the title if the feature is available
|
# Try to use terminfo to set the title if the feature is available
|
||||||
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
||||||
# Emit the capabilities with echoti so terminfo does its own parameter
|
print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
|
||||||
# substitution: some terminals (vt320) take a column argument, and
|
|
||||||
# running prompt expansion over the capability string mangles it.
|
|
||||||
echoti tsl 0
|
|
||||||
print -Pn "$1"
|
|
||||||
echoti fsl
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ plugins=(... kubectl)
|
|||||||
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
|
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
|
||||||
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
||||||
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
||||||
| krsss | `kubectl rollout status statefulset` | Check the rollout status of a statefulset |
|
| krsss | `kubectl rollout status statefulset` | Check the rollout status of a deployment |
|
||||||
| krrss | `kubectl rollout restart statefulset` | Rollout restart a statefulset |
|
| krrss | `kubectl rollout restart statefulset` | Rollout restart a statefulset |
|
||||||
| | | **Service Accounts management** |
|
| | | **Service Accounts management** |
|
||||||
| kdsa | `kubectl describe sa` | Describe a service account in details |
|
| kdsa | `kubectl describe sa` | Describe a service account in details |
|
||||||
|
|||||||
@@ -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'
|
||||||
@@ -45,7 +45,6 @@ plugins=(... systemd)
|
|||||||
| `sc-set-environment` | `sudo systemctl set-environment` | Set one or more systemd manager environment variables |
|
| `sc-set-environment` | `sudo systemctl set-environment` | Set one or more systemd manager environment variables |
|
||||||
| `sc-unset-environment` | `sudo systemctl unset-environment` | Unset one or more systemd manager environment variables |
|
| `sc-unset-environment` | `sudo systemctl unset-environment` | Unset one or more systemd manager environment variables |
|
||||||
| `sc-edit` | `sudo systemctl edit` | Edit a drop-in snippet or a whole replacement file with `--full` |
|
| `sc-edit` | `sudo systemctl edit` | Edit a drop-in snippet or a whole replacement file with `--full` |
|
||||||
| `sc-edit-full` | `sudo systemctl edit --full` | Edit the whole unit file instead of a drop-in snippet |
|
|
||||||
| `sc-enable-now` | `sudo systemctl enable --now` | Enable and start unit(s) |
|
| `sc-enable-now` | `sudo systemctl enable --now` | Enable and start unit(s) |
|
||||||
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
|
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
|
||||||
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
|
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
|
||||||
|
|||||||
@@ -97,10 +97,6 @@ alias scu-mask-now="scu-mask --now"
|
|||||||
alias scu-failed='systemctl --user --failed'
|
alias scu-failed='systemctl --user --failed'
|
||||||
alias sc-failed='systemctl --failed'
|
alias sc-failed='systemctl --failed'
|
||||||
|
|
||||||
# --full commands
|
|
||||||
alias sc-edit-full="sc-edit --full"
|
|
||||||
alias scu-edit-full="scu-edit --full"
|
|
||||||
|
|
||||||
function systemd_prompt_info {
|
function systemd_prompt_info {
|
||||||
local unit
|
local unit
|
||||||
for unit in "$@"; do
|
for unit in "$@"; do
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
|||||||
# Get absolute path, resolving symlinks
|
# Get absolute path, resolving symlinks
|
||||||
local PROJECT_ROOT="${PWD:A}"
|
local PROJECT_ROOT="${PWD:A}"
|
||||||
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \
|
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \
|
||||||
&& ! -e "$PROJECT_ROOT/.git" ]]; do
|
&& ! -d "$PROJECT_ROOT/.git" ]]; do
|
||||||
PROJECT_ROOT="${PROJECT_ROOT:h}"
|
PROJECT_ROOT="${PROJECT_ROOT:h}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function theme_precmd {
|
|||||||
if (( promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize > TERMWIDTH )); then
|
if (( promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize > TERMWIDTH )); then
|
||||||
(( PR_PWDLEN = TERMWIDTH - promptsize ))
|
(( PR_PWDLEN = TERMWIDTH - promptsize ))
|
||||||
elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
|
elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
|
||||||
PR_FILLBAR="\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize ) ))::─:)}"
|
PR_FILLBAR="\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize ) ))::${PR_HBAR}:)}"
|
||||||
else
|
else
|
||||||
PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize ) ))::${altchar[q]:--}:)}${PR_SHIFT_OUT}"
|
PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize + venvpromptsize + condapromptsize ) ))::${altchar[q]:--}:)}${PR_SHIFT_OUT}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user