Skip to content

Instantly share code, notes, and snippets.

@jksk
Forked from Pallinder/fish.config
Created June 9, 2012 19:04
Show Gist options
  • Save jksk/2902198 to your computer and use it in GitHub Desktop.
Save jksk/2902198 to your computer and use it in GitHub Desktop.
Add current git branch to fish
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 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%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