187f95ce4c85

Git fish prompt.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 08 Jun 2012 13:34:19 -0400
parents 2b3419a7c1a9
children 1a4e4c34085d
branches/tags (none)
files bin/git_prompt_status fish/config.fish

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/git_prompt_status	Fri Jun 08 13:34:19 2012 -0400
@@ -0,0 +1,21 @@
+#!/usr/bin/env zsh
+
+INDEX=$(git status --porcelain 2> /dev/null)
+STATUS=""
+
+
+if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
+    STATUS="C$STATUS"
+fi
+
+if $(echo "$INDEX" | grep '^.[MD] ' &> /dev/null); then
+    STATUS="?$STATUS"
+elif $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
+    STATUS="?$STATUS"
+fi
+
+if $(echo "$INDEX" | grep '^[AMDR]. ' &> /dev/null); then
+    STATUS="!$STATUS"
+fi
+
+echo -n $STATUS
--- a/fish/config.fish	Thu Jun 07 16:28:55 2012 -0400
+++ b/fish/config.fish	Fri Jun 08 13:34:19 2012 -0400
@@ -70,55 +70,6 @@
     # hg prompt --angle-brackets $hg_promptstring 2>/dev/null
 end
 
-function git_prompt_status
-  set INDEX (git status --porcelain ^ /dev/null)
-  set STATUS ""
-
-  if echo "$INDEX" | grep '^?? ' > /dev/null ^&1
-  echo "$INDEX"
-    echo trolololol
-    set STATUS "lololol$STATUS"
-  end
-
-  if echo "$INDEX" | grep '^A  ' > /dev/null ^&1
-    set STATUS "+$STATUS"
-  else
-    if echo "$INDEX" | grep '^M  ' > /dev/null ^&1
-        set STATUS "+$STATUS"
-    end
-  end
-
-  if echo "$INDEX" | grep '^ M ' > /dev/null ^&1
-    set STATUS "!$STATUS"
-  else
-    if echo "$INDEX" | grep '^AM ' > /dev/null ^&1
-        set STATUS "!$STATUS"
-    else
-        if echo "$INDEX" | grep '^ T ' > /dev/null ^&1
-            set STATUS "!$STATUS"
-        end
-    end
-  end
-
-  if echo "$INDEX" | grep '^R  ' > /dev/null ^&1
-    set STATUS ">$STATUS"
-  end
-
-  if echo "$INDEX" | grep '^ D ' > /dev/null ^&1
-    set STATUS "-$STATUS"
-  else
-    if echo "$INDEX" | grep '^AD ' > /dev/null ^&1
-        set STATUS "-$STATUS"
-    end
-  end
-
-  if echo "$INDEX" | grep '^UU ' > /dev/null ^&1
-    set STATUS "C$STATUS"
-  end
-
-  echo -n $STATUS
-end
-
 function git_prompt
     if git root >/dev/null 2>&1
         set_color normal
@@ -126,12 +77,14 @@
         set_color magenta
         printf '%s' (git currentbranch ^/dev/null)
         set_color green
-        # git_prompt_status
+        git_prompt_status
         set_color normal
     end
 end
 
 function fish_prompt
+    set last_status $status
+
     z --add "$PWD"
 
     echo
@@ -155,8 +108,13 @@
 
     echo
 
-    set_color white -o
-    printf '><> '
+    if test $last_status -eq 0
+        set_color white -o
+        printf '><((°> '
+    else
+        set_color red -o
+        printf '[%d] ><((ˣ> ' $last_status
+    end
 
     set_color normal
 end
@@ -191,6 +149,6 @@
 
 #normal }}}
 
-# if status --is-interactive
-#     command fortune -s | cowsay -n | lolcat
-# end
+if status --is-interactive
+    command fortune -s | cowsay -n | lolcat
+end