Some checks failed
Build Dotfile Bundles / bundle (push) Has been cancelled
Signed-off-by: Nicholas Mello <nick@nmello.dev>
65 lines
1.6 KiB
Fish
65 lines
1.6 KiB
Fish
function fish_prompt
|
|
set -l last_status $status
|
|
set -l cwd (prompt_pwd)
|
|
set -l jobs_count (count (jobs -p))
|
|
|
|
# --- Base path ---
|
|
set_color cyan
|
|
echo -n $cwd
|
|
|
|
# --- Git Info ---
|
|
if command -sq git
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1
|
|
set -l branch (git symbolic-ref --short HEAD 2>/dev/null; or git rev-parse --short HEAD)
|
|
|
|
# Ahead / behind vs upstream
|
|
set -l ahead 0
|
|
set -l behind 0
|
|
set -l counts (git rev-list --left-right --count @{upstream}...HEAD 2>/dev/null)
|
|
|
|
if test -n "$counts"
|
|
set behind (echo $counts | awk '{print $1}')
|
|
set ahead (echo $counts | awk '{print $2}')
|
|
end
|
|
|
|
# Dirty working tree?
|
|
git diff --quiet --ignore-submodules HEAD >/dev/null 2>&1
|
|
or set -l dirty "*"
|
|
|
|
set_color magenta
|
|
echo -n " ["$branch
|
|
|
|
if test $ahead -gt 0
|
|
echo -n " ↑$ahead"
|
|
end
|
|
|
|
if test $behind -gt 0
|
|
echo -n " ↓$behind"
|
|
end
|
|
|
|
if test -n "$dirty"
|
|
echo -n " $dirty"
|
|
end
|
|
|
|
echo -n "]"
|
|
end
|
|
end
|
|
|
|
if test $jobs_count -gt 0
|
|
set_color yellow
|
|
echo -n " [$jobs_count jobs]"
|
|
set_color normal
|
|
end
|
|
|
|
# --- Exit status ---
|
|
if test $last_status -ne 0
|
|
set_color red
|
|
echo -n " [$last_status]"
|
|
end
|
|
|
|
# --- Final prompt character ---
|
|
set_color green
|
|
echo -n "> "
|
|
set_color normal
|
|
end
|