Default posh-git prompt #2773
|
Hi, I would like to get the default posh-git prompt. P.S. I do not want to construct if from scratch since it is already provided by posh-git. |
Replies: 2 comments 11 replies
|
@daniporr the exact same prompt? Because I just refactored everything so that posh-git and git are perfectly aligned. You don't really need to do anything other than enable posh-git, the default rendering is already providing all information correctly. |
A custom template to mimic the posh-git promptI agree that the best answer to this discussion is: But I wanted to see how difficult it would be to faithfully mimic the posh-git prompt using the oh-my-posh properties, so I have created the following segment: {
"foreground": "cyan",
"foreground_templates": [
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}yellow{{ end }}",
"{{ if gt .Ahead 0 }}green{{ end }}",
"{{ if gt .Behind 0 }}red{{ end }}"
],
"properties": {
"branch_icon": "",
"commit_icon": ""
},
"style": "diamond",
"leading_diamond": "<lightYellow>[</>",
"trailing_diamond": "<lightYellow>]</>",
"template": "{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Staging.Changed }} <green>{{ .Staging.String }}</>{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}<red>{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (not .Staging.Changed) }} !{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} ~{{ end }}</>",
"type": "git"
}Following the description in the official repository as faithfully as possible: I hope this can be useful to someone. Please let me know if you think it can be improved (and how you think it can be improved) |

@daniporr the exact same prompt? Because I just refactored everything so that posh-git and git are perfectly aligned. You don't really need to do anything other than enable posh-git, the default rendering is already providing all information correctly.