38 lines
1.4 KiB
Fish
38 lines
1.4 KiB
Fish
function fish_prompt
|
|
set -l last_exit $status
|
|
set -l user (whoami)
|
|
set -l host (hostname -s)
|
|
set -l pwd_str (prompt_pwd)
|
|
echo -n (set_color brblack)"╭─"(set_color normal)
|
|
echo -n (set_color red)"["(set_color brgreen)"$user"(set_color bryellow)"@"(set_color bryellow)"$host"(set_color red)"]"(set_color normal)
|
|
echo -n (set_color brblack)" · "(set_color normal)
|
|
echo -n (set_color --bold green)"$pwd_str"(set_color normal)
|
|
|
|
set -l git_branch (command git symbolic-ref --short HEAD 2>/dev/null)
|
|
if test -n "$git_branch"
|
|
set -l git_dirty (command git status --porcelain 2>/dev/null | head -c1 | wc -c)
|
|
echo -n (set_color brblack)" · "(set_color normal)
|
|
if test "$git_dirty" -gt 0
|
|
echo -n (set_color red)"["(set_color yellow)"$git_branch"(set_color red)"*]"(set_color normal)
|
|
else
|
|
echo -n (set_color green)"["(set_color brgreen)"$git_branch"(set_color green)"]"(set_color normal)
|
|
end
|
|
end
|
|
|
|
if test $last_exit -ne 0
|
|
echo -n (set_color brblack)" · "(set_color normal)
|
|
echo -n (set_color red)"[$last_exit]"(set_color normal)
|
|
end
|
|
|
|
echo
|
|
echo -n (set_color brblack)"╰─"(set_color normal)
|
|
|
|
if test (id -u) -eq 0
|
|
echo -n (set_color red)"# "(set_color normal)
|
|
else if test $last_exit -eq 0
|
|
echo -n (set_color brred)"> "(set_color normal)
|
|
else
|
|
echo -n (set_color brred)"> "(set_color normal)
|
|
end
|
|
end
|