In Bash
I have my PS1
as
PS1="\u@\h:\w\$(git branch 2>/dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1}/') \$ "
Which will show my current git branch
if I am in a git repo.
How do I set the PS1
in fish
so it will show me my current git branch?
@glenn already got the answer, but I've found a simpler way of showing the git prompt on fish.
From the terminal, in fish, type fish_config
. This will open a browser window. Select the second tab prompt
and under there select Classic + Git`.
This will show the commands required to show Git on the terminal prompt. Copy them to your ~/.config/fish/config.fish
or even simpler: click on "Use prompt".
How awesome is that?