aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__terlar_git_prompt.fish
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-10-15 18:45:46 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-10-15 18:45:46 -0700
commit211b9ea8b9b74d94cbad3e1f06f4d9c1b17e2e0f (patch)
tree42ce292fcd8ef5c3fba4680f8fe5a3fb7dfbf43a /share/functions/__terlar_git_prompt.fish
parent833abc27cc8653d92c4d275c042f35ced0ea3f94 (diff)
Added terlar's prompt, and robbyrussell which was inadvertently omitted
Diffstat (limited to 'share/functions/__terlar_git_prompt.fish')
-rw-r--r--share/functions/__terlar_git_prompt.fish76
1 files changed, 76 insertions, 0 deletions
diff --git a/share/functions/__terlar_git_prompt.fish b/share/functions/__terlar_git_prompt.fish
new file mode 100644
index 00000000..93df408f
--- /dev/null
+++ b/share/functions/__terlar_git_prompt.fish
@@ -0,0 +1,76 @@
+set -gx fish_color_git_clean green
+set -gx fish_color_git_dirty red
+set -gx fish_color_git_ahead red
+set -gx fish_color_git_staged yellow
+
+set -gx fish_color_git_added green
+set -gx fish_color_git_modified blue
+set -gx fish_color_git_renamed magenta
+set -gx fish_color_git_deleted red
+set -gx fish_color_git_unmerged yellow
+set -gx fish_color_git_untracked cyan
+
+set -gx fish_prompt_git_status_added '✚'
+set -gx fish_prompt_git_status_modified '*'
+set -gx fish_prompt_git_status_renamed '➜'
+set -gx fish_prompt_git_status_deleted '✖'
+set -gx fish_prompt_git_status_unmerged '═'
+set -gx fish_prompt_git_status_untracked '.'
+
+function __terlar_git_prompt --description 'Write out the git prompt'
+ set -l branch (git symbolic-ref --quiet --short HEAD 2>/dev/null)
+ if test -z $branch
+ return
+ end
+
+ echo -n '|'
+
+ set -l index (git status --porcelain 2>/dev/null)
+ if test -z "$index"
+ set_color $fish_color_git_clean
+ printf $branch'✓'
+ set_color normal
+ return
+ end
+
+ git diff-index --quiet --cached HEAD 2>/dev/null
+ set -l staged $status
+ if test $staged = 1
+ set_color $fish_color_git_staged
+ else
+ set_color $fish_color_git_dirty
+ end
+
+ printf $branch'⚡'
+
+ set -l info
+ for i in $index
+ switch $i
+ case 'A *'
+ set i added
+ case 'M *' ' M *'
+ set i modified
+ case 'R *'
+ set i renamed
+ case 'D *' ' D *'
+ set i deleted
+ case 'U *'
+ set i unmerged
+ case '?? *'
+ set i untracked
+ end
+
+ if not contains $i $info
+ set info $info $i
+ end
+ end
+
+ for i in added modified renamed deleted unmerged untracked
+ if contains $i $info
+ eval 'set_color $fish_color_git_'$i
+ eval 'printf $fish_prompt_git_status_'$i
+ end
+ end
+
+ set_color normal
+end