1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

[git-info] Add complete example to README.md

so users don't need to look at our prompts code to figure out how having
all the pieces together looks like.
This commit is contained in:
Eric Nielsen 2018-12-26 20:56:57 -05:00
parent 882408b762
commit 1ab110c264

View file

@ -101,3 +101,29 @@ Second, format how the above attributes are displayed in prompts:
Last, add `${(e)git_info[prompt]}` and `${(e)git_info[rprompt]}` to `PS1` and Last, add `${(e)git_info[prompt]}` and `${(e)git_info[rprompt]}` to `PS1` and
`RPS1` respectively, and call `git-info` in the `prompt_name_precmd` hook function. `RPS1` respectively, and call `git-info` in the `prompt_name_precmd` hook function.
Here's a complete example of a `prompt_example_setup` file:
```zsh
prompt_example_precmd() {
(( ${+functions[git-info]} )) && git-info
}
prompt_example_setup() {
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_example_precmd
prompt_opts=(cr percent sp subst)
zstyle ':zim:git-info:branch' format 'branch:%b'
zstyle ':zim:git-info:commit' format 'commit:%c'
zstyle ':zim:git-info:remote' format 'remote:%R'
zstyle ':zim:git-info:keys' format \
'prompt' 'git(%b%c)' \
'rprompt' '[%R]'
PS1='${(e)git_info[prompt]}%# '
RPS1='${(e)git_info[rprompt]}'
}
prompt_example_setup "${@}"
```