2021-12-01 17:49:42 +01:00
|
|
|
# Branch plugin
|
2015-10-03 04:16:56 +02:00
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository,
|
|
|
|
also display the current bookmark, if present.
|
|
|
|
|
|
|
|
To use it, add `branch` to the plugins array in your zshrc file:
|
|
|
|
|
|
|
|
```zsh
|
|
|
|
plugins=(... branch)
|
|
|
|
```
|
2015-10-03 04:16:56 +02:00
|
|
|
|
|
|
|
## Speed test
|
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
- `hg branch`:
|
2015-10-03 04:16:56 +02:00
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
```console
|
|
|
|
$ time hg branch
|
|
|
|
0.11s user 0.14s system 70% cpu 0.355 total
|
|
|
|
```
|
2015-10-03 04:16:56 +02:00
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
- branch plugin:
|
2015-10-03 04:16:56 +02:00
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
```console
|
|
|
|
$ time zsh /tmp/branch_prompt_info_test.zsh
|
|
|
|
0.00s user 0.01s system 78% cpu 0.014 total
|
|
|
|
```
|
2015-10-03 04:16:56 +02:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
|
|
|
|
This example is for the `robbyrussell` theme:
|
2015-10-03 04:16:56 +02:00
|
|
|
|
|
|
|
```diff
|
2021-12-01 17:49:42 +01:00
|
|
|
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
|
|
|
|
index 2fd5f2cd..9d89a464 100644
|
|
|
|
--- a/themes/robbyrussell.zsh-theme
|
|
|
|
+++ b/themes/robbyrussell.zsh-theme
|
|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
|
|
|
|
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
|
|
|
|
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
|
2024-03-26 09:55:16 +01:00
|
|
|
|
2021-12-01 17:49:42 +01:00
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
2015-10-03 04:16:56 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Maintainer
|
|
|
|
|
|
|
|
Victor Torres (<vpaivatorres@gmail.com>)
|