diff --git a/fish/functions/fish_colors_check.fish b/fish/functions/fish_colors_check.fish new file mode 100644 index 0000000..dbd84ac --- /dev/null +++ b/fish/functions/fish_colors_check.fish @@ -0,0 +1,46 @@ +function fish_colors_check --description 'Validate the fish color variables' --argument-names fish_srcdir + if test -z "$fish_srcdir" + echo "Usage: fish_colors_check " + return 1 + end + if not test -d "$fish_srcdir" + echo "Error: not a directory: $fish_srcdir" + return 2 + end + + set --local allcolors (string collect (rg --no-line-number --no-filename --only-matching 'fish(?:_pager)?_color[a-z_]*[a-z]+' $fish_srcdir | sort | uniq)) + set --local setcolors (string collect (set --names | string match 'fish*_color*')) + + set --local missingcolors + set --local unknowncolors + + for color in $allcolors + if not contains -- $color $setcolors + set missingcolors $missingcolors $color + end + end + + for color in $setcolors + if not contains -- $color $allcolors + set unknowncolors $unknowncolors $color + end + end + + if test (count $missingcolors) -gt 0 + # *current regex matches some invalid cases + # + # example: set -l color_name fish_color_git_$i + # match: fish_color_git + echo "These color variables are (potentially*) defined, but unset:" + for color in $missingcolors + echo " - $color" + end + end + + if test (count $unknowncolors) -gt 0 + echo "These color variables are set, but undefined:" + for color in $unknowncolors + echo " - $color" + end + end +end diff --git a/fish/functions/video_compress.fish b/fish/functions/video_compress.fish index 2f5be74..e98f4fe 100644 --- a/fish/functions/video_compress.fish +++ b/fish/functions/video_compress.fish @@ -1,6 +1,6 @@ function video_compress --argument-names srcfile if test -z "$srcfile" - echo "Error: missing argument" + echo "Usage: video_compress " return 1 end if not test -f "$srcfile"