mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-25 01:43:04 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2cd6260c5 | ||
|
|
49766a713a | ||
|
|
570bd64a56 | ||
|
|
ad203cc9c4 | ||
|
|
89ec2b437b | ||
|
|
3943d2f880 | ||
|
|
a449ed2c4e | ||
|
|
a32fc1d8ae |
No files matched your search
@@ -36,8 +36,6 @@ jobs:
|
||||
run: |
|
||||
for file in ./oh-my-zsh.sh \
|
||||
./lib/*.zsh \
|
||||
./functions/* \
|
||||
./completions/_* \
|
||||
./plugins/*/*.plugin.zsh \
|
||||
./plugins/*/_* \
|
||||
./themes/*.zsh-theme; do
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
#compdef omz
|
||||
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'changelog:Print the changelog'
|
||||
'diagnose:Run configuration diagnostics'
|
||||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
'reload:Reload the current zsh session'
|
||||
'shellsaver:Launch a whimsical terminal screensaver'
|
||||
'shop:Open the Oh My Zsh shop'
|
||||
'theme:Manage themes'
|
||||
'update:Update Oh My Zsh'
|
||||
'version:Show the version'
|
||||
)
|
||||
|
||||
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||
_arguments \
|
||||
'1:command:' \
|
||||
'2::scene:(aquarium logo hermit party)' \
|
||||
'--list[List available scenes]' \
|
||||
'--mono[Use the default foreground color]' \
|
||||
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||
'--snapshot[Print a plain-text still]::frame:' \
|
||||
'--help[Show Shellsaver help]'
|
||||
return
|
||||
fi
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
changelog) local -a refs
|
||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
_describe 'command' refs ;;
|
||||
plugin) subcmds=(
|
||||
'disable:Disable plugin(s)'
|
||||
'enable:Enable plugin(s)'
|
||||
'info:Get plugin information'
|
||||
'list:List plugins'
|
||||
'load:Load plugin(s)'
|
||||
)
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(disable|enable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
plugin::info)
|
||||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
plugin::list)
|
||||
local -a opts
|
||||
opts=('--enabled:List enabled plugins only')
|
||||
_describe -o 'options' opts ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
_describe 'theme' themes ;;
|
||||
esac
|
||||
elif (( CURRENT > 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(enable|disable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
# Remove plugins already passed as arguments
|
||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||
# the completion not add a space after the completed plugin.
|
||||
local -a args
|
||||
args=(${words[4,$(( CURRENT - 1))]})
|
||||
valid_plugins=(${valid_plugins:|args})
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
+112
-2
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
function omz {
|
||||
setopt localoptions noksharrays
|
||||
[[ $# -gt 0 ]] || {
|
||||
@@ -18,6 +20,116 @@ function omz {
|
||||
_omz::$command "$@"
|
||||
}
|
||||
|
||||
function _omz {
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'changelog:Print the changelog'
|
||||
'diagnose:Run configuration diagnostics'
|
||||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
'reload:Reload the current zsh session'
|
||||
'shellsaver:Launch a whimsical terminal screensaver'
|
||||
'shop:Open the Oh My Zsh shop'
|
||||
'theme:Manage themes'
|
||||
'update:Update Oh My Zsh'
|
||||
'version:Show the version'
|
||||
)
|
||||
|
||||
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||
_arguments \
|
||||
'1:command:' \
|
||||
'2::scene:(aquarium logo hermit party)' \
|
||||
'--list[List available scenes]' \
|
||||
'--mono[Use the default foreground color]' \
|
||||
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||
'--snapshot[Print a plain-text still]::frame:' \
|
||||
'--help[Show Shellsaver help]'
|
||||
return
|
||||
fi
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
changelog) local -a refs
|
||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
_describe 'command' refs ;;
|
||||
plugin) subcmds=(
|
||||
'disable:Disable plugin(s)'
|
||||
'enable:Enable plugin(s)'
|
||||
'info:Get plugin information'
|
||||
'list:List plugins'
|
||||
'load:Load plugin(s)'
|
||||
)
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(disable|enable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
plugin::info)
|
||||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
plugin::list)
|
||||
local -a opts
|
||||
opts=('--enabled:List enabled plugins only')
|
||||
_describe -o 'options' opts ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
_describe 'theme' themes ;;
|
||||
esac
|
||||
elif (( CURRENT > 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(enable|disable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
# Remove plugins already passed as arguments
|
||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||
# the completion not add a space after the completed plugin.
|
||||
local -a args
|
||||
args=(${words[4,$(( CURRENT - 1))]})
|
||||
valid_plugins=(${valid_plugins:|args})
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# If run from a script, do not set the completion function
|
||||
if (( ${+functions[compdef]} )); then
|
||||
compdef _omz omz
|
||||
fi
|
||||
|
||||
## Utility functions
|
||||
|
||||
function _omz::confirm {
|
||||
@@ -887,5 +999,3 @@ function _omz::version {
|
||||
printf "%s (%s)\n" "$version" "$commit"
|
||||
)
|
||||
}
|
||||
|
||||
omz "$@"
|
||||
@@ -1,4 +1,4 @@
|
||||
# omz_diagnostic_dump
|
||||
# diagnostics.zsh
|
||||
#
|
||||
# Diagnostic and debugging support for oh-my-zsh
|
||||
|
||||
@@ -351,5 +351,3 @@ function _omz_diag_dump_os_specific_version() {
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
omz_diagnostic_dump "$@"
|
||||
@@ -78,10 +78,6 @@ fpath=($ZSH/{functions,completions} $ZSH_CUSTOM/{functions,completions} $fpath)
|
||||
# Load all stock functions (from $fpath files) called below.
|
||||
autoload -U compaudit compinit zrecompile
|
||||
|
||||
# The omz CLI and omz_diagnostic_dump are loaded on first use; -z keeps
|
||||
# zsh-style loading under kshautoload so the trailing call runs once
|
||||
autoload -Uz omz omz_diagnostic_dump
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
|
||||
@@ -35,7 +35,8 @@ plugins=(... aws)
|
||||
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`) and
|
||||
`$AWS_SHARED_CREDENTIALS_FILE` (default: `~/.aws/credentials`).
|
||||
Used to provide completion for the `asp` function.
|
||||
|
||||
* `aws_regions`: lists the available regions.
|
||||
|
||||
@@ -42,7 +42,7 @@ function asp() {
|
||||
export AWS_PROFILE=$1
|
||||
export AWS_EB_PROFILE=$1
|
||||
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
export AWS_PROFILE_REGION=$(_aws_profile_region "$1")
|
||||
|
||||
_aws_update_state
|
||||
|
||||
@@ -239,9 +239,50 @@ function aws_regions() {
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
command grep -Eo '^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?[^][:space:]]+[[:space:]]*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | command sed -E 's/^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?([^][:space:]]+)[[:space:]]*\]$/\2/'
|
||||
emulate -L zsh
|
||||
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
|
||||
local creds="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}"
|
||||
# Read the files directly; the AWS CLI is slow to start
|
||||
if [[ ! -r "$config" && ! -r "$creds" ]]; then
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null
|
||||
return
|
||||
fi
|
||||
local file line words
|
||||
for file in "$config" "$creds"; do
|
||||
# Only read the section headers, so the credentials never enter the shell
|
||||
for line in "${(@f)$(command grep '^[[:space:]]*\[' -- "$file" 2> /dev/null)}"; do
|
||||
line=${line#*\[} # drop up to the first [
|
||||
line=${line%\]*} # drop from the last ] (comments, CR)
|
||||
words=(${=line})
|
||||
if (( $#words == 1 )); then
|
||||
# [default], or any [foo] in the credentials file
|
||||
[[ $file == $creds || $words[1] == default ]] && print -r -- $words[1]
|
||||
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
||||
print -r -- $words[2]
|
||||
fi
|
||||
done
|
||||
done | command sort -u
|
||||
}
|
||||
|
||||
# Read a profile's region from the config file, falling back to the AWS CLI
|
||||
function _aws_profile_region() {
|
||||
emulate -L zsh
|
||||
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}" line words in_profile
|
||||
if [[ -r "$config" ]]; then
|
||||
# Only read headers and region lines, so any credentials never enter the shell
|
||||
for line in "${(@f)$(command grep -e '\[' -e region -- "$config" 2> /dev/null)}"; do
|
||||
line=${line%$'\r'}
|
||||
words=(${=line//[\[\]=]/ }) # "[profile foo]" -> (profile foo), "region = x" -> (region x)
|
||||
if [[ ${${=line}[1]} == \[* ]]; then # header, possibly indented
|
||||
in_profile=
|
||||
[[ "$words" == "profile $1" || ( $1 == default && "$words" == default ) ]] && in_profile=1
|
||||
elif [[ -n $in_profile && $words[1] == region ]]; then
|
||||
print -r -- $words[2]
|
||||
return
|
||||
fi
|
||||
done
|
||||
fi
|
||||
aws configure get region
|
||||
}
|
||||
|
||||
function _aws_regions() {
|
||||
@@ -285,7 +326,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(_aws_profile_region "$AWS_PROFILE")
|
||||
|
||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||
|
||||
@@ -84,6 +84,7 @@ If you use Podman's Docker wrapper, you need to enable legacy completion. See ab
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
| dvrm | `docker volume rm` | Remove one or more volumes |
|
||||
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
||||
| dxc | `docker container exec` | Run a new command in a running container |
|
||||
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
||||
@@ -35,6 +35,7 @@ alias dsts='docker stats'
|
||||
alias dtop='docker top'
|
||||
alias dvi='docker volume inspect'
|
||||
alias dvls='docker volume ls'
|
||||
alias dvrm='docker volume rm'
|
||||
alias dvprune='docker volume prune'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
|
||||
@@ -30,6 +30,7 @@ man-command-line() {
|
||||
else
|
||||
BUFFER="man ${args[1]}"
|
||||
fi
|
||||
zle end-of-line
|
||||
}
|
||||
|
||||
zle -N man-command-line
|
||||
|
||||
@@ -30,6 +30,8 @@ if it's found, or the mvn command otherwise.
|
||||
| `mvncisto` | `mvn clean install -DskipTests --offline` |
|
||||
| `mvncom` | `mvn compile` |
|
||||
| `mvncp` | `mvn clean package` |
|
||||
| `mvncpst` | `mvn clean package -DskipTests` |
|
||||
| `mvncpsto` | `mvn clean package -DskipTests --offline` |
|
||||
| `mvnct` | `mvn clean test` |
|
||||
| `mvncv` | `mvn clean verify` |
|
||||
| `mvncvst` | `mvn clean verify -DskipTests` |
|
||||
|
||||
@@ -59,6 +59,8 @@ alias mvncist='mvn clean install -DskipTests'
|
||||
alias mvncisto='mvn clean install -DskipTests --offline'
|
||||
alias mvncom='mvn compile'
|
||||
alias mvncp='mvn clean package'
|
||||
alias mvncpst='mvn clean package -DskipTests'
|
||||
alias mvncpsto='mvn clean package -DskipTests --offline'
|
||||
alias mvnct='mvn clean test'
|
||||
alias mvncv='mvn clean verify'
|
||||
alias mvncvst='mvn clean verify -DskipTests'
|
||||
|
||||
@@ -11,6 +11,7 @@ tldr-command-line() {
|
||||
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
|
||||
|
||||
BUFFER="tldr ${args[1]}"
|
||||
zle end-of-line
|
||||
}
|
||||
|
||||
zle -N tldr-command-line
|
||||
|
||||
@@ -22,7 +22,7 @@ plugins=(... uv)
|
||||
| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |
|
||||
| uvp | `uv pip` | Manage pip packages |
|
||||
| uvpi | `uv python install` | Install a specific version of python |
|
||||
| uvpl | `uv python list` | Lists all python version installed |
|
||||
| uvpl | `uv python list` | List all installed Python versions. |
|
||||
| uvpp | `uv python pin` | Pin the current project to use a specific Python version |
|
||||
| uvpu | `uv python uninstall` | Remove a specific version of python |
|
||||
| uvpy | `uv python` | Manage Python installs |
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# zsh-patina plugin
|
||||
|
||||
Initializes [zsh-patina](https://github.com/michel-kraemer/zsh-patina), a
|
||||
"blazingly fast Zsh plugin performing syntax highlighting of your command line
|
||||
while you type 🌈"
|
||||
|
||||
To use it, add `zsh-patina` to the plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... zsh-patina)
|
||||
```
|
||||
|
||||
zsh-patina replaces [zsh-syntax-highlighting](../zsh-syntax-highlighting), so
|
||||
enable only one of them. If zsh-syntax-highlighting is in the plugins array or
|
||||
already loaded, this plugin prints a warning and does not activate.
|
||||
|
||||
## Binary location
|
||||
|
||||
If `zsh-patina` is not in your `PATH` when Oh My Zsh loads (eg: it lives in
|
||||
`~/.cargo/bin`), set `ZSH_PATINA_BINARY` to its full path before sourcing
|
||||
Oh My Zsh:
|
||||
|
||||
```zsh
|
||||
ZSH_PATINA_BINARY=$HOME/.cargo/bin/zsh-patina
|
||||
```
|
||||
|
||||
**Note:** you have to [install zsh-patina](https://github.com/michel-kraemer/zsh-patina#how-to-install) first.
|
||||
@@ -0,0 +1,7 @@
|
||||
if (( $+ZSH_HIGHLIGHT_VERSION )) || (( ${plugins[(Ie)zsh-syntax-highlighting]} )); then
|
||||
echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them'
|
||||
elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then
|
||||
eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)"
|
||||
else
|
||||
echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina'
|
||||
fi
|
||||
Executable → Regular
File mode changed.
Reference in new issue
Block a user