Created
April 1, 2014 16:10
-
-
Save steve-ross/9917341 to your computer and use it in GitHub Desktop.
Fish git prompt
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
function _git_branch_name | |
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') | |
end | |
function _is_git_dirty | |
echo (git status -s --ignore-submodules=dirty ^/dev/null) | |
end | |
function _unpushed | |
echo (git cherry -v "@{upstream}" ^/dev/null) | |
end | |
function rvm_prompt | |
set -l yellow (set_color -o yellow) | |
# if [ (which rvm) ] | |
if type -t rvm >/dev/null | |
set -l identifier (rvm tools identifier) | |
echo "$yellow$identifier " | |
else | |
echo "" | |
end | |
end | |
function git_fish_prompt | |
set -l cyan (set_color cyan) | |
set -l yellow (set_color yellow) | |
set -l red (set_color -o red) | |
set -l blue (set_color blue) | |
set -l magenta (set_color -o magenta) | |
set -l normal (set_color normal) | |
set -l arrow "$red➜" | |
set -l cwd $cyan(pwd) | |
# if [ (_git_branch_name) ] | |
if test -n (_git_branch_name) | |
set -l git_branch $red(_git_branch_name) | |
set git_info "$blue git:($git_branch$blue)" | |
set -l with_unpushed (_git_branch_name) | |
if [ (_is_git_dirty) ] | |
set arrow "$red✗" | |
end | |
# if [ (_unpushed) ] | |
if test -n (_unpushed) | |
set git_info "$git_info$normal with$magenta unpushed" | |
end | |
end | |
echo -e \n | |
# for rvm prompting (if wanted) | |
# echo -n -s (rvm_prompt) $cwd $git_info | |
echo -n -s (hostname): $cwd $git_info | |
echo -e \n$arrow $normal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment