Created
June 7, 2012 22:26
-
-
Save Pallinder/2892073 to your computer and use it in GitHub Desktop.
Add current git branch to fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_dirty | |
git diff --quiet HEAD ^&- | |
if test $status = 1 | |
echo (set_color $fish_git_dirty_color)"Δ"(set_color normal) | |
end | |
end | |
function parse_git_branch | |
# git branch outputs lines, the current branch is prefixed with a * | |
set -l branch (git rev-parse --abbrev-ref HEAD) | |
echo $branch (parse_git_dirty) | |
end | |
function fish_prompt | |
if test -z (git branch --quiet 2>| awk '/fatal:/ {print "no git"}') | |
printf '%s%s%s (%s) $ ' (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch) | |
else | |
printf '%s%s%s $ ' (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) | |
end |
You could also try putting it in the fish_right_prompt
function whose output is right-aligned. BTW I think an end
is missing at the uhm, end?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, it just works!