Add Fossil VCS support

Commit amended on 2024-04-19 to update the README.
This commit is contained in:
demize
2024-04-18 22:44:45 -04:00
parent 83bf89d10c
commit 921a6f40fb
3 changed files with 79 additions and 0 deletions

View File

@@ -72,6 +72,11 @@ function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish
end
end
function __bobthefish_fossil_branch -S -d 'Get the current fossil branch'
set -l branch (command fossil branch 2>/dev/null)
echo "$branch_glyph $branch"
end
function __bobthefish_hg_branch -S -d 'Get the current hg branch'
set -l branch (command hg branch 2>/dev/null)
set -l book (command hg book | command grep \* | cut -d\ -f3)
@@ -190,6 +195,17 @@ function __bobthefish_git_project_dir -S -a real_pwd -d 'Print the current git p
end
end
function __bobthefish_fossil_project_dir -S -a real_pwd -d 'Print the current fossil project base directory'
[ "$theme_display_fossil" = 'yes' ]
or return
set -q theme_vcs_ignore_paths
and [ (__bobthefish_ignore_vcs_dir $real_pwd) ]
and return
command fossil info 2>/dev/null | sed '3q;d' | string split ' ' -f2 -n | string trim --right --chars=/
end
function __bobthefish_hg_project_dir -S -a real_pwd -d 'Print the current hg project base directory'
[ "$theme_display_hg" = 'yes' ]
or return
@@ -1020,6 +1036,54 @@ end
# VCS segments
# ==============================
function __bobthefish_prompt_fossil -S -a fossil_root_dir -a real_pwd -d 'Display the actual fossil state'
set fossil_statuses (command fossil changes --differ 2>/dev/null | cut -d' ' -f1 | sort -u)
# Fossil doesn't really stage changes; untracked files are ignored, tracked files are committed by default
# It also syncs by default when you commit, and monitors for conflicts (which will be reported here)
for line in $fossil_statuses
switch $line
case ADDED UPDATED EDITED DELETED RENAMED
# These can really just all be dirty, then
set dirty $git_dirty_glyph
case EXTRA
set new $git_untracked_glyph
case CONFLICT
set conflict '!'
end
end
set flags "$dirty$new$conflict"
[ "$flags" ]
and set flags " $flags"
set -l flag_colors $color_repo
if [ "$dirty" ]
set flag_colors $color_repo_dirty
end
__bobthefish_path_segment $fossil_root_dir project
__bobthefish_start_segment $flag_colors
echo -ns $fossil_glyph ' '
__bobthefish_start_segment $flag_colors
echo -ns (__bobthefish_fossil_branch) $flags ' '
set_color normal
set -l project_pwd (__bobthefish_project_pwd $fossil_root_dir $real_pwd)
if [ "$project_pwd" ]
if [ -w "$real_pwd" ]
__bobthefish_start_segment $color_path
else
__bobthefish_start_segment $color_path_nowrite
end
echo -ns $project_pwd ' '
end
end
function __bobthefish_prompt_hg -S -a hg_root_dir -a real_pwd -d 'Display the actual hg state'
set -l dirty (command hg stat; or echo -n '*')
@@ -1242,6 +1306,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
# VCS
set -l git_root_dir (__bobthefish_git_project_dir $real_pwd)
set -l hg_root_dir (__bobthefish_hg_project_dir $real_pwd)
set -l fossil_root_dir (__bobthefish_fossil_project_dir $real_pwd)
if [ "$git_root_dir" -a "$hg_root_dir" ]
# only show the closest parent
@@ -1255,6 +1320,8 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_prompt_git $git_root_dir $real_pwd
else if [ "$hg_root_dir" ]
__bobthefish_prompt_hg $hg_root_dir $real_pwd
else if [ "$fossil_root_dir" ]
__bobthefish_prompt_fossil $fossil_root_dir $real_pwd
else
__bobthefish_prompt_dir $real_pwd
end