mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-19 22:48:26 +08:00
Compare commits
2 Commits
97b27bb2ec
...
b54a719775
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b54a719775 | ||
|
|
1f9511f132 |
@@ -22,6 +22,21 @@ RPS1='$(kubectx_prompt_info)'
|
|||||||
PROMPT="$PROMPT"'$(kubectx_prompt_info)'
|
PROMPT="$PROMPT"'$(kubectx_prompt_info)'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The context is loaded asynchronously on supported versions of zsh so that
|
||||||
|
`kubectl` does not block the prompt. To restore synchronous behavior, add this
|
||||||
|
before Oh My Zsh is sourced:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:alpha:plugins:kubectx' async-prompt no
|
||||||
|
```
|
||||||
|
|
||||||
|
If your theme calls `kubectx_prompt_info` indirectly through another function,
|
||||||
|
force registration of the async handler instead:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:alpha:plugins:kubectx' async-prompt force
|
||||||
|
```
|
||||||
|
|
||||||
### Custom context names
|
### Custom context names
|
||||||
|
|
||||||
You can rename the default context name for better readability or additional formatting.
|
You can rename the default context name for better readability or additional formatting.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
typeset -g -A kubectx_mapping
|
typeset -g -A kubectx_mapping
|
||||||
|
|
||||||
function kubectx_prompt_info() {
|
function _omz_kubectx_prompt_info() {
|
||||||
(( $+commands[kubectl] )) || return
|
(( $+commands[kubectl] )) || return
|
||||||
|
|
||||||
local current_ctx=$(kubectl config current-context 2> /dev/null)
|
local current_ctx=$(kubectl config current-context 2> /dev/null)
|
||||||
@@ -13,3 +13,34 @@ function kubectx_prompt_info() {
|
|||||||
# the context name, as it could contain a % character.
|
# the context name, as it could contain a % character.
|
||||||
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
|
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function kubectx_prompt_info() {
|
||||||
|
if (( ${+_OMZ_ASYNC_OUTPUT} )) \
|
||||||
|
&& [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_kubectx_prompt_info]-}" ]]; then
|
||||||
|
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_kubectx_prompt_info]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
local _style
|
||||||
|
if zstyle -t ':omz:alpha:plugins:kubectx' async-prompt \
|
||||||
|
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:plugins:kubectx' async-prompt }; then
|
||||||
|
function _defer_async_kubectx_register() {
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT-}:${RPS1-}:${RPS2-}:${RPS3-}:${RPS4-}" in
|
||||||
|
*(\$\(kubectx_prompt_info\)|\`kubectx_prompt_info\`)*)
|
||||||
|
_omz_register_handler _omz_kubectx_prompt_info
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
add-zsh-hook -d precmd _defer_async_kubectx_register
|
||||||
|
unset -f _defer_async_kubectx_register
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
precmd_functions=(_defer_async_kubectx_register $precmd_functions)
|
||||||
|
elif zstyle -s ':omz:alpha:plugins:kubectx' async-prompt _style && [[ $_style == "force" ]]; then
|
||||||
|
_omz_register_handler _omz_kubectx_prompt_info
|
||||||
|
else
|
||||||
|
function kubectx_prompt_info() {
|
||||||
|
_omz_kubectx_prompt_info
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ plugins=(... laravel)
|
|||||||
|:-:|:-:|
|
|:-:|:-:|
|
||||||
| `artisan` | `php artisan` |
|
| `artisan` | `php artisan` |
|
||||||
| `pas` | `php artisan serve` |
|
| `pas` | `php artisan serve` |
|
||||||
|
| `pad` | `php artisan dev` |
|
||||||
| `pats` | `php artisan test` |
|
| `pats` | `php artisan test` |
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ alias bob='php artisan bob::build'
|
|||||||
|
|
||||||
# Development
|
# Development
|
||||||
alias pas='php artisan serve'
|
alias pas='php artisan serve'
|
||||||
|
alias pad='php artisan dev'
|
||||||
alias pats='php artisan test'
|
alias pats='php artisan test'
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
|||||||
Reference in New Issue
Block a user