Ser*_*rov 4 git macos terminal zsh prompt
Apple在其最新的操作系统中将shell 从 更改bash为zsh,所以我现在正在尝试修复我的终端提示:(。
我希望我的提示只包含:
~ 如果我在主目录中$和最后一个空格我曾经在我的这个剧本.bash_profile时,我使用bash:
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[33;1m\]\W\[\033[32m\]\$(parse_git_branch)\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
Run Code Online (Sandbox Code Playgroud)
我重命名.bash_profile为.zprofile,但除ls部分外,所有这些都不再起作用。
我如何使这项工作再次发挥作用?
因此,经过更多的谷歌搜索并查看zsh可以通过运行显示的手册的特定部分后,man zshmisc我设法解决了这个问题。这是代码.zprofile:
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '%b'
# Set up the prompt
setopt PROMPT_SUBST
PROMPT='%1~ %F{green}${vcs_info_msg_0_}%f $ '
Run Code Online (Sandbox Code Playgroud)
%1~意味着只显示当前工作目录的最后一个尾随部分,主目录将替换为~.
| 归档时间: |
|
| 查看次数: |
2780 次 |
| 最近记录: |