Skip to content

Instantly share code, notes, and snippets.

@kapoormanish
Last active December 14, 2022 09:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapoormanish/72c4e78e69b84aeb7a0619a84ba35202 to your computer and use it in GitHub Desktop.
Save kapoormanish/72c4e78e69b84aeb7a0619a84ba35202 to your computer and use it in GitHub Desktop.
Showing current git branch in fish shell prompt.
# Unlike bash shell, to display your prompt, fish executes a function with the name fish_prompt,
# and its output is used as the prompt. So in order to add custom text to the prompt,
# we need to override this method (fish_prompt) in fish config file (for me, it is .config/fish/config.fish)
# Here is the simple implementation of fish_promt that shows current git branch name in the prompt.
function fish_prompt
set_color purple
date
set_color FF0
echo (pwd)
set_color green
echo (git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')
set_color normal
end
@hitchcliff
Copy link

Thanks man 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment