Skip to content

Instantly share code, notes, and snippets.

@homuler
Created December 26, 2019 02:39
Show Gist options
  • Save homuler/e5a85af71e056963a27953570066b81c to your computer and use it in GitHub Desktop.
Save homuler/e5a85af71e056963a27953570066b81c to your computer and use it in GitHub Desktop.
Fish prompt with Git current branch name
function fish_prompt --description 'Write out the prompt'
set -l color_cwd
set -l suffix
switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '>'
end
set -l color_branch cyan
set -l branch_name (git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color $color_branch) "$branch_name" (set_color normal) "$suffix "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment