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