My fish shell lambda prompt functions (they go in ~/.config/fish/functions) it's extremely fast too! :D
# A lambda (λ) prompt. | |
# Green and red depending on exit status. | |
# Underlined if git status is dirty. | |
# Uppercase (Λ) if ahead of the remote. | |
function fish_prompt | |
if is_status_okay | |
set_color green | |
else | |
set_color red | |
end | |
if is_git_dirty | |
set_color --underline | |
end | |
if is_git_ahead | |
echo -n 'Λ' | |
else | |
echo -n 'λ' | |
end | |
set_color normal | |
echo -n ' ' | |
end |
function fish_right_prompt | |
if is_git | |
set_color yellow | |
echo -n (git_branch) | |
set_color normal | |
echo -n ' ' | |
end | |
set_color blue | |
echo -n (basename (pwd | sed "s#$HOME#\~#")) | |
set_color normal | |
end |
function git_branch | |
if is_git | |
echo (git rev-parse --abbrev-ref HEAD 2> /dev/null) | |
end | |
end |
function is_git | |
git symbolic-ref HEAD > /dev/null 2>&1 | |
end |
function is_git_ahead | |
set -l revs (git rev-list origin/(git_branch)..HEAD ^ /dev/null) | |
[ "$revs" != "" ] | |
end |
function is_git_dirty | |
is_git; and [ (git status | tail -n1) != "nothing to commit, working directory clean" ] | |
end |
function is_status_okay | |
[ $status = 0 ] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Wow, this is pretty much the perfect prompt! I love it, thank you!