Added terlar's prompt, and robbyrussell which was inadvertently omitted

https://github.com/fish-shell/fish-shell/issues/329
This commit is contained in:
ridiculousfish 2012-10-15 18:45:46 -07:00
parent 833abc27cc
commit 211b9ea8b9
4 changed files with 149 additions and 0 deletions

View File

@ -0,0 +1,76 @@
set -gx fish_color_git_clean green
set -gx fish_color_git_dirty red
set -gx fish_color_git_ahead red
set -gx fish_color_git_staged yellow
set -gx fish_color_git_added green
set -gx fish_color_git_modified blue
set -gx fish_color_git_renamed magenta
set -gx fish_color_git_deleted red
set -gx fish_color_git_unmerged yellow
set -gx fish_color_git_untracked cyan
set -gx fish_prompt_git_status_added '✚'
set -gx fish_prompt_git_status_modified '*'
set -gx fish_prompt_git_status_renamed '➜'
set -gx fish_prompt_git_status_deleted '✖'
set -gx fish_prompt_git_status_unmerged '═'
set -gx fish_prompt_git_status_untracked '.'
function __terlar_git_prompt --description 'Write out the git prompt'
set -l branch (git symbolic-ref --quiet --short HEAD 2>/dev/null)
if test -z $branch
return
end
echo -n '|'
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

View File

@ -0,0 +1,33 @@
# name: Robbyrussell
# author: Bruno Ferreira Pinto
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (git status -s --ignore-submodules=dirty ^/dev/null)
end
function fish_prompt
set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow)
set -l red (set_color -o red)
set -l blue (set_color -o blue)
set -l normal (set_color normal)
set -l arrow "$red"
set -l cwd $cyan(basename (prompt_pwd))
if [ (_git_branch_name) ]
set -l git_branch $red(_git_branch_name)
set git_info "$blue git:($git_branch$blue)"
if [ (_is_git_dirty) ]
set -l dirty "$yellow"
set git_info "$git_info$dirty"
end
end
echo -n -s $arrow $cwd $git_info $normal '>'
end

View File

@ -0,0 +1,39 @@
# name: Terlar
# author: terlar - https://github.com/terlar
set -xg fish_color_user magenta
set -xg fish_color_host yellow
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
# User
set_color $fish_color_user
printf (whoami)
set_color normal
echo -n '@'
# Host
set_color $fish_color_host
printf (hostname -s)
set_color normal
echo -n ':'
# PWD
set_color $fish_color_cwd
printf (prompt_pwd)
set_color normal
__terlar_git_prompt
# 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_color_error
end
echo -n '➤ '
set_color normal
end

View File

@ -224,6 +224,7 @@ def ansi_to_html(val):
if result[idx] == '</span>' and result[idx-1].startswith('<span'):
# Empty span, delete these two
result[idx-1:idx+1] = []
idx = idx - 1
idx = idx - 1
return ''.join(result)