Created
March 20, 2013 16:44
-
-
Save chrisallick/5206206 to your computer and use it in GitHub Desktop.
fishfish show git branch in shell
This file contains 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
set fish_git_dirty_color red | |
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 branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
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%s (%s) $ ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch) | |
else | |
printf '%s@%s %s%s%s $ ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment