mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-12 01:52:31 +01:00
feat(branch): show mercurial bookmarks if used (#9948)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
This commit is contained in:
parent
c66fc00401
commit
46e63340ee
2 changed files with 56 additions and 36 deletions
|
|
@ -1,31 +1,47 @@
|
|||
# Branch
|
||||
# Branch plugin
|
||||
|
||||
Displays the current Git or Mercurial branch fast.
|
||||
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)
|
||||
```
|
||||
|
||||
## Speed test
|
||||
|
||||
### Mercurial
|
||||
- `hg branch`:
|
||||
|
||||
```shell
|
||||
$ time hg branch
|
||||
0.11s user 0.14s system 70% cpu 0.355 total
|
||||
```
|
||||
```console
|
||||
$ time hg branch
|
||||
0.11s user 0.14s system 70% cpu 0.355 total
|
||||
```
|
||||
|
||||
### Branch plugin
|
||||
- branch plugin:
|
||||
|
||||
```shell
|
||||
$ time zsh /tmp/branch_prompt_info_test.zsh
|
||||
0.00s user 0.01s system 78% cpu 0.014 total
|
||||
```
|
||||
```console
|
||||
$ time zsh /tmp/branch_prompt_info_test.zsh
|
||||
0.00s user 0.01s system 78% cpu 0.014 total
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
|
||||
adding `$(branch_prompt_info)` in your prompt like this:
|
||||
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:
|
||||
|
||||
```diff
|
||||
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
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)'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
```
|
||||
|
||||
## Maintainer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue