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?
Prompt Tab The "prompt" tab displays the contents of the current fish shell prompt. It allows selection from 17 predefined prompts. To change the prompt, select one and press "Prompt Set!".
If you want to organize your configuration, fish also reads commands in . fish files in ~/. config/fish/conf.
Switching to fish? If you wish to use fish (or any other shell) as your default shell, you need to enter your new shell's executable /usr/local/bin/fish in two places: add /usr/local/bin/fish to /etc/shells. change your default shell with chsh -s to /usr/local/bin/fish.
Modern shells save previous commands in a command history. You can view earlier commands by using the up and down arrows. Fish extends this concept by integrating the history search functionality. To search the history, simply type in the search string, and press the up arrow.
@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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With