Skip to content

Instantly share code, notes, and snippets.

@nazfox
Last active March 6, 2022 05:40
Show Gist options
  • Save nazfox/2050adfa632601bcd4dc0a90ff70ef02 to your computer and use it in GitHub Desktop.
Save nazfox/2050adfa632601bcd4dc0a90ff70ef02 to your computer and use it in GitHub Desktop.
テンプレートファイルにテーマファイルを挿入するやつ sedとか使いたかったけど結局ループになった
#!/bin/bash
theme="$1"
template="./template.yml"
output="./alacritty.yml"
if [[ ! -f $template ]]; then
echo "template file does not exists." 1>&2
exit 1
fi
if [[ ! -f $theme ]]; then
echo "theme file does not eixists." 1>&2
exit 2
fi
rm "$output"
touch "$output"
cat "$template" | while IFS= read -r line; do
if [ "$line" = "{{ colors }}" ]; then
echo "# theme: $theme" >> "$output"
cat "$theme" >> "$output"
else
echo "$line" >> "$output"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment