function Show_current_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/(\1)/p'
}
setopt PROMPT_SUBST
PROMPT='%f%B%3~%b%f %F{#76946A}$(Show_current_branch) %f%F{#76946A}> '
当我重新加载 zshrc 时,出现以下错误消息: source ~/.zshrc
我已经尝试过:
function Show_current_branch()
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/(\1)/p'
endfunction
正如我所言,您可以在函数定义末尾添加
:endfunction
标签
function Show_current_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/(\1)/p'
}
endfunction
setopt PROMPT_SUBST
PROMPT='%f%B%3~%b%f %F{#76946A}$(Show_current_branch) %f%F{#76946A}> '
现在保存并退出,然后输入此命令重新加载
zshrc
source ~/.zshrc