Article
home/blog/Loading

How to show the git branch in Fish

Show the git branch on the end of the terminal prompt is a really useful modification as you can always see the branch you are on!

Add this to your config

function fish_prompt
    set -l git_branch (git branch ^/dev/null | sed -n '/\* /s///p')
    echo -n (c green -o)(whoami)'@'(hostname)(c normal)':'(c blue -o)(prompt_pwd)' '(c red)"$git_branch"(c normal)'$ '
end