Created
January 14, 2013 20:53
-
-
Save kennbrodhagen/4533329 to your computer and use it in GitHub Desktop.
My config.fish with a peepcode-inspired prompt
This file contains hidden or 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
set PATH ~/bin ~/.rvm/bin $PATH | |
set -U fish_color_user magenta | |
set -U fish_color_host yellow | |
set -U fish_color_git_clean green | |
set -U fish_color_git_dirty red | |
set -U fish_color_git_ahead red | |
set -U fish_color_git_staged yellow | |
set -U fish_color_git_added green | |
set -U fish_color_git_modified blue | |
set -U fish_color_git_renamed magenta | |
set -U fish_color_git_deleted red | |
set -U fish_color_git_unmerged yellow | |
set -U fish_color_git_untracked cyan | |
set -U fish_prompt_git_status_added '✚' | |
set -U fish_prompt_git_status_modified '*' | |
set -U fish_prompt_git_status_renamed '➜' | |
set -U fish_prompt_git_status_deleted '✖' | |
set -U fish_prompt_git_status_unmerged '═' | |
set -U fish_prompt_git_status_untracked '.' | |
function fish_prompt_git --description 'Write out the git prompt' | |
set -l branch (git symbolic-ref --quiet --short HEAD 2>/dev/null) | |
if test -z $branch | |
return | |
end | |
printf '|' | |
set -l index (git status --porcelain 2>/dev/null) | |
if test -z "$index" | |
set_color $fish_color_git_clean | |
printf $branch'✓' | |
set_color normal | |
return | |
end | |
git diff-index --quiet --cached HEAD 2>/dev/null | |
set -l staged $status | |
if test $staged = 1 | |
set_color $fish_color_git_staged | |
else | |
set_color $fish_color_git_dirty | |
end | |
printf $branch'⚡' | |
set -l info | |
for i in $index | |
switch $i | |
case 'A *' | |
set i added | |
case 'M *' ' M *' | |
set i modified | |
case 'R *' | |
set i renamed | |
case 'D *' ' D *' | |
set i deleted | |
case 'U *' | |
set i unmerged | |
case '?? *' | |
set i untracked | |
end | |
if not contains $i $info | |
set info $info $i | |
end | |
end | |
for i in added modified renamed deleted unmerged untracked | |
if contains $i $info | |
eval 'set_color $fish_color_git_'$i | |
eval 'printf $fish_prompt_git_status_'$i | |
end | |
end | |
set_color normal | |
end | |
set -U fish_prompt_smiley_success '☺ ' | |
set -U fish_prompt_color_success green | |
set -U fish_prompt_smiley_error '☹ ' | |
set -U fish_prompt_color_error red | |
function fish_prompt --description 'Write out the prompt' | |
set -l last_status $status | |
# User | |
set_color $fish_color_user | |
printf (whoami) | |
set_color normal | |
printf '@' | |
# Host | |
set_color $fish_color_host | |
printf (hostname -s) | |
set_color normal | |
printf ':' | |
# PWD | |
set_color $fish_color_cwd | |
printf (prompt_pwd) | |
set_color normal | |
fish_prompt_git | |
# I prefer to have a new-line here but messes with the prompt when resizing | |
echo | |
if not test $last_status -eq 0 | |
set_color $fish_prompt_color_error | |
printf $fish_prompt_smiley_error | |
else | |
set_color $fish_prompt_color_success | |
printf $fish_prompt_smiley_success | |
end | |
printf '➤ ' | |
set_color normal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment