Last active
July 5, 2022 22:23
-
-
Save joaovictornsv/498fea3b28e0b2cec698cc0b83093e79 to your computer and use it in GitHub Desktop.
Em busca do Linux automático 🚀
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WHITE="\033[1;37m"; | |
RESET="\033[0m"; | |
echo "- ${WHITE}build${RESET}: Changes that affect the build system or external dependencies | |
- ${WHITE}ci${RESET}: Changes to our CI configuration files and scripts | |
- ${WHITE}docs${RESET}: Documentation only changes | |
- ${WHITE}feat${RESET}: A new feature | |
- ${WHITE}fix${RESET}: A bug fix | |
- ${WHITE}perf${RESET}: A code change that improves performance | |
- ${WHITE}refactor${RESET}: A code change that neither fixes a bug nor adds a feature | |
- ${WHITE}style${RESET}: Changes that do not affect the meaning of the code (white-space, semi-colons, etc) | |
- ${WHITE}test${RESET}: Adding missing tests or correcting existing tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git branch >> temp.txt; | |
ARRAY=( | |
'main' '* main' | |
'master' '* master' | |
'develop' '* develop' | |
'dev' '* dev' | |
'qa' '* qa' | |
'homolog' '* homolog' | |
'hml' '* hml' | |
); | |
echo "Branches to delete:" | |
count=0; | |
while read p; do | |
if ! [[ "${ARRAY[@]}" =~ "${p}" ]]; then | |
echo "- ${p}"; | |
let count++; | |
fi | |
done < temp.txt; | |
echo "------------------------------------------" | |
echo "Total: ${count} branches" | |
read -p "Are you sure you want to continue (y/n)? " answer | |
case ${answer:0:1} in | |
y|Y ) echo 'Initializing...';; | |
* ) rm temp.txt; exit;; | |
esac | |
deleted=0; | |
errors=0; | |
while read p; do | |
if ! [[ "${ARRAY[@]}" =~ "${p}" ]] && ! [[ "${ARRAY[@]}" =~ "* ${p}" ]]; then | |
if git branch -d "${p}"; then let deleted++; else let errors++; fi; | |
fi | |
done < temp.txt; | |
rm temp.txt; | |
echo "------------------------------------------" | |
echo "${deleted}/${count} branches deleted. ${errors} errors"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ===== FOLDERS DEFINITION ===== | |
SOURCE_FOLDER=~/Downloads; | |
PDF_FOLDER=$SOURCE_FOLDER/pdf; | |
IMAGES_FOLDER=$SOURCE_FOLDER/images; | |
VIDEOS_FOLDER=$SOURCE_FOLDER/videos; | |
DOCS_FOLDER=$SOURCE_FOLDER/docs; | |
ZIP_FOLDER=$SOURCE_FOLDER/zip; | |
DEB_FOLDER=$SOURCE_FOLDER/deb; | |
JSON_FOLDER=$SOURCE_FOLDER/json; | |
OTHERS_FOLDER=$SOURCE_FOLDER/others; | |
VOID=/dev/null; | |
# ===== CREATE FOLDERS ===== | |
mkdir -p $PDF_FOLDER; | |
mkdir -p $IMAGES_FOLDER; | |
mkdir -p $VIDEOS_FOLDER; | |
mkdir -p $DOCS_FOLDER; | |
mkdir -p $ZIP_FOLDER; | |
mkdir -p $DEB_FOLDER; | |
mkdir -p $JSON_FOLDER; | |
mkdir -p $OTHERS_FOLDER; | |
# ===== ORGANIZE FILES ===== | |
## PDFs | |
mv -n $SOURCE_FOLDER/*.pdf $PDF_FOLDER 2> $VOID; | |
## Images | |
mv -n $SOURCE_FOLDER/*.{gif,png,jpeg,jpg} $IMAGES_FOLDER 2> $VOID; | |
## Videos | |
mv -n $SOURCE_FOLDER/*.{wmv,m4p,mov,m4v,mkv,avi,mp4} $VIDEOS_FOLDER 2> $VOID; | |
## Documents | |
mv -n $SOURCE_FOLDER/*.{doc,docx} $DOCS_FOLDER 2> $VOID; | |
## Zip | |
mv -n $SOURCE_FOLDER/*.zip $ZIP_FOLDER 2> $VOID; | |
## JSON | |
mv -n $SOURCE_FOLDER/*.json $JSON_FOLDER 2> $VOID; | |
## .deb files | |
mv -n $SOURCE_FOLDER/*.deb $DEB_FOLDER 2> $VOID; | |
## Other files (remaining files) | |
find $SOURCE_FOLDER/ -maxdepth 1 -type f -exec mv {} $OTHERS_FOLDER \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment