summaryrefslogtreecommitdiff
path: root/fish/functions/vcs_string.fish
diff options
context:
space:
mode:
Diffstat (limited to 'fish/functions/vcs_string.fish')
-rw-r--r--fish/functions/vcs_string.fish51
1 files changed, 51 insertions, 0 deletions
diff --git a/fish/functions/vcs_string.fish b/fish/functions/vcs_string.fish
new file mode 100644
index 0000000..56ae1f9
--- /dev/null
+++ b/fish/functions/vcs_string.fish
@@ -0,0 +1,51 @@
+function vcs_string
+ set -l green (set_color -o 00A000)
+ set -l yellow (set_color -o FF9900)
+ set -l red (set_color -o red)
+ set -l blue (set_color -o blue)
+ set -l brown (set_color brown)
+ set -l normal (set_color normal)
+
+ set -l nstr " $red●"
+ set -l mstr " $yellow●"
+ set -l rstr " $green●"
+ set vcs_str ""
+
+ if begin test -d ".git"; or test -d "../.git"; or test -d "../../.git"; end;
+ set -l outp (git status)
+ set vcs_str "×"
+ set vcs_inf (echo $outp | head -n 1 | cut -d' ' -f 3)
+
+ if echo $outp | grep -q "Untracked files:";
+ set vcs_new $nstr;
+ end
+ if echo $outp | grep -q 'Changes not staged for commit:';
+ set vcs_mod $mstr;
+ end
+ if echo $outp | grep -q 'Changes to be committed:';
+ set vcs_rec $rstr
+ end
+ else if begin test -d "_darcs"; or test -d "../_darcs"; or test -d "../../_darcs"; end;
+ set fls (darcs show files)
+ set vcs_str "+"
+ set vcs_inf (darcs show repo | grep Default | cut -d : -f 3-)
+ # TODO: Find a way to use darcs to set vcs_new
+ # This is very inefficient, have to basically check all files in
+ # the current directory to see if they match the listing.
+ # for f in ./*;
+ # if not echo $fls | grep -q $f;
+ # set vcs_new $nstr
+ # break
+ # end
+ # end
+ if not darcs what | grep -q "No changes";
+ set vcs_rec $rstr
+ end
+ end
+
+ if not [ "$vcs_str" = "" ];
+ echo -ne "$normal$vcs_str$normal{$blue$vcs_inf$vcs_rec$vcs_mod$vcs_new$normal}"
+ end
+ return 0
+end
+