Last active
August 29, 2015 14:03
-
-
Save triple-j/cc74f5f54f920002bb65 to your computer and use it in GitHub Desktop.
~/.config/fish/config.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
# http://herdrick.tumblr.com/post/24563032599/display-git-branch-and-dirty-status-in-fish-shell | |
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/') | |
set -l branch (git rev-parse --abbrev-ref HEAD) | |
printf '%s%s' $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