From 7f833712b2ef915c43e973ad8859765b35e464a7 Mon Sep 17 00:00:00 2001 From: Deepankar Chakroborty Date: Thu, 14 Mar 2024 14:04:09 -0700 Subject: [PATCH] Convert themes to TOML --- convert_to_toml.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/convert_to_toml.sh b/convert_to_toml.sh index dc9b21f..bb5edf8 100755 --- a/convert_to_toml.sh +++ b/convert_to_toml.sh @@ -16,16 +16,21 @@ # shopt -s globstar cd themes -if command -v yj > /dev/null 2>&1; then - # For each .yaml file in the current directory - for yaml_file in *.yml; do - # Use basename to get the file name without the .yaml extension - base_name=$(basename "$yaml_file" .yml) +if command -v sd > /dev/null 2>&1; then + if command -v yj > /dev/null 2>&1; then + # For each .yaml file in the current directory + for yaml_file in *.yml; do + # Use basename to get the file name without the .yaml extension + base_name=$(basename "$yaml_file" .yml) - # Convert .yaml to .toml using yj - cat "$yaml_file" | yj -yt > "${base_name}.toml" - done + # Convert .yaml to .toml using yj + cat "$yaml_file" | yj -yt | sd "^.*_background.*\r?\n" "" | sd "^.*_foreground.*\r?\n" "" > "${base_name}.toml" + done + else + echo "Get yj from: https://github.com/sclevine/yj" + fi else - echo "Get yj from: https://github.com/sclevine/yj" + echo "Get sd from: https://github.com/chmln/sd" fi +