mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
git symbols prompt improved
This commit is contained in:
parent
b14e710151
commit
d7003d4ba1
@ -1,4 +1,5 @@
|
||||
# TODO: color definitions
|
||||
# TODO: color definitions cleanup
|
||||
# TODO: git improvements
|
||||
# name: budspencer
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@ -1,5 +1,43 @@
|
||||
# TODO: color definitions
|
||||
# TODO: color definitions cleanup
|
||||
# TODO: elapsed time segment
|
||||
# TODO: username/host segment for ssh connections
|
||||
|
||||
# Init colors
|
||||
|
||||
set fcol_black (set_color 000000)
|
||||
set fcol_base03 (set_color -o 002b36)
|
||||
set fcol_base02 (set_color -o 073642)
|
||||
set fcol_base01 (set_color -o 586e75)
|
||||
set fcol_base00 (set_color -o 657b83)
|
||||
set fcol_base0 (set_color -o 839496)
|
||||
set fcol_base1 (set_color -o 93a1a1)
|
||||
set fcol_base2 (set_color -o eee8d5)
|
||||
set fcol_base3 (set_color -o fdf6e3)
|
||||
set fcol_yellow (set_color -o b58900)
|
||||
set fcol_orange (set_color -o cb4b16)
|
||||
set fcol_red (set_color -o red)
|
||||
set fcol_magenta (set_color -o d33682)
|
||||
set fcol_violet (set_color -o 6c71c4)
|
||||
set fcol_blue (set_color -o 268bd2)
|
||||
set fcol_blue (set_color -o 268bd2)
|
||||
set fcol_cyan (set_color -o 2aa198)
|
||||
set fcol_green (set_color -o 859900)
|
||||
set bcol_base03 (set_color -b 002b36)
|
||||
set bcol_base02 (set_color -b 073642)
|
||||
set bcol_base01 (set_color -b 586e75)
|
||||
set bcol_base00 (set_color -b 657b83)
|
||||
set bcol_base0 (set_color -b 839496)
|
||||
set bcol_base1 (set_color -b 93a1a1)
|
||||
set bcol_base2 (set_color -b eee8d5)
|
||||
set bcol_base3 (set_color -b fdf6e3)
|
||||
set bcol_yellow (set_color -b b58900)
|
||||
set bcol_orange (set_color -b cb4b16)
|
||||
set bcol_red (set_color -b dc322f)
|
||||
set bcol_magenta (set_color -b d33682)
|
||||
set bcol_violet (set_color -b 6c71c4)
|
||||
set bcol_blue (set_color -b 268bd2)
|
||||
set bcol_cyan (set_color -b 2aa198)
|
||||
set bcol_green (set_color -b 859900)
|
||||
|
||||
function __budspencer_is_git_ahead_or_behind -d "Check if there are unpulled or unpushed commits"
|
||||
echo (command git rev-list --count --left-right "HEAD...@{upstream}" ^/dev/null | sed 's/[[:space:]+]/\\x1e/g')
|
||||
@ -43,6 +81,17 @@ function fish_pwd_toggle_cm --description "Toggles style of pwd segment, press s
|
||||
end
|
||||
bind -M default ' ' fish_pwd_toggle_cm
|
||||
|
||||
set git_style "symbols"
|
||||
function fish_git_toggle_cm --description "Toggles style of git segment, press G in NORMAL mode"
|
||||
if test $git_style = "symbols"
|
||||
set git_style "counts"
|
||||
else
|
||||
set git_style "symbols"
|
||||
end
|
||||
commandline -f repaint
|
||||
end
|
||||
bind -M default ',,' fish_git_toggle_cm
|
||||
|
||||
function fish_pwd_prompt_cm --description "Displays the present working directory"
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
@ -72,90 +121,96 @@ function fish_pwd_prompt_cm --description "Displays the present working director
|
||||
set_color normal
|
||||
end
|
||||
|
||||
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
|
||||
# Init colors
|
||||
function fish_git_prompt_cm --description "Displays the git symbols"
|
||||
set -l git_prompt ""
|
||||
set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
|
||||
if test $is_repo="true"
|
||||
|
||||
set -l fcol_black (set_color 000000)
|
||||
set -l fcol_base03 (set_color -o 002b36)
|
||||
set -l fcol_base02 (set_color -o 073642)
|
||||
set -l fcol_base01 (set_color -o 586e75)
|
||||
set -l fcol_base00 (set_color -o 657b83)
|
||||
set -l fcol_base0 (set_color -o 839496)
|
||||
set -l fcol_base1 (set_color -o 93a1a1)
|
||||
set -l fcol_base2 (set_color -o eee8d5)
|
||||
set -l fcol_base3 (set_color -o fdf6e3)
|
||||
set -l fcol_yellow (set_color -o b58900)
|
||||
set -l fcol_orange (set_color -o cb4b16)
|
||||
set -l fcol_red (set_color -o red)
|
||||
set -l fcol_magenta (set_color -o d33682)
|
||||
set -l fcol_violet (set_color -o 6c71c4)
|
||||
set -l fcol_blue (set_color -o 268bd2)
|
||||
set -l fcol_blue (set_color -o 268bd2)
|
||||
set -l fcol_cyan (set_color -o 2aa198)
|
||||
set -l fcol_green (set_color -o 859900)
|
||||
set -l bcol_base03 (set_color -b 002b36)
|
||||
set -l bcol_base02 (set_color -b 073642)
|
||||
set -l bcol_base01 (set_color -b 586e75)
|
||||
set -l bcol_base00 (set_color -b 657b83)
|
||||
set -l bcol_base0 (set_color -b 839496)
|
||||
set -l bcol_base1 (set_color -b 93a1a1)
|
||||
set -l bcol_base2 (set_color -b eee8d5)
|
||||
set -l bcol_base3 (set_color -b fdf6e3)
|
||||
set -l bcol_yellow (set_color -b b58900)
|
||||
set -l bcol_orange (set_color -b cb4b16)
|
||||
set -l bcol_red (set_color -b dc322f)
|
||||
set -l bcol_magenta (set_color -b d33682)
|
||||
set -l bcol_violet (set_color -b 6c71c4)
|
||||
set -l bcol_blue (set_color -b 268bd2)
|
||||
set -l bcol_cyan (set_color -b 2aa198)
|
||||
set -l bcol_green (set_color -b 859900)
|
||||
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
|
||||
if test $git_ahead_behind[1] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $fcol_yellow" ↑"
|
||||
else
|
||||
set git_prompt $fcol_yellow" "$git_ahead_behind[1]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_ahead_behind[2] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_yellow" ↓"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_yellow" "$git_ahead_behind[2]
|
||||
end
|
||||
end
|
||||
|
||||
set -l git_status (__budspencer_git_status)
|
||||
if test $git_status[1] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_green" +"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_green" "$git_status[1]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_status[2] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_red" –"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_red" "$git_status[2]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_status[3] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_blue" ✱"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_blue" "$git_status[3]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_status[4] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_magenta" →"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_magenta" "$git_status[4]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_status[5] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_violet" ═"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_violet" "$git_status[5]
|
||||
end
|
||||
end
|
||||
|
||||
if test $git_status[6] -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_base3" ●"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_base3" "$git_status[6]
|
||||
end
|
||||
end
|
||||
|
||||
set -l git_stashed (__budspencer_is_git_stashed)
|
||||
if test git_stashed -gt 0
|
||||
if test $git_style = "symbols"
|
||||
set git_prompt $git_prompt$fcol_cyan" ✭"
|
||||
else
|
||||
set git_prompt $git_prompt$fcol_cyan" "$git_stashed
|
||||
end
|
||||
end
|
||||
echo $git_prompt
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
|
||||
|
||||
# Segments
|
||||
|
||||
# git
|
||||
set -l ps_git ""
|
||||
set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
|
||||
if test $is_repo="true"
|
||||
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
|
||||
if test $git_ahead_behind[1] -gt 0
|
||||
set ps_git $fcol_yellow" ↑"
|
||||
end
|
||||
|
||||
if test $git_ahead_behind[2] -gt 0
|
||||
set ps_git $ps_git$fcol_yellow" ↓"
|
||||
end
|
||||
|
||||
set -l git_status (__budspencer_git_status)
|
||||
echo $git_status
|
||||
if test $git_status[1] -gt 0
|
||||
set ps_git $ps_git$fcol_green" +"
|
||||
end
|
||||
|
||||
if test $git_status[2] -gt 0
|
||||
set ps_git $ps_git$fcol_red" –"
|
||||
end
|
||||
|
||||
if test $git_status[3] -gt 0
|
||||
set ps_git $ps_git$fcol_blue" ✱"
|
||||
end
|
||||
|
||||
if test $git_status[4] -gt 0
|
||||
set ps_git $ps_git$fcol_blue" →"
|
||||
end
|
||||
|
||||
if test $git_status[5] -gt 0
|
||||
set ps_git $ps_git$fcol_violet" ═"
|
||||
end
|
||||
|
||||
if test $git_status[6] -gt 0
|
||||
set ps_git $ps_git$fcol_base3" ●"
|
||||
end
|
||||
|
||||
if test (__budspencer_is_git_stashed) -gt 0
|
||||
set ps_git $ps_git$fcol_cyan" ✭"
|
||||
end
|
||||
end
|
||||
|
||||
set ps_git (fish_git_prompt_cm)
|
||||
if test -n "$ps_git"
|
||||
set ps_git $fcol_base02""$bcol_base02""$ps_git
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user