add latex-color function

This commit is contained in:
Mylloon 2024-10-06 18:07:45 +02:00
parent 4c9b31164d
commit 04bb7b1c37
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 28 additions and 0 deletions

View file

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

View file

@ -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/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/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/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-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 @$(WGET) $(REPO_SRC)/.config/fish/functions/ssh-import.fish -O $(HOME)/.config/fish/functions/ssh-import.fish

View file

@ -86,6 +86,7 @@ function main {
wget -q "${repo}"/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish wget -q "${repo}"/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish
# Add functions # Add functions
wget -q "${repo}"/.config/fish/functions/catall.fish -P "$HOME"/.config/fish/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/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-export.fish -P "$HOME"/.config/fish/functions/
wget -q "${repo}"/.config/fish/functions/ssh-import.fish -P "$HOME"/.config/fish/functions/ wget -q "${repo}"/.config/fish/functions/ssh-import.fish -P "$HOME"/.config/fish/functions/