Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fivemini/0a5b514bc3473cc70f02b9400a9151e5 to your computer and use it in GitHub Desktop.
Save fivemini/0a5b514bc3473cc70f02b9400a9151e5 to your computer and use it in GitHub Desktop.
# git
set git_dirty_color red
set git_not_dirty_color green
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_diff (git diff)
if test -n "$git_diff"
echo (set_color $git_dirty_color)$branch(set_color normal)
else
echo (set_color $git_not_dirty_color)$branch(set_color normal)
end
end
# prompt
function fish_prompt
set_color $fish_color_cwd
echo -n (prompt_pwd)
set_color normal
set -l git_dir (git rev-parse --git-dir 2> /dev/null)
if test -n "$git_dir"
echo -n [(parse_git_branch)]
end
echo -n ' > '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment