From 04bb7b1c3712d27c57c4b3e67346a7cfdf3d3f3a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 6 Oct 2024 18:07:45 +0200 Subject: [PATCH] add latex-color function --- .config/fish/functions/latex-color.fish | 26 +++++++++++++++++++++++++ Makefile | 1 + meta.sh | 1 + 3 files changed, 28 insertions(+) create mode 100644 .config/fish/functions/latex-color.fish diff --git a/.config/fish/functions/latex-color.fish b/.config/fish/functions/latex-color.fish new file mode 100644 index 0000000..af0ce2a --- /dev/null +++ b/.config/fish/functions/latex-color.fish @@ -0,0 +1,26 @@ +function latexcolor --description "Get the LaTeX color from HEX code" + # Declare our arguments + argparse h/help -- $argv + + # Get function name + set current_name $(status current-function) + + # Check if not enough arguments provided, or help menu + if set -ql _flag_help || test -z $argv[2] + echo -e "Usage: $current_name hex" + echo -e " $current_name [-h|--help] \t\t - Show this help message" + return 0 + end + + set hex $argv[1] + if string match -r '^#' -- $hex + set hex (string sub -s 2 $hex) + end + + # Convert hex to RGB + set r (math "0x${hex[1..2]} / 255") + set g (math "0x${hex[3..4]} / 255") + set b (math "0x${hex[5..6]} / 255") + + printf "{%.2f, %.2f, %.2f}\n" $r $g $b +end diff --git a/Makefile b/Makefile index 5904d6d..4a7e2e8 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,7 @@ sync-dotconfig: @$(WGET) $(REPO_SRC)/.config/fish/functions/fish_prompt.fish -O $(HOME)/.config/fish/functions/fish_prompt.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/catall.fish -O $(HOME)/.config/fish/functions/catall.fish + @$(WGET) $(REPO_SRC)/.config/fish/functions/latex-color.fish -O $(HOME)/.config/fish/functions/latex-color.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/makeaway.fish -O $(HOME)/.config/fish/functions/makeaway.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/ssh-export.fish -O $(HOME)/.config/fish/functions/ssh-export.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/ssh-import.fish -O $(HOME)/.config/fish/functions/ssh-import.fish diff --git a/meta.sh b/meta.sh index 0c87f0f..523aa35 100644 --- a/meta.sh +++ b/meta.sh @@ -86,6 +86,7 @@ function main { wget -q "${repo}"/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish # Add functions wget -q "${repo}"/.config/fish/functions/catall.fish -P "$HOME"/.config/fish/functions/ + wget -q "${repo}"/.config/fish/functions/latex-color.fish -P "$HOME"/.config/fish/functions/ wget -q "${repo}"/.config/fish/functions/makeaway.fish -P "$HOME"/.config/fish/functions/ wget -q "${repo}"/.config/fish/functions/ssh-export.fish -P "$HOME"/.config/fish/functions/ wget -q "${repo}"/.config/fish/functions/ssh-import.fish -P "$HOME"/.config/fish/functions/