3 changed files with 141 additions and 1 deletions
@ -0,0 +1,91 @@ |
|||||
|
set -g fish_color_git_normal blue |
||||
|
|
||||
|
set -g fish_color_git_ahead green |
||||
|
set -g fish_color_git_behind red |
||||
|
set -g fish_color_git_diverged magenta |
||||
|
set -g fish_color_git_staged green |
||||
|
set -g fish_color_git_unstaged yellow |
||||
|
set -g fish_color_git_untracked red |
||||
|
set -g fish_color_git_unmerged red |
||||
|
|
||||
|
set -g fish_prompt_git_status_ahead '▲' |
||||
|
set -g fish_prompt_git_status_behind '▼' |
||||
|
set -g fish_prompt_git_status_diverged '⯁' |
||||
|
set -g fish_prompt_git_status_staged '●' |
||||
|
set -g fish_prompt_git_status_unstaged '●' |
||||
|
set -g fish_prompt_git_status_untracked '●' |
||||
|
set -g fish_prompt_git_status_unmerged 'M' |
||||
|
set -g fish_prompt_git_status_stashed 'S' |
||||
|
|
||||
|
set -g fish_prompt_git_status_order ahead behind diverged staged unstaged untracked unmerged stashed |
||||
|
|
||||
|
# Useful chars |
||||
|
# '✓' |
||||
|
# '⚡' |
||||
|
# '✚' |
||||
|
# '●' |
||||
|
# '▾' |
||||
|
# '✖' |
||||
|
# '➜' |
||||
|
# '⇒' |
||||
|
# '➤' |
||||
|
|
||||
|
function __plaid_git_prompt --description 'Write out the git prompt' |
||||
|
# If git isn't installed, there's nothing we can do |
||||
|
# Return 1 so the calling prompt can deal with it |
||||
|
if not command -sq git |
||||
|
return 1 |
||||
|
end |
||||
|
set -l branch (git rev-parse --abbrev-ref HEAD 2>/dev/null) |
||||
|
if test -z $branch |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
set -l index (git status --porcelain -b 2>/dev/null) |
||||
|
set -l rst (set_color normal) |
||||
|
|
||||
|
if test -z "$index" |
||||
|
printf '%s[%s]%s' (set_color $fish_color_git_normal) $branch $rst |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
set -l gs |
||||
|
|
||||
|
printf '%s[%s ' (set_color $fish_color_git_normal) $branch |
||||
|
for i in $index |
||||
|
if echo $i | grep '^[AMRCD]' >/dev/null |
||||
|
set -a gs staged |
||||
|
end |
||||
|
if echo $i | grep '^ [AMRCD]' >/dev/null |
||||
|
set -a gs unstaged |
||||
|
end |
||||
|
if echo $i | grep '^??' >/dev/null |
||||
|
set -a gs untracked |
||||
|
end |
||||
|
if echo $i | grep '^[ADU*][ADU*]' >/dev/null |
||||
|
set -a gs unmerged |
||||
|
end |
||||
|
if echo $i | grep '^## .*ahead' >/dev/null |
||||
|
set -a gs ahead |
||||
|
end |
||||
|
if echo $i | grep '^## .*behind' >/dev/null |
||||
|
set -a gs behind |
||||
|
end |
||||
|
if echo $i | grep '^## .*diverged' >/dev/null |
||||
|
set -a gs diverged |
||||
|
end |
||||
|
if git rev-parse --verify refs/stash >/dev/null 2>&1 |
||||
|
set -a gs stashed |
||||
|
end |
||||
|
end |
||||
|
|
||||
|
for i in $fish_prompt_git_status_order |
||||
|
if contains $i in $gs |
||||
|
set -l color_name fish_color_git_$i |
||||
|
set -l status_name fish_prompt_git_status_$i |
||||
|
printf '%s%s' (set_color $$color_name) $$status_name |
||||
|
end |
||||
|
end |
||||
|
|
||||
|
printf '%s]%s' (set_color $fish_color_git_normal) $rst |
||||
|
end |
||||
@ -0,0 +1,47 @@ |
|||||
|
set -g fish_color_user cyan |
||||
|
set -g fish_color_host green |
||||
|
set -g fish_color_cwd yellow |
||||
|
set -g fish_prompt_pwd_dir_length 0 |
||||
|
|
||||
|
function fish_prompt --description 'Write out the prompt' |
||||
|
set -l last_status $status |
||||
|
set -l rst (set_color normal) |
||||
|
|
||||
|
# User |
||||
|
set -l user (set_color --bold $fish_color_user)(whoami)$rst |
||||
|
|
||||
|
# Host |
||||
|
set -l host (set_color --bold $fish_color_host)(prompt_hostname)$rst |
||||
|
|
||||
|
# PWD |
||||
|
set -l ppwd (set_color $fish_color_cwd)(prompt_pwd)$rst |
||||
|
|
||||
|
# Git |
||||
|
set -l pgit (__plaid_git_prompt) |
||||
|
# __fish_hg_prompt |
||||
|
|
||||
|
printf '%s@%s:%s %s\n' $user $host $ppwd $pgit |
||||
|
|
||||
|
switch $fish_bind_mode |
||||
|
case default |
||||
|
set_color --bold --background red black |
||||
|
echo -n '⮜N⮞' |
||||
|
case insert |
||||
|
set_color --bold green |
||||
|
echo -n '⮜I⮞' |
||||
|
case replace_one |
||||
|
set_color --bold --background yellow black |
||||
|
echo -n '⮜R⮞' |
||||
|
case visual |
||||
|
set_color --bold --background magenta black |
||||
|
echo -n '⮜V⮞' |
||||
|
end |
||||
|
set_color normal |
||||
|
|
||||
|
if not test $last_status -eq 0 |
||||
|
set_color $fish_color_error |
||||
|
end |
||||
|
|
||||
|
printf ' ' |
||||
|
set_color normal |
||||
|
end |
||||
Loading…
Reference in new issue