Add Fossil VCS support

Commit amended on 2024-04-19 to update the README.
pull/363/head
demize 3 months ago
parent 83bf89d10c
commit 921a6f40fb
No known key found for this signature in database
GPG Key ID: AECE696834DC11E9

@ -63,6 +63,10 @@ This theme is based loosely on [agnoster][btf-agnoster].
* Unpushed commits (**`+`**)
* Unpulled _and_ unpushed commits (**`±`**)
* _Note that not all of these have been implemented for hg yet :)_
* Fossil status:
* Dirty working directory (**`*`**)
* Untracked files (**`…`**)
* Conflicts (**`!`**)
* Abbreviated project-relative path
@ -244,6 +248,10 @@ If you do any Git worktree shenanigans, setting this to `yes` will fix incorrect
This feature is disabled by default. Use `yes` to enable Mercurial support in Bobthefish. If you don't use Mercurial, leave it disabled because it's ... not fast.
#### `set -g theme_display_fossil yes`
This feature is also disabled by default. It should be faster than Mercurial, but if you aren't using Fossil it's safe to leave disabled.
#### `set -g theme_vcs_ignore_paths /some/path /some/other/path{foo,bar}`
Ignore project paths for Git or Mercurial. Supports glob patterns.

@ -49,6 +49,9 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
set -x git_minus_glyph '-'
set -x git_plus_minus_glyph '±'
# Fossil glyph (it reuses most of the git glyphs)
set -x fossil_glyph '🦴'
# Disable Powerline fonts (unless we're using nerd fonts instead)
if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ]
set private_glyph \u29B8 ' '
@ -83,6 +86,7 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
set git_stashed_glyph \uF0C6 '' # nf-fa-paperclip
set git_untracked_glyph \uF128 '' # nf-fa-question
# set git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h
set fossil_glyph '󰂹'
set git_ahead_glyph \uF47B # nf-oct-chevron_up
set git_behind_glyph \uF47C # nf-oct-chevron_down

@ -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

Loading…
Cancel
Save