Skip to content

Instantly share code, notes, and snippets.

@jordanthomas
Created April 19, 2023 17:40
Show Gist options
  • Save jordanthomas/69ed92320a33579ba5ce13b66b420b9d to your computer and use it in GitHub Desktop.
Save jordanthomas/69ed92320a33579ba5ce13b66b420b9d to your computer and use it in GitHub Desktop.
A prompt w/ git status for fish shell
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