fish-shell/fish-shell — pull request #978 by haarts (2013-08-26 12:58:32+00:00)
Title: New informative Git prompt implementation

DO NOT MERGE AS IS! This pull meant to discuss the implementation.

I've created this pull request as a direct result of the discussion in #880 (especially [this](https://github.com/fish-shell/fish-shell/pull/880#issuecomment-19737984) part).

In summary I (think I have) achieved 4 goals:
1. **Convention over configuration**: Lots of configuration parameters have been removed favor of sane defaults.
2. **Clarity**: The code has been split in several functions and the control flow has been simplified. Also variables have gotten sane names.
3. **Modularity**: Functions can be overwritten. Think building blocks!
4. **No magic**: I removed the color and char setting methods and replaced them with default `set_color` calls.

There are three things which need more attention;
1. On the bottom of the file are a couple of lose ends. Annotated with FIXME's.
2. The function `__fish_git_prompt_show_upstream` is complex and I could use some help there.
3. I would love for ppl to test this implementation.

I would especially like the view of @zanchey, @terlar and @mariuszs on this subject.

A quick prompt to test this:

function fish_prompt
printf '['
set_color green
printf '%s@%s:' (whoami) (hostname|cut -d . -f 1)
set_color 23f
printf '%s' (prompt_pwd)
set_color normal
set -l os
set -l git_dir (git rev-parse --git-dir ^/dev/null; set os $status)
if test $os -eq 0
printf ']%s ' (__fish_git_prompt_new)
else
printf '] '
end
end