双 zsh 提示显示未格式化然后格式化

双 zsh 提示显示未格式化然后格式化

我运行的任何命令(除了clear)都会产生双 zsh 提示符 - 第一个显示未格式化的提示符,第二个显示正确的格式化提示符。

在此输入图像描述

我的~/.zshrc文件:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="agnoster"

 zstyle ':omz:update' mode auto      # update automatically without asking


  ENABLE_CORRECTION="true"

  COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"


 HIST_STAMPS="mm/dd/yyyy"

plugins=(
  zsh-completions
  git
  pip
  jsontools
  dotenv
)

source ~/powerlevel10k/powerlevel10k.zsh-theme

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh


[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

export FZF_DEFAULT_OPTS='-height=40% -preview="cat {}" -preview-window=right:60%:wrap'

alias ip="ipconfig getifaddr en0"
alias zshconf="vim ~/.zshrc"
alias szsh="source ~/.zshrc"
alias ohmyzsh="cd ~/.oh-my-zsh"
alias gs="git status"
alias gac="git add . && git commit -am"
alias gb="git branch --show-current"
alias goof="git add --all && git commit --amend --no-edit"
alias ff="find . | grep "
alias ft="grep -lrni -e "
alias rando="openssl rand -base64 24"

fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh


source $ZSH/oh-my-zsh.sh

[[ -s "/Users/<user>/.gvm/scripts/gvm" ]] && source "/Users/<user>/.gvm/scripts/gvm"

任何帮助表示赞赏。谢谢!

命令输出:typeset -p PS1 RPS1; typeset -fp precmd preexec $precmd_functions $preexec_functions

typeset PS1=$'${$((_p9k_on_expand()))+}%{${_p9k__raw_msg-}${_p9k__raw_msg::=}%}${(e)_p9k_t[7]}${_p9k__1-${${:-${_p9k__d::=0}${_p9k__rprompt::=${_p9k__1r-${${:-${_p9k__bg::=NONE}${_p9k__i::=0}${_p9k__sss::=${(Q)${:-"%\\\\{%\\\\}"}}}}+}${${:-"${${(%):-%j}:#0}"}:+${${:-${P9K_CONTENT::=""}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=12}}${_p9k__n:=${${(M)${:-x$_p9k__bg}:#x(000|000)}:+14}}${_p9k__n:=15}${_p9k__v::=}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1rbackground_jobs+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}1}}}+}${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/<_p9k__w>/$_p9k__w}${_p9k__c}%b%K{000\\}%F{006\\}${${(M)_p9k__e:#11}:+ }$_p9k__v${${:-${_p9k__w::=%b%K{000\\}%F{006\\} %b%K{000\\}%F{006\\}}${_p9k__sss::=%b%K{000\\}%F{006\\} %k%F{000\\}%b%K{000\\}%F{006\\}}${_p9k__i::=3}${_p9k__bg::=000}}+}}}${${:-"${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}"}:+${${:-${P9K_CONTENT::=OVERTYPE}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=28}}${_p9k__n:=${${(M)${:-x$_p9k__bg}:#x(003|003)}:+30}}${_p9k__n:=31}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1rvi_mode+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}0}}}+}${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/<_p9k__w>/$_p9k__w}${_p9k__c}%b%K{003\\}%F{000\\}${${:-${_p9k__w::=%b%K{003\\}%F{000\\} %b%K{003\\}%F{000\\}}${_p9k__sss::=%b%K{003\\}%F{000\\} %k%F{003\\}%b%K{003\\}%F{000\\}}${_p9k__i::=41}${_p9k__bg::=003}}+}}}${${:-"${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}"}:+${${:-${P9K_CONTENT::=NORMAL}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=32}}${_p9k__n:=${${(M)${:-x$_p9k__bg}:#x(002|002)}:+34}}${_p9k__n:=35}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1rvi_mode+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}0}}}+}${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/<_p9k__w>/$_p9k__w}${_p9k__c}%b%K{002\\}%F{000\\}${${:-${_p9k__w::=%b%K{002\\}%F{000\\} %b%K{002\\}%F{000\\}}${_p9k__sss::=%b%K{002\\}%F{000\\} %k%F{002\\}%b%K{002\\}%F{000\\}}${_p9k__i::=41}${_p9k__bg::=002}}+}}}${${:-"${(M)${:-$_p9k__keymap$_p9k__region_active}:#(vicmd1|vivis?|vivli?)}"}:+${${:-${P9K_CONTENT::=VISUAL}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=36}}${_p9k__n:=${${(M)${:-x$_p9k__bg}:#x(004|004)}:+38}}${_p9k__n:=39}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1rvi_mode+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}0}}}+}${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/<_p9k__w>/$_p9k__w}${_p9k__c}%b%K{004\\}%F{000\\}${${:-${_p9k__w::=%b%K{004\\}%F{000\\} %b%K{004\\}%F{000\\}}${_p9k__sss::=%b%K{004\\}%F{000\\} %k%F{004\\}%b%K{004\\}%F{000\\}}${_p9k__i::=41}${_p9k__bg::=004}}+}}}${${:-${P9K_CONTENT::=08:53:09 AM}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=40}}${_p9k__n:=${${(M)${:-x$_p9k__bg}:#x(007|007)}:+42}}${_p9k__n:=43}${_p9k__v::=}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1rtime+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}1}}}+}${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/<_p9k__w>/$_p9k__w}at ${_p9k__c}%b%K{007\\}%F{000\\}${${(M)_p9k__e:#11}:+ }$_p9k__v${${:-${_p9k__w::=%b%K{007\\}%F{000\\} %b%K{007\\}%F{000\\}}${_p9k__sss::=%b%K{007\\}%F{000\\} %k%F{007\\}%b%K{007\\}%F{000\\}}${_p9k__i::=46}${_p9k__bg::=007}}+}}$_p9k__sss%b%k%f}}${_p9k__lprompt::=${_p9k__1l_frame-"%240F╭─"}${_p9k__1l-${${:-${_p9k__bg::=NONE}${_p9k__i::=0}${_p9k__sss::=%f}}+}${${:-${P9K_CONTENT::=}${_p9k__n::=}${${${_p9k__bg:-0}:#NONE}:-${_p9k__n::=44}}${_p9k__n:=${${(M)${:-x007}:#x($_p9k__bg|${_p9k__bg:-0})}:+46}}${_p9k__n:=47}${_p9k__c::="${P9K_CONTENT}"}${_p9k__c::=${_p9k__c//\C-M}}${_p9k__e::=${${_p9k__1los_icon+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}0}}}+}${${_p9k__e:#00}:+${${_p9k_t[$_p9k__n]/<_p9k__ss>/$_p9k__ss}/<_p9k__s>/$_p9k__s}${_p9k__c}%b%K{007\\}%F{232\\} ${${:-${_p9k__s::=%F{007\\}}${_p9k__ss::=}${_p9k__sss::=%F{007\\}}${_p9k__i::=1}${_p9k__bg::=007}}+}}${(e)_p9k__vcs}%b%k$_p9k__sss%b%k%f}}}+}${(e)_p9k_t[6]}${_p9k__lprompt}${${_p9k__g+\n}:-${:-"%F{240}"}${${${_p9k__m:#-*}:+${${_p9k__1g+${(pl.$((_p9k__m+1)).. .)}}:-${(pl.$((_p9k__m+1))..─.)}}$_p9k__rprompt${_p9k_t[$((1+!_p9k__ind))]}}:-\n}%b%k%f}}${_p9k__2-${_p9k__2l_frame-"%240F╰─"}${_p9k__2l-${${:-${_p9k__bg::=NONE}${_p9k__i::=0}${_p9k__sss::=%f}}+}%b%k$_p9k__sss%b%k%f${:-" %b%k%f"}}}${${COLUMNS::=$_p9k__clm}+}'
_p9k_do_nothing () {
    true
}
_zsh_autosuggest_start () {
    if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} ))
    then
        add-zsh-hook -d precmd _zsh_autosuggest_start
    fi
    _zsh_autosuggest_bind_widgets
}
omz_termsupport_precmd () {
    [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
    title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
}
omz_termsupport_cwd () {
    local URL_HOST URL_PATH
    URL_HOST="$(omz_urlencode -P $HOST)"  || return 1
    URL_PATH="$(omz_urlencode -P $PWD)"  || return 1
    [[ -z "$KONSOLE_VERSION" ]] || URL_HOST=""
    printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
}
_p9k_precmd () {
    __p9k_new_status=$?
    __p9k_new_pipestatus=($pipestatus)
    trap ":" INT
    [[ -o ksh_arrays ]] && __p9k_ksh_arrays=1  || __p9k_ksh_arrays=0
    [[ -o sh_glob ]] && __p9k_sh_glob=1  || __p9k_sh_glob=0
    _p9k_restore_special_params
    _p9k_precmd_impl
    [[ ${+__p9k_instant_prompt_active} == 0 || -o no_prompt_cr ]] || __p9k_instant_prompt_active=2
    setopt no_local_options no_prompt_bang prompt_percent prompt_subst prompt_cr prompt_sp
    typeset -g __p9k_trapint='_p9k_trapint; return 130'
    trap "$__p9k_trapint" INT
    : ${(%):-%b%k%s%u}
}
_p9k_preexec1 () {
    _p9k_restore_special_params
    unset __p9k_trapint
    trap - INT
}
omz_termsupport_preexec () {
    [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
    emulate -L zsh
    setopt extended_glob
    local -a cmdargs
    cmdargs=("${(z)2}")
    if [[ "${cmdargs[1]}" = fg ]]
    then
        local job_id jobspec="${cmdargs[2]#%}"
        case "$jobspec" in
            (<->) job_id=${jobspec}  ;;
            ("" | % | +) job_id=${(k)jobstates[(r)*:+:*]}  ;;
            (-) job_id=${(k)jobstates[(r)*:-:*]}  ;;
            ([?]*) job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]}  ;;
            (*) job_id=${(k)jobtexts[(r)${(Q)jobspec}*]}  ;;
        esac
        if [[ -n "${jobtexts[$job_id]}" ]]
        then
            1="${jobtexts[$job_id]}"
            2="${jobtexts[$job_id]}"
        fi
    fi
    local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
    local LINE="${2:gs/%/%%}"
    title "$CMD" "%100>...>${LINE}%<<"
}
_p9k_preexec2 () {
    typeset -g _p9k__preexec_cmd=$2
    _p9k__timer_start=EPOCHREALTIME
    P9K_TTY=old
    (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec
}

答案1

事实证明,source $ZSH/oh-my-zsh.sh~/.zshrc导致了 Powerlevel10k 的一些问题。将此行注释掉,退出 iTerm2 并重新打开后提示符恢复正常。

相关内容