Diff
1diff --git a/plugins/fossil/README.md b/plugins/fossil/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..5bb47b7d5d777cb2bb21efe6e849339dd854f80b
4--- /dev/null
5+++ b/plugins/fossil/README.md
6@@ -0,0 +1,7 @@
7+## Fossil Plugin
8+
9+This plugin adds completion support and prompt for fossil repositories.
10+The prompt will display the current branch and status been dirty or clean.
11+
12+### CONTRIBUTOR
13+ - Jefferson González ([jgmdev](https://github.com/jgmdev))
14diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh
15new file mode 100644
16index 0000000000000000000000000000000000000000..1ae166e628175065327a9482386fa5bc16ce24fc
17--- /dev/null
18+++ b/plugins/fossil/fossil.plugin.zsh
19@@ -0,0 +1,89 @@
20+_FOSSIL_PROMPT=""
21+
22+# Prefix at the very beginning of the prompt, before the branch name
23+ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
24+
25+# At the very end of the prompt
26+ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
27+
28+# Text to display if the branch is dirty
29+ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
30+
31+# Text to display if the branch is clean
32+ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
33+
34+function fossil_prompt_info () {
35+ local _OUTPUT=`fossil branch 2>&1`
36+ local _STATUS=`echo $_OUTPUT | grep "use --repo"`
37+ if [ "$_STATUS" = "" ]; then
38+ local _EDITED=`fossil changes`
39+ local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
40+ local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'`
41+
42+ if [ "$_EDITED" != "" ]; then
43+ _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
44+ fi
45+
46+ echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
47+ "$_BRANCH" \
48+ "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
49+ "$_EDITED_SYM"\
50+ "%{$reset_color%}"
51+ fi
52+}
53+
54+function _fossil_get_command_list () {
55+ fossil help -a | grep -v "Usage|Common|This is"
56+}
57+
58+function _fossil () {
59+ local context state state_descr line
60+ typeset -A opt_args
61+
62+ _arguments \
63+ '1: :->command'\
64+ '2: :->subcommand'
65+
66+ case $state in
67+ command)
68+ local _OUTPUT=`fossil branch 2>&1 | grep "use --repo"`
69+ if [ "$_OUTPUT" = "" ]; then
70+ compadd `_fossil_get_command_list`
71+ else
72+ compadd clone init import help version
73+ fi
74+ ;;
75+ subcommand)
76+ if [ "$words[2]" = "help" ]; then
77+ compadd `_fossil_get_command_list`
78+ else
79+ compcall -D
80+ fi
81+ ;;
82+ esac
83+}
84+
85+function _fossil_prompt () {
86+ local current=`echo $PROMPT $RPROMPT | grep fossil`
87+
88+ if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
89+ local _prompt=${PROMPT}
90+ local _rprompt=${RPROMPT}
91+
92+ local is_prompt=`echo $PROMPT | grep git`
93+
94+ if [ "$is_prompt" = "" ]; then
95+ export RPROMPT="$_rprompt"'$(fossil_prompt_info)'
96+ else
97+ export PROMPT="$_prompt"'$(fossil_prompt_info) '
98+ fi
99+
100+ _FOSSIL_PROMPT="1"
101+ fi
102+}
103+
104+compdef _fossil fossil
105+
106+autoload -U add-zsh-hook
107+
108+add-zsh-hook precmd _fossil_prompt