mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-30 04:21:19 -08:00
parent
3673267deb
commit
441d1ff0af
|
@ -65,7 +65,11 @@ func runInit(shellName string) {
|
||||||
shell.Transient = cfg.TransientPrompt != nil
|
shell.Transient = cfg.TransientPrompt != nil
|
||||||
shell.ErrorLine = cfg.ErrorLine != nil || cfg.ValidLine != nil
|
shell.ErrorLine = cfg.ErrorLine != nil || cfg.ValidLine != nil
|
||||||
shell.Tooltips = len(cfg.Tooltips) > 0
|
shell.Tooltips = len(cfg.Tooltips) > 0
|
||||||
for _, block := range cfg.Blocks {
|
for i, block := range cfg.Blocks {
|
||||||
|
// only fetch cursor position when relevant
|
||||||
|
if i == 0 && block.Newline {
|
||||||
|
shell.Cursor = true
|
||||||
|
}
|
||||||
if block.Type == engine.RPrompt {
|
if block.Type == engine.RPrompt {
|
||||||
shell.RPrompt = true
|
shell.RPrompt = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ var (
|
||||||
ErrorLine bool
|
ErrorLine bool
|
||||||
Tooltips bool
|
Tooltips bool
|
||||||
RPrompt bool
|
RPrompt bool
|
||||||
|
Cursor bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func getExecutablePath(env platform.Environment) (string, error) {
|
func getExecutablePath(env platform.Environment) (string, error) {
|
||||||
|
@ -228,6 +229,7 @@ func PrintInit(env platform.Environment) string {
|
||||||
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
||||||
"::TOOLTIPS::", toggleSetting(Tooltips),
|
"::TOOLTIPS::", toggleSetting(Tooltips),
|
||||||
"::RPROMPT::", strconv.FormatBool(RPrompt),
|
"::RPROMPT::", strconv.FormatBool(RPrompt),
|
||||||
|
"::CURSOR::", strconv.FormatBool(Cursor),
|
||||||
).Replace(script)
|
).Replace(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ PS2="$(::OMP:: print secondary --config="$POSH_THEME" --shell=bash --shell-versi
|
||||||
function _set_posh_cursor_position() {
|
function _set_posh_cursor_position() {
|
||||||
# not supported in Midnight Commander
|
# not supported in Midnight Commander
|
||||||
# see https://github.com/JanDeDobbeleer/oh-my-posh/issues/3415
|
# see https://github.com/JanDeDobbeleer/oh-my-posh/issues/3415
|
||||||
if [[ -v MC_SID ]]; then
|
if [[ "::CURSOR::" != "true" ]] || [[ -v MC_SID ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ PS2="$(::OMP:: print secondary --config="$POSH_THEME" --shell=zsh)"
|
||||||
function _set_posh_cursor_position() {
|
function _set_posh_cursor_position() {
|
||||||
# not supported in Midnight Commander
|
# not supported in Midnight Commander
|
||||||
# see https://github.com/JanDeDobbeleer/oh-my-posh/issues/3415
|
# see https://github.com/JanDeDobbeleer/oh-my-posh/issues/3415
|
||||||
if [[ -v MC_SID ]]; then
|
if [[ "::CURSOR::" != "true" ]] || [[ -v MC_SID ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -54,25 +54,10 @@ function prompt_ohmyposh_precmd() {
|
||||||
unset omp_start_time
|
unset omp_start_time
|
||||||
}
|
}
|
||||||
|
|
||||||
function _install-omp-hooks() {
|
# add hook functions
|
||||||
for s in "${preexec_functions[@]}"; do
|
autoload -Uz add-zsh-hook
|
||||||
if [ "$s" = "prompt_ohmyposh_preexec" ]; then
|
add-zsh-hook precmd prompt_ohmyposh_precmd
|
||||||
return
|
add-zsh-hook preexec prompt_ohmyposh_preexec
|
||||||
fi
|
|
||||||
done
|
|
||||||
preexec_functions+=(prompt_ohmyposh_preexec)
|
|
||||||
|
|
||||||
for s in "${precmd_functions[@]}"; do
|
|
||||||
if [ "$s" = "prompt_ohmyposh_precmd" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
precmd_functions+=(prompt_ohmyposh_precmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$TERM" != "linux" ]; then
|
|
||||||
_install-omp-hooks
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform cleanup so a new initialization in current session works
|
# perform cleanup so a new initialization in current session works
|
||||||
if [[ "$(zle -lL self-insert)" = *"_posh-tooltip"* ]]; then
|
if [[ "$(zle -lL self-insert)" = *"_posh-tooltip"* ]]; then
|
||||||
|
|
Loading…
Reference in a new issue