diff --git a/.config/fish/functions/latex-color.fish b/.config/fish/functions/latex-color.fish index c942822..4a5a885 100644 --- a/.config/fish/functions/latex-color.fish +++ b/.config/fish/functions/latex-color.fish @@ -18,6 +18,12 @@ function latex-color --description "Get the LaTeX color from HEX code" set hex (string sub -s 2 $hex) end + # Check if the length of the hex is valid + if not contains $(string length $hex) $(string split " " "3 4 6 8") + echo "Error: Invalid HEX code" + return 1 + end + # Expand 3 hex to 4 hex if test (string length $hex) -eq 3 set hex $(string join "" $hex 0)