dotfiles/vscode/generate_install_scripts.sh

46 lines
1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
YAMLDOC="extensions.yml"
# check for yq
2022-07-06 11:55:14 -05:00
if ! command -v yq &>/dev/null; then
echo "yq could not be found"
echo "to install w/ eget"
echo "eget mikefarah/yq"
exit
fi
readarray sections < <(yq e 'keys | .[]' $YAMLDOC)
get_extensions() {
2022-07-06 11:55:14 -05:00
for section in "${sections[@]}"; do
echo $section
readarray exts < <(key=$section yq e '.[env(key)] | .[]' $YAMLDOC)
echo ${exts[@]}
for ext in "${exts[@]}"; do
write_bat $ext
write_sh $ext
done
done
}
write_bat() {
2022-07-06 11:55:14 -05:00
echo "call code --install-extension $1 --force" >>install-extensions.bat
}
write_sh() {
2022-07-06 11:55:14 -05:00
echo "code --install-extension $1 --force" >>install-extensions.sh
}
# clean up old files
rm -f install-extensions.{sh,bat}
2022-07-06 11:55:14 -05:00
echo "echo off" >install-extensions.bat
echo >>install-extensions.bat
echo "echo Installing VSCode extensions" >>install-extensions.bat
echo "#!/usr/bin/env bash" >install-extensions.sh
echo >>install-extensions.sh
echo "echo Installing VSCode extensions" >>install-extensions.sh
# read extensions and write install scripts
2022-07-06 11:55:14 -05:00
get_extensions