문제

This is my PROMPT configuration in zsh:

PROMPT=$'
%{$purple%}%n%{$reset_color%} at %{$orange%}%m%{$reset_color%} in %{$limegreen%}%~%{$reset_color%} $vcs_info_msg_0_
$ '

And this is how my zsh displays

shell screenshoot

At first I just want to get the master** string for other use, then I searched for how zsh got it, and found that the message was generated by zsh's vcs_info package, and was stored in $vcs_info_msg_0_, but as the screenshot shows, the echo result of that variable was very strange. Why did this happen, and how can I just get the git information (master** with color) of a repository folder?

도움이 되었습니까?

해결책

That's because the variable is only to be used in prompts, nowhere else. The strange things you see are special control sequences that are interpreted by ZSH when rendering the prompt.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top