mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix(tooltip): check only the first word of command line
This commit is contained in:
parent
7368c6541e
commit
14f012308e
|
@ -69,19 +69,6 @@ if [[ "$(zle -lL zle-line-init)" = *"_posh-zle-line-init"* ]]; then
|
|||
fi
|
||||
|
||||
function _posh-tooltip() {
|
||||
# ignore an empty buffer
|
||||
if [[ -z "$BUFFER" ]]; then
|
||||
zle .self-insert
|
||||
return
|
||||
fi
|
||||
|
||||
local tooltip=$(::OMP:: print tooltip --config="$POSH_THEME" --shell=zsh --error="$omp_last_error" --command="$BUFFER" --shell-version="$ZSH_VERSION")
|
||||
# ignore an empty tooltip
|
||||
if [[ -n "$tooltip" ]]; then
|
||||
RPROMPT=$tooltip
|
||||
zle .reset-prompt
|
||||
fi
|
||||
|
||||
# https://github.com/zsh-users/zsh-autosuggestions - clear suggestion to avoid keeping it after the newly inserted space
|
||||
if [[ -n "$(zle -lL autosuggest-clear)" ]]; then
|
||||
# only if suggestions not disabled (variable not set)
|
||||
|
@ -97,6 +84,20 @@ function _posh-tooltip() {
|
|||
zle autosuggest-fetch
|
||||
fi
|
||||
fi
|
||||
|
||||
# get the first word of command line as tip
|
||||
local tip=${${(MS)BUFFER##[[:graph:]]*}%%[[:space:]]*}
|
||||
# ignore an empty tip
|
||||
if [[ -z "$tip" ]]; then
|
||||
return
|
||||
fi
|
||||
local tooltip=$(::OMP:: print tooltip --config="$POSH_THEME" --shell=zsh --error="$omp_last_error" --command="$tip" --shell-version="$ZSH_VERSION")
|
||||
# ignore an empty tooltip
|
||||
if [[ -z "$tooltip" ]]; then
|
||||
return
|
||||
fi
|
||||
RPROMPT=$tooltip
|
||||
zle .reset-prompt
|
||||
}
|
||||
|
||||
function _posh-zle-line-init() {
|
||||
|
|
|
@ -44,7 +44,7 @@ import Config from '@site/src/components/Config.js';
|
|||
}}/>
|
||||
|
||||
This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space.
|
||||
A tip should not include any leading or trailing space but an interpolated one can be used, e.g., `g s`.
|
||||
Keep in mind that this is a blocking call, meaning that if the segment renders slow, you can't type until it's visible. Optimizations in this space are being explored.
|
||||
A tip should not include any spaces. Keep in mind that this is a blocking call, meaning that if the segment renders slow,
|
||||
you can't type until it's visible. Optimizations in this space are being explored.
|
||||
|
||||
[clink]: https://chrisant996.github.io/clink/
|
||||
|
|
Loading…
Reference in a new issue