Commit c17ff864 authored by Jorge Bucaran's avatar Jorge Bucaran

Merge pull request #452 from scorphus/improve-scorphish

Improve scorphish theme
parents 31b0f12f e5ef2da8
# name: scorphish # name: scorphish
function _prompt_rubies -d 'Display current Ruby (rvm/rbenv)' function _prompt_rubies -a sep_color -a ruby_color -d 'Display current Ruby (rvm/rbenv)'
[ "$theme_display_ruby" = 'no' ]; and return [ "$theme_display_ruby" = 'no' ]; and return
set -l ruby_version set -l ruby_version
if type rvm-prompt >/dev/null 2>&1 if type rvm-prompt >/dev/null 2>&1
...@@ -8,16 +8,16 @@ function _prompt_rubies -d 'Display current Ruby (rvm/rbenv)' ...@@ -8,16 +8,16 @@ function _prompt_rubies -d 'Display current Ruby (rvm/rbenv)'
else if type rbenv >/dev/null 2>&1 else if type rbenv >/dev/null 2>&1
set ruby_version (rbenv version-name) set ruby_version (rbenv version-name)
# Don't show global ruby version... # Don't show global ruby version...
[ "$ruby_version" = (rbenv global) ]; and echo -n -s '--'; and return [ "$ruby_version" = (rbenv global) ]; and return
end end
[ -z "$ruby_version" ]; and return [ -z "$ruby_version" ]; and return
echo -n -s $ruby_version echo -n -s $sep_color '|' $ruby_color $ruby_version
end end
function _prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)" function _prompt_virtualfish -a sep_color -a venv_color -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"
[ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]; and echo -n -s '--'; and return [ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]; and return
echo -n -s (basename "$VIRTUAL_ENV") echo -n -s $sep_color '|' $venv_color (basename "$VIRTUAL_ENV")
end end
function _git_branch_name function _git_branch_name
...@@ -28,53 +28,34 @@ function _is_git_dirty ...@@ -28,53 +28,34 @@ function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty ^/dev/null) echo (command git status -s --ignore-submodules=dirty ^/dev/null)
end end
function _git_ahead_count -a branch_name function _git_ahead_count -a remote -a branch_name
echo (command git log origin/$branch_name..HEAD ^/dev/null | \ echo (command git log $remote/$branch_name..HEAD ^/dev/null | \
grep '^commit' | wc -l | tr -d ' ') grep '^commit' | wc -l | tr -d ' ')
end end
function _git_dirty_remotes -a ahead_color function _git_dirty_remotes -a remote_color -a ahead_color
set current_branch (git rev-parse --abbrev-ref HEAD) set current_branch (git rev-parse --abbrev-ref HEAD)
set current_ref (git rev-parse HEAD) set current_ref (git rev-parse HEAD)
set -l git_ahead_count (_git_ahead_count $current_branch) for remote in (git remote)
if [ $git_ahead_count != 0 ] set -l git_ahead_count (_git_ahead_count $remote $current_branch)
set ahead_count "$ahead_color+$git_ahead_count$normal"
end
for remote in (git remote) set remote_branch "refs/remotes/$remote/$current_branch"
# if test $remote != 'origin' set remote_ref (git for-each-ref --format='%(objectname)' $remote_branch)
set remote_ref_branch "refs/remotes/$remote/$current_branch"
set remote_ref (git for-each-ref --format='%(objectname)' $remote_ref_branch)
if test "$remote_ref" != '' if test "$remote_ref" != ''
if test "$remote_ref" != $current_ref if test "$remote_ref" != $current_ref
echo ! echo -n "$remote_color!"
echo "$ahead_count" if [ $git_ahead_count != 0 ]
echo -n "$ahead_color+$git_ahead_count$normal"
end
end end
end end
# end
end end
end end
function fish_prompt function fish_prompt
set_color -o 666 set -l exit_code $status
printf '['
set_color -o blue
printf '%s' (prompt_pwd)
set_color -o 666
printf '|'
set_color -o red
_prompt_rubies
set_color -o 666
printf '|'
set_color -o green
_prompt_virtualfish
set_color -o 666
echo ']'
set -l gray (set_color 666) set -l gray (set_color 666)
set -l cyan (set_color cyan) set -l cyan (set_color cyan)
...@@ -82,15 +63,31 @@ function fish_prompt ...@@ -82,15 +63,31 @@ function fish_prompt
set -l normal (set_color normal) set -l normal (set_color normal)
set -l yellow (set_color ffcc00) set -l yellow (set_color ffcc00)
set -l orange (set_color ffb300) set -l orange (set_color ffb300)
set -l green (set_color 80ff00) set -l green (set_color green)
set -l pink (set_color ff99ff) set -l pink (set_color ff99ff)
set -l dark_pink (set_color cc99ff) set -l dark_pink (set_color cc99ff)
set_color -o 666
printf '['
set_color -o blue
printf '%s' (prompt_pwd)
_prompt_rubies $gray $red
_prompt_virtualfish $gray $green
set_color -o 666
if set -q SCORPHISH_GIT_INFO_ON_FIRST_LINE
printf ']'
else
printf ']\n'
end
# Show git branch and dirty state # Show git branch and dirty state
if [ (_git_branch_name) ] if [ (_git_branch_name) ]
set -l git_branch (_git_branch_name) set -l git_branch (_git_branch_name)
set dirty_remotes (_git_dirty_remotes $orange) set dirty_remotes (_git_dirty_remotes $red $orange)
if [ (_is_git_dirty) ] if [ (_is_git_dirty) ]
echo -n -s $gray '‹' $yellow $git_branch $red '*' $dirty_remotes $gray '›' $normal echo -n -s $gray '‹' $yellow $git_branch $red '*' $dirty_remotes $gray '›' $normal
...@@ -99,14 +96,24 @@ function fish_prompt ...@@ -99,14 +96,24 @@ function fish_prompt
end end
end end
set_color 060 if test $exit_code -ne 0
printf ' »' set arrow_colors 600 900 c00 f00
set_color 090 else
printf '»' set arrow_colors 060 090 0c0 0f0
set_color 0c0 end
if set -q SCORPHISH_GIT_INFO_ON_FIRST_LINE
printf '\n'
else
printf ' '
end
for arrow_color in $arrow_colors
set_color $arrow_color
printf '»' printf '»'
set_color 0f0 end
printf '» '
printf ' '
set_color normal set_color normal
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment