Skip to content

Instantly share code, notes, and snippets.

@diogorusso
Last active October 28, 2018 00:19
Show Gist options
  • Save diogorusso/1a2d659d9e19cfd0fa39e49f8774ede3 to your computer and use it in GitHub Desktop.
Save diogorusso/1a2d659d9e19cfd0fa39e49f8774ede3 to your computer and use it in GitHub Desktop.

Shell Script .sh

  • what's
  • snippets
    • menu.sh : select from txt list and run a script
    • create a eof encoded text file (.txt, .scss, .css, .html, .rb, .py...)
echo "πŸ™ \033[0m \033[1;34m Heyyyy!!! \033[0m\033[1;32m O que vc deseja fazer???? \033[0m"
# load menu-commands.txt
# every menu option has an equivalent .sh script
IFS=$'\r\n' GLOBIGNORE='*' command eval 'tasks=($(cat ./_scripts/sh/_menu-commands.txt))'
# remover aruqivos do tema
PS3='πŸ™ Please enter your choice: '
select opt in "${tasks[@]}"
do
echo "πŸ™ \033[0m \033[1;34m $opt!!! \033[0m\033[1;32m HEYYYY! \033[0m"
sh ./_scripts/sh/$opt.sh
sh ./_scripts/sh/_#main.sh
break
done
dev
deploy
theme_activate
theme_clone
theme_delete
exit
echo "tchau tchau baby!!!"
exit 1
cat > ./example.txt <<- 'EOF'
---
# file content
# file content
EOF
file -I ./example.txt
echo "encoding your file" ("us-ascii") to utf-8"
echo "πŸ™ \033[1;34m Done!!! \033[0m"
echo "πŸ™ \033[1;34m ATTENTION: vamo remover o tema atual se existir algum!! \033[0m"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'themes=($(cat ./_scripts/sh/_list-items.txt))'
IFS=$'\r\n' GLOBIGNORE='*' command eval 'themeActive=($(cat ./_scripts/sh/_item-active.txt))'
PS3=' πŸ™ Please enter your choice: '
select opt in "${themes[@]}"
do
echo "πŸ™ \033[0m \033[1;34m $opt!!! \033[0m\033[1;32m Vamos instalar! \033[0m"
break
done
theme=$opt
export theme
#
rm ./_scripts/sh/_theme-active.txt
rm ./_theme/$themeActive/$themeActive.gemspec
rm ./_scripts/gulp/theme.js
rm -rf ./_config/
rm Gemfile
rm Gemfile.lock
if [ $themeActive = "bootstrap" ]
then
rm ./.bootstraprc
rm ./_config/webpack.bootstrap.config.js
rm ./postcss.config.js
else
rm _config/postcss.config.js
fi
#
sh ./_scripts/sh/create_Config-_main.sh
echo "module.exports = {theme: '$opt'}" >> ./_scripts/gulp/theme.js
sh ./_scripts/sh/create_GemSpec.sh
sh ./_scripts/sh/create_Gemfile.sh
sh ./_scripts/sh/create_Hologram.sh
if [ "$opt" = "bootstrap" ]
then
sh ./_scripts/sh/create_BootstrapRC.sh
sh ./_scripts/sh/create_Webpack-Bootstrap.sh
sh ./_scripts/sh/create_Webpack-Dev-Bootstrap.sh
sh ./_scripts/sh/create_Webpack-Dist-Bootstrap.sh
echo "πŸ™ \033[0m \033[1;34m boot!!! \033[0m\033[1;32m boot baby! \033[0m"
else
sh ./_scripts/sh/create_Webpack-Dev.sh
sh ./_scripts/sh/create_Webpack-Dist.sh
fi
sh ./_scripts/sh/create_Postcss.sh
bundle update
bundle install
echo "$opt" >> ./_scripts/sh/_item-active.txt
html-react
bootstrap
bulma
foundation
mdl
# load files
IFS=$'\r\n' GLOBIGNORE='*' command eval 'themes=($(cat ./_scripts/sh/_items.txt))'
# new theme name
echo "πŸ™ \033[1;34m qual o nome do seu novo tema? \033[0m"
read newTheme
echo "πŸ™ \033[0m \033[1;34m $newTheme !!! \033[0m\033[1;32m vamo com tudo braΓ§o!! \033[0m"
theme=$newTheme
export theme
# select theme
echo "πŸ™ \033[1;34m selecione um dos temas para clonar? \033[0m"
PS3='πŸ™ Please enter your choice: '
select opt in "${themes[@]}"
do
echo "πŸ™ \033[0m \033[1;34m $opt!!! \033[0m\033[1;32m HEYYYY! \033[0m"
break
done
# copiar tema selecionado
cp -R ./_theme/$opt/ ./_theme/$newTheme
# remover .gemspec
rm ./_theme/$newTheme/*.gemspec
# criar novo .gemspec
sh ./_scripts/sh/create_GemSpec.sh
# atualizar array $themes
themes+=($newTheme)
echo "πŸ™ \033[0m \033[1;34m ${themes[@]}!!! \033[0m\033[1;32m HEYYYY! \033[0m"
# deletar themes-custom.txt
rm ./_scripts/sh/_themes-custom.txt
# salvar $themes como themes-custom.txt
printf "%s\n" "${themes[@]}" > ./_scripts/sh/_list-items.txt
# load files
IFS=$'\r\n' GLOBIGNORE='*' command eval 'themes=($(cat ./_scripts/sh/_list-items.txt))'
if [ ${#themes[@]} -eq 0 ]; then
echo "No themes to delete, all clean!!!!"
break
else
# select theme to delete
echo "πŸ™ \033[1;34m selecione um dos temas para DELETAR? \033[0m"
PS3='πŸ™ Please enter your choice: '
select opt in "${themes[@]}"
do
echo "πŸ™ \033[0m \033[1;34m $opt!!! \033[0m\033[1;32m HEYYYY! \033[0m"
break
done
# remover tema from array
unset themes[$opt]
# deletar themes-custom.txt
rm ./_scripts/sh/_themes-custom.txt
# atualizar themes-custom.txt sem item
printf "%s\n" "${themes[@]}" > ./_scripts/sh/_list-items.txt
# remover aruqivos do tema
echo "Do you really wish to remove theme files?"
select yn in "Yes" "No"; do
case $yn in
Yes ) rm -rf ./_theme/$opt; break;;
No ) exit;;
esac
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment