mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-28 14:06:12 +02:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4569fd2164 | ||
|
|
610d66ae06 | ||
|
|
426650fbe8 | ||
|
|
8a5b393088 |
@@ -36,6 +36,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
for file in ./oh-my-zsh.sh \
|
for file in ./oh-my-zsh.sh \
|
||||||
./lib/*.zsh \
|
./lib/*.zsh \
|
||||||
|
./functions/* \
|
||||||
|
./completions/_* \
|
||||||
./plugins/*/*.plugin.zsh \
|
./plugins/*/*.plugin.zsh \
|
||||||
./plugins/*/_* \
|
./plugins/*/_* \
|
||||||
./themes/*.zsh-theme; do
|
./themes/*.zsh-theme; do
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
#compdef omz
|
||||||
|
|
||||||
|
local -a cmds subcmds
|
||||||
|
cmds=(
|
||||||
|
'changelog:Print the changelog'
|
||||||
|
'help:Usage information'
|
||||||
|
'plugin:Manage plugins'
|
||||||
|
'pr:Manage Oh My Zsh Pull Requests'
|
||||||
|
'reload:Reload the current zsh session'
|
||||||
|
'shop:Open the Oh My Zsh shop'
|
||||||
|
'theme:Manage themes'
|
||||||
|
'update:Update Oh My Zsh'
|
||||||
|
'version:Show the version'
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
|
|
||||||
function omz {
|
function omz {
|
||||||
setopt localoptions noksharrays
|
setopt localoptions noksharrays
|
||||||
[[ $# -gt 0 ]] || {
|
[[ $# -gt 0 ]] || {
|
||||||
@@ -20,102 +18,6 @@ function omz {
|
|||||||
_omz::$command "$@"
|
_omz::$command "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz {
|
|
||||||
local -a cmds subcmds
|
|
||||||
cmds=(
|
|
||||||
'changelog:Print the changelog'
|
|
||||||
'help:Usage information'
|
|
||||||
'plugin:Manage plugins'
|
|
||||||
'pr:Manage Oh My Zsh Pull Requests'
|
|
||||||
'reload:Reload the current zsh session'
|
|
||||||
'shop:Open the Oh My Zsh shop'
|
|
||||||
'theme:Manage themes'
|
|
||||||
'update:Update Oh My Zsh'
|
|
||||||
'version:Show the version'
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
## Utility functions
|
||||||
|
|
||||||
function _omz::confirm {
|
function _omz::confirm {
|
||||||
@@ -942,3 +844,5 @@ function _omz::version {
|
|||||||
printf "%s (%s)\n" "$version" "$commit"
|
printf "%s (%s)\n" "$version" "$commit"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
omz "$@"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# diagnostics.zsh
|
# omz_diagnostic_dump
|
||||||
#
|
#
|
||||||
# Diagnostic and debugging support for oh-my-zsh
|
# Diagnostic and debugging support for oh-my-zsh
|
||||||
|
|
||||||
@@ -351,3 +351,5 @@ function _omz_diag_dump_os_specific_version() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
omz_diagnostic_dump "$@"
|
||||||
@@ -78,6 +78,9 @@ fpath=($ZSH/{functions,completions} $ZSH_CUSTOM/{functions,completions} $fpath)
|
|||||||
# Load all stock functions (from $fpath files) called below.
|
# Load all stock functions (from $fpath files) called below.
|
||||||
autoload -U compaudit compinit zrecompile
|
autoload -U compaudit compinit zrecompile
|
||||||
|
|
||||||
|
# The omz CLI and omz_diagnostic_dump are loaded on first use
|
||||||
|
autoload -Uz omz omz_diagnostic_dump
|
||||||
|
|
||||||
is_plugin() {
|
is_plugin() {
|
||||||
local base_dir=$1
|
local base_dir=$1
|
||||||
local name=$2
|
local name=$2
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ plugins=(... kubectl)
|
|||||||
| | | **Secret management** |
|
| | | **Secret management** |
|
||||||
| kgsec | `kubectl get secret` | Get secret for decoding |
|
| kgsec | `kubectl get secret` | Get secret for decoding |
|
||||||
| kgseca | `kubectl get secret --all-namespaces` | List secrets across all namespaces |
|
| kgseca | `kubectl get secret --all-namespaces` | List secrets across all namespaces |
|
||||||
|
| kesec | `kubectl edit secret` | Edit secret resource |
|
||||||
| kdsec | `kubectl describe secret` | Describe secret resource in detail |
|
| kdsec | `kubectl describe secret` | Describe secret resource in detail |
|
||||||
| kdelsec | `kubectl delete secret` | Delete the secret |
|
| kdelsec | `kubectl delete secret` | Delete the secret |
|
||||||
| | | **Deployment management** |
|
| | | **Deployment management** |
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ alias kdelcm='kubectl delete configmap'
|
|||||||
# Secret management
|
# Secret management
|
||||||
alias kgsec='kubectl get secret'
|
alias kgsec='kubectl get secret'
|
||||||
alias kgseca='kubectl get secret --all-namespaces'
|
alias kgseca='kubectl get secret --all-namespaces'
|
||||||
|
alias kesec='kubectl edit secret'
|
||||||
alias kdsec='kubectl describe secret'
|
alias kdsec='kubectl describe secret'
|
||||||
alias kdelsec='kubectl delete secret'
|
alias kdelsec='kubectl delete secret'
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
# - https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Resources/completion.bash
|
# - https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Resources/completion.bash
|
||||||
#
|
#
|
||||||
_sf_console() {
|
_sf_console() {
|
||||||
local lastParam flagPrefix requestComp out comp
|
local lastParam out comp sf_cmd
|
||||||
local -a completions
|
local -a completions flagPrefix requestComp inputs
|
||||||
|
|
||||||
# The user could have moved the cursor backwards on the command-line.
|
# The user could have moved the cursor backwards on the command-line.
|
||||||
# We need to trigger completion from the $CURRENT location, so we need
|
# We need to trigger completion from the $CURRENT location, so we need
|
||||||
@@ -29,11 +29,20 @@ _sf_console() {
|
|||||||
setopt local_options BASH_REMATCH
|
setopt local_options BASH_REMATCH
|
||||||
if [[ "${lastParam}" =~ '-.*=' ]]; then
|
if [[ "${lastParam}" =~ '-.*=' ]]; then
|
||||||
# We are dealing with a flag with an =
|
# We are dealing with a flag with an =
|
||||||
flagPrefix="-P ${BASH_REMATCH}"
|
flagPrefix=(-P "${BASH_REMATCH}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare the command to obtain completions
|
# Prepare the command to obtain completions. An alias is resolved here,
|
||||||
requestComp="${words[0]} ${words[1]} _complete --no-interaction -szsh -a1 -c$((CURRENT-1))" i=""
|
# because the request is no longer read again by the shell.
|
||||||
|
sf_cmd="${words[1]}"
|
||||||
|
if [[ -n "${aliases[$sf_cmd]}" ]]; then
|
||||||
|
requestComp=(${(z)aliases[$sf_cmd]})
|
||||||
|
else
|
||||||
|
requestComp=(${~sf_cmd})
|
||||||
|
fi
|
||||||
|
|
||||||
|
requestComp+=(_complete --no-interaction -szsh -a1 "-c$((CURRENT-1))")
|
||||||
|
|
||||||
for w in ${words[@]}; do
|
for w in ${words[@]}; do
|
||||||
w=$(printf -- '%b' "$w")
|
w=$(printf -- '%b' "$w")
|
||||||
# remove quotes from typed values
|
# remove quotes from typed values
|
||||||
@@ -47,19 +56,18 @@ _sf_console() {
|
|||||||
fi
|
fi
|
||||||
# empty values are ignored
|
# empty values are ignored
|
||||||
if [ ! -z "$w" ]; then
|
if [ ! -z "$w" ]; then
|
||||||
i="${i}-i${w} "
|
inputs+=("-i$w")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Ensure at least 1 input
|
# Ensure at least 1 input
|
||||||
if [ "${i}" = "" ]; then
|
if (( ! $#inputs )); then
|
||||||
requestComp="${requestComp} -i\" \""
|
inputs=(-i' ')
|
||||||
else
|
|
||||||
requestComp="${requestComp} ${i}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use eval to handle any environment variables and such
|
# The request is run without being read again by the shell, so that a
|
||||||
out=$(eval ${requestComp} 2>/dev/null)
|
# "$(...)" or a backtick typed on the command line is not executed
|
||||||
|
out=$(SHELL_VERBOSITY=0 "${requestComp[@]}" "${inputs[@]}" 2>/dev/null)
|
||||||
|
|
||||||
while IFS='\n' read -r comp; do
|
while IFS='\n' read -r comp; do
|
||||||
if [ -n "$comp" ]; then
|
if [ -n "$comp" ]; then
|
||||||
@@ -75,7 +83,7 @@ _sf_console() {
|
|||||||
done < <(printf "%s\n" "${out[@]}")
|
done < <(printf "%s\n" "${out[@]}")
|
||||||
|
|
||||||
# Let inbuilt _describe handle completions
|
# Let inbuilt _describe handle completions
|
||||||
eval _describe "completions" completions $flagPrefix
|
_describe "completions" completions "${flagPrefix[@]}"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user