Diff
1diff --git a/plugins/branch/README.md b/plugins/branch/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..f970266a81daaf5bde7628be7ff336d02046724e
4--- /dev/null
5+++ b/plugins/branch/README.md
6@@ -0,0 +1,33 @@
7+# Branch
8+
9+Displays the current Git or Mercurial branch fast.
10+
11+## Speed test
12+
13+### Mercurial
14+
15+```shell
16+$ time hg branch
17+0.11s user 0.14s system 70% cpu 0.355 total
18+```
19+
20+### Branch plugin
21+
22+```shell
23+$ time sh /tmp/branch_prompt_info.sh
24+0.01s user 0.01s system 81% cpu 0.018 total
25+```
26+
27+## Usage
28+
29+Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
30+adding `$(branch_prompt_info)` in your prompt like this:
31+
32+```diff
33+- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
34++ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
35+```
36+
37+## Maintainer
38+
39+Victor Torres (<vpaivatorres@gmail.com>)
40diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh
41new file mode 100644
42index 0000000000000000000000000000000000000000..c918ea2b5a9152609da0a7d2992bd3c21b823f0e
43--- /dev/null
44+++ b/plugins/branch/branch.plugin.zsh
45@@ -0,0 +1,26 @@
46+# Branch: displays the current Git or Mercurial branch fast.
47+# Victor Torres <vpaivatorres@gmail.com>
48+# Oct 2, 2015
49+
50+function branch_prompt_info() {
51+ # Defines path as current directory
52+ path=$(pwd)
53+ # While current path is not root path
54+ while [ $path != '/' ];
55+ do
56+ # Git repository
57+ if [ -d ${path}/.git ];
58+ then
59+ echo '±' $(/bin/cat ${path}/.git/HEAD | /usr/bin/cut -d / -f 3-)
60+ return;
61+ fi
62+ # Mercurial repository
63+ if [ -d ${path}/.hg ];
64+ then
65+ echo '☿' $(/bin/cat ${path}/.hg/branch)
66+ return;
67+ fi
68+ # Defines path as parent directory and keeps looking for :)
69+ path=$(/usr/bin/dirname $path)
70+ done
71+}