Adapted to Fisher 4.x plugin style

This commit is contained in:
2021-01-31 17:39:14 +01:00
parent 6d7d687d67
commit dbaef057a1
10 changed files with 8 additions and 7 deletions

View File

@ -0,0 +1,67 @@
function fish_prompt
set -l symbol "λ "
set -l code $status
set t31m_custom_right (t31m_prompt_right)
echo -ns "$t31m_custom_right"
if test -n "$ssh_client"
set -l host (hostname -s)
set -l who (whoami)
echo -n -s (red)"("(cyan)"$who"(red)":"(cyan)"$host"(red)") "(off)
end
if git::is_repo
set -l branch (git::branch_name ^/dev/null)
set -l ref (git show-ref --head --abbrev | awk '{print substr($0,0,7)}' | sed -n 1p)
printf '%s ' \U1F6E0
echo -n -s (red)"("(off)
if git::is_stashed
echo -n -s (white)"^"(off)
end
if git::is_dirty
printf (white)"*"(off)
end
if command git symbolic-ref HEAD > /dev/null ^/dev/null
if git::is_staged
printf (cyan)"$branch"(off)
else
printf (yellow)"$branch"(off)
end
else
printf (dim)"$ref"(off)
end
for remote in (git remote)
set -l behind_count (echo (command git rev-list $branch..$remote/$branch ^/dev/null | wc -l | tr -d " "))
set -l ahead_count (echo (command git rev-list $remote/$branch..$branch ^/dev/null | wc -l | tr -d " "))
if test $ahead_count -ne 0; or test $behind_count -ne 0; and test (git remote | wc -l) -gt 1
echo -n -s " "(orange)$remote(off)
end
if test $ahead_count -ne 0
echo -n -s (white)" +"$ahead_count(off)
end
if test $behind_count -ne 0
echo -n -s (white)" -"$behind_count(off)
end
end
echo -n -s (red)")"(off)
end
set t31m_custom (t31m_prompt)
# check if latest cmd resulted in exit code 0 (ok)
if test "$code" = 0
echo -e -n -s "$t31m_custom"(red)"\n$symbol"(off)
else
echo -e -n -s "$t31m_custom"(dim)"\n$symbol"(off)
end
end