1
0

Show git branch in fish prompt

This commit is contained in:
Noah 2015-06-03 13:37:25 -07:00
parent cb31c5d5bc
commit b2733d1ea1

View File

@ -24,8 +24,13 @@ set -g VIRTUALFISH_HOME $HOME/.virtualenv
set -g VIRTUALFISH_COMPAT_ALIASES set -g VIRTUALFISH_COMPAT_ALIASES
. ~/.config/fish/virtual.fish . ~/.config/fish/virtual.fish
# Git repo branches
function git_branch
git branch 2>/dev/null | grep -v '^[^*]' | perl -pe 's/^\*\s+//g'
end
# Shell prompt # Shell prompt
function fish_prompt function base_prompt
# VirtualEnv prefix # VirtualEnv prefix
if set -q VIRTUAL_ENV if set -q VIRTUAL_ENV
echo -n -s (set_color FF9900) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal) echo -n -s (set_color FF9900) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal)
@ -42,10 +47,21 @@ function fish_prompt
echo -n " " echo -n " "
set_color 00FF00 set_color 00FF00
echo -n (prompt_pwd) echo -n (prompt_pwd)
# git branch
set branch (git_branch)
if test -n "$branch"
set_color 00FFFF
echo -n " ($branch)"
end
set_color 0099FF set_color 0099FF
echo -n "]\$ " echo -n "]\$ "
set_color normal set_color normal
end end
function fish_prompt
echo -n (base_prompt)
end
# Title bar # Title bar
function fish_title function fish_title
@ -56,6 +72,7 @@ function fish_title
end end
end end
# Source local system-specific config. # Source local system-specific config.
if test -e ~/.local.fish if test -e ~/.local.fish
. ~/.local.fish . ~/.local.fish