Thursday, May 2, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 13255  / 2 Years ago, tue, april 5, 2022, 11:50:27

When working on a git repository with multiple branches, how do I modify my zsh prompt to include my current active branch?


More From » command-line

 Answers
6

Use the vcs_info function in the zsh user contributions (included in the zsh package). Quick start:



autoload -Uz vcs_info
precmd () { vcs_info }
setopt prompt_subst
PS1="$vcs_info_msg_0_$PS1"


It's likely that you'll want to make the output prettier. Since that's matter of personal taste, I refer you to the examples in the documentation.


[#41650] Thursday, April 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
afisird

Total Points: 193
Total Questions: 112
Total Answers: 111

Location: Angola
Member since Mon, Jul 12, 2021
3 Years ago
afisird questions
Wed, Jul 27, 22, 03:53, 2 Years ago
Sun, Mar 12, 23, 18:05, 1 Year ago
Sun, Dec 11, 22, 01:19, 1 Year ago
;