Created
April 19, 2023 17:40
-
-
Save jordanthomas/69ed92320a33579ba5ce13b66b420b9d to your computer and use it in GitHub Desktop.
A prompt w/ git status for fish 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
function fish_prompt --description 'Write out the prompt' | |
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/') | |
set -l dirty_count 0 | |
printf '\n%s' (set_color --bold)(prompt_pwd)(set_color normal) | |
if [ $branch ] | |
printf ' on %s' (set_color --bold)$branch(set_color normal) | |
set -l dirty_count (git status --porcelain | wc -l | sed "s/ //g") | |
if test $dirty_count -gt 0 | |
printf ' %s' (set_color red)●(set_color normal) | |
else | |
printf ' %s' (set_color blue)●(set_color normal) | |
end | |
end | |
printf "\n> " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment