Created
August 14, 2015 17:05
-
-
Save Olical/1491b2072f0daf84072a to your computer and use it in GitHub Desktop.
My fish shell lambda prompt functions (they go in ~/.config/fish/functions) it's extremely fast too! :D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git_branch | |
if is_git | |
echo (git rev-parse --abbrev-ref HEAD 2> /dev/null) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_git | |
git symbolic-ref HEAD > /dev/null 2>&1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_git_ahead | |
set -l revs (git rev-list origin/(git_branch)..HEAD ^ /dev/null) | |
[ "$revs" != "" ] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_git_dirty | |
is_git; and [ (git status | tail -n1) != "nothing to commit, working directory clean" ] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Wow, this is pretty much the perfect prompt! I love it, thank you!