don't show git status inside `.git` dir

master
lowne 2 years ago
parent c774c260d0
commit 99ea7d3425

@ -1,7 +1,9 @@
# git helper functions
# unused
function __git_is_repo -d "Test if the current directory is a Git repository"
if not command git rev-parse --git-dir > /dev/null 2>/dev/null
# don't consider the .git dir as part of the repo
# so we use --show-toplevel (which fails inside .git) instead of --git-dir
if not command git rev-parse --show-toplevel > /dev/null 2>/dev/null
return 1
end
end
@ -140,58 +142,60 @@ function fish_prompt
segment $base_color " $pwd_info[3] "
end
if set branch_name (__git_branch_name)
if __git_is_repo
if set branch_name (__git_branch_name)
if __git_is_stashed
segment "$text_color" blue "♺" # "╍╍"
end
# set -l untracked_files (__git_untracked_files)
# if test "0" != "$untracked_files"
# segment "$text_color" blue "$untracked_files?" #﹖"
if __git_has_untracked
segment "$text_color" blue "?" #﹖"
end
# set -l dirty_files (__git_dirty_files)
# if test "0" != "$dirty_files"
# segment "$text_color" red "$dirty_files"
if __git_is_dirty
segment "$text_color" red "⁝" # " ╍"
end
# set -l staged_files (__git_staged_files)
# if test "0" != "$staged_files"
if __git_is_staged
segment "$text_color" yellow "🮸 " #"🮶"
end
if __git_is_stashed
segment "$text_color" blue "♺" # "╍╍"
end
# set -l untracked_files (__git_untracked_files)
# if test "0" != "$untracked_files"
# segment "$text_color" blue "$untracked_files?" #﹖"
if __git_has_untracked
segment "$text_color" blue "?" #﹖"
end
# set -l dirty_files (__git_dirty_files)
# if test "0" != "$dirty_files"
# segment "$text_color" red "$dirty_files"
if __git_is_dirty
segment "$text_color" red "⁝" # " ╍"
end
# set -l staged_files (__git_staged_files)
# if test "0" != "$staged_files"
if __git_is_staged
segment "$text_color" yellow "🮸 " #"🮶"
end
set -l git_color "$split_color" "$text_color"
set -l git_glyph ""
if __git_is_detached_head
set git_glyph "➤"
if __git_is_tag
set git_glyph "🏷"
set -l git_color "$split_color" "$text_color"
set -l git_glyph ""
if __git_is_detached_head
set git_glyph "➤"
if __git_is_tag
set git_glyph "🏷"
end
end
end
set -l prompt
# set -l git_ahead (__git_ahead "🠕 " "🠗 " "⤲ ")
set -l git_ahead (__git_ahead)
if test -z "$git_ahead"
else if test "+" = "$git_ahead"
set git_ahead "🠕"
set git_color $text_color green
else if test "-" = "$git_ahead"
set git_ahead "🠗"
set git_color $text_color yellow
else
set git_ahead "⤲"
set git_color $text_color red
end
if test "$branch_name" = master -o "$branch_name" = main
set prompt " $git_glyph $git_ahead"
else
set prompt " $git_glyph $branch_name $git_ahead"
set -l prompt
# set -l git_ahead (__git_ahead "🠕 " "🠗 " "⤲ ")
set -l git_ahead (__git_ahead)
if test -z "$git_ahead"
else if test "+" = "$git_ahead"
set git_ahead "🠕"
set git_color $text_color green
else if test "-" = "$git_ahead"
set git_ahead "🠗"
set git_color $text_color yellow
else
set git_ahead "⤲"
set git_color $text_color red
end
if test "$branch_name" = master -o "$branch_name" = main
set prompt " $git_glyph $git_ahead"
else
set prompt " $git_glyph $branch_name $git_ahead"
end
segment "$git_color[1]" "$git_color[2]" "$prompt"
end
segment "$git_color[1]" "$git_color[2]" "$prompt"
end
segment $base_color " $dir"(set_color $text_color)"$base "

Loading…
Cancel
Save