Last active
December 8, 2021 14:56
-
-
Save D1360-64RC14/ce344ef296072deee0fbcbe15560b3af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Adições realizadas ao meu .bashrc | |
| if [ -f ~/.bash_path ]; then | |
| ADD_TO_PATH=$(cat ~/.bash_path) | |
| for p in $ADD_TO_PATH; do | |
| if [[ $(echo $p | head -c 1) != '#' ]]; then | |
| PATH=$PATH:$p | |
| fi | |
| done | |
| fi | |
| # https://en.wikipedia.org/wiki/ANSI_escape_code#Colors | |
| NO_COLOR='\033[0m' | |
| COLOR_BLACK='\033[0;30m' | |
| COLOR_RED='\033[0;31m' | |
| COLOR_GREEN='\033[0;32m' | |
| COLOR_YELLOW='\033[0;33m' | |
| COLOR_BLUE='\033[0;34m' | |
| COLORR_MAGENTA='\033[0;35m' | |
| COLOR_CYAN='\033[0;36m' | |
| COLOR_WHITE='\033[0;37m' | |
| COLOR_LIGHT_BLACK='\033[1;90m' | |
| COLOR_LIGHT_RED='\033[1;91m' | |
| COLOR_LIGHT_GREEN='\033[1;92m' | |
| COLOR_LIGHT_YELLOW='\033[1;93m' | |
| COLOR_LIGHT_BLUE='\033[1;94m' | |
| COLOR_LIGHT_MAGENTA='\033[1;95m' | |
| COLOR_LIGHT_CYAN='\033[1;96m' | |
| COLOR_LIGHT_WHITE='\033[1;97m' | |
| function nodeopen { | |
| # Para remover as mensagens de saída (echo e ls) | |
| # mude a variável 'LOG' para false. | |
| LOG=true | |
| MESSAGE="Novo diretório 'node_modules/.bin' encontrado!" | |
| # Ativa se existir o diretório "node_modules/.bin" | |
| # e se o mesmo não estiver no PATH. | |
| if [ -d node_modules/.bin ] && [[ $PATH != *"$(pwd)/node_modules/.bin"* ]]; then | |
| PATH=$PATH:$(pwd)/node_modules/.bin | |
| if [ $LOG == true ]; then | |
| echo -e "\n ${COLOR_LIGHT_GREEN}${MESSAGE}${NO_COLOR}\n" | |
| ls node_modules/.bin | |
| fi | |
| fi | |
| } | |
| nodeopen | |
| # Função executada toda vez que | |
| # o diretório é trocado. | |
| function on_change_directory { | |
| nodeopen | |
| } | |
| # Monitora execuções do | |
| # comando 'cd'. | |
| function cd { | |
| builtin cd "$@" | |
| RETURN_CODE=$? | |
| on_change_directory | |
| return $RETURN_CODE | |
| } | |
| source $HOME/.bash_scripts/load_scripts.sh |
This file contains hidden or 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
| # Bash script feito para instalar | |
| # facilmente outras versões do GoLang | |
| #!/bin/bash | |
| function go_install { | |
| local VERSION=$1 | |
| local FILENAME=go$VERSION.linux-amd64.tar.gz | |
| local DOWNLOAD_LINK=https://golang.org/dl/$FILENAME | |
| local DOWNLOAD_DIR=/tmp/download-$FILENAME | |
| local DOWNLOAD_PATH=$DOWNLOAD_DIR/$FILENAME | |
| local INSTALL_DIR=/usr/local/lib/go | |
| local STRING_CHECK_SCRIPT=' | |
| const expression = /(" \[1\])$/; | |
| const check = expression.test(process.env.OUT.trim()); | |
| console.log(check); | |
| ' | |
| if [ ! $VERSION ]; then | |
| \echo "Informe uma versão, como por exemplo 'go_install 1.17.2'"; | |
| return 1; | |
| fi | |
| ### Etapa de Download ### | |
| \echo -e "\nTentando baixar '$FILENAME'..." | |
| \mkdir -p $DOWNLOAD_DIR | |
| local DOWNLOAD_OUT=$(wget -nv $DOWNLOAD_LINK -O $DOWNLOAD_PATH 2>&1) | |
| local DOWNLOAD_RESULT=$(OUT=$DOWNLOAD_OUT node -e "$STRING_CHECK_SCRIPT") | |
| if [ $DOWNLOAD_RESULT = false ]; then | |
| \echo -e "\nAlgo deu errado no Download do arquivo, verifique se digitou a versão corretamente." | |
| \rm -r $DOWNLOAD_DIR | |
| return 1; | |
| fi | |
| ### Etapa de Instalação ### | |
| \tar -zxf $DOWNLOAD_PATH -C $DOWNLOAD_DIR | |
| \mv $DOWNLOAD_DIR/go $DOWNLOAD_DIR/$VERSION | |
| sudo -E \rm -r $INSTALL_DIR/$VERSION 2> /dev/null | |
| sudo -E \mkdir -p $INSTALL_DIR/$VERSION | |
| sudo -E \mv $DOWNLOAD_DIR/$VERSION $INSTALL_DIR/ | |
| echo -e "\nInstalação concluída! Versão instalada em '$INSTALL_DIR/$VERSION'" | |
| } |
This file contains hidden or 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
| # Bash script feito para trabalhar junto com o | |
| # golang_install.sh selecionando qual versão utilizar. | |
| #!/bin/bash | |
| export GO_VERSION=1.17.3 | |
| export GOROOT=/usr/local/lib/go/$GO_VERSION | |
| export GOPATH=$HOME/go | |
| export PATH=$PATH:$GOROOT/bin:$GOPATH/bin |
This file contains hidden or 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
| # Bash script feito para cattegar todos os scripts criados pelo usuário. | |
| # A pasta desses scripts é ~/.bash_scripts | |
| #!/bin/bash | |
| FOLDER=$HOME/.bash_scripts | |
| for SCRIPT in $(ls $FOLDER | awk '/.sh/{print}'); do | |
| if [[ $SCRIPT != "load_scripts.sh" ]]; then | |
| source $FOLDER/$SCRIPT | |
| fi | |
| done |
This file contains hidden or 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
| # Bash script criado para abrir o nautilus no | |
| # diretório atual apenas digitando o comando `here`. | |
| #!/bin/bash | |
| function here { | |
| echo Abrindo nautilus em $(pwd) | |
| nautilus $(pwd) &> /dev/null & | |
| } |
This file contains hidden or 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
| # Este bash script cria um novo diretório na pasta | |
| # /tmp para o testes rápidos sobre qualquer coisa. | |
| # https://en.wikipedia.org/wiki/ANSI_escape_code#Colors | |
| NO_COLOR='\033[0m' | |
| COLOR_BLACK='\033[0;30m' | |
| COLOR_RED='\033[0;31m' | |
| COLOR_GREEN='\033[0;32m' | |
| COLOR_YELLOW='\033[0;33m' | |
| COLOR_BLUE='\033[0;34m' | |
| COLORR_MAGENTA='\033[0;35m' | |
| COLOR_CYAN='\033[0;36m' | |
| COLOR_WHITE='\033[0;37m' | |
| COLOR_LIGHT_BLACK='\033[1;90m' | |
| COLOR_LIGHT_RED='\033[1;91m' | |
| COLOR_LIGHT_GREEN='\033[1;92m' | |
| COLOR_LIGHT_YELLOW='\033[1;93m' | |
| COLOR_LIGHT_BLUE='\033[1;94m' | |
| COLOR_LIGHT_MAGENTA='\033[1;95m' | |
| COLOR_LIGHT_CYAN='\033[1;96m' | |
| COLOR_LIGHT_WHITE='\033[1;97m' | |
| # Recebe: <cor> <texto> | |
| function colorize { | |
| COLOR=$(eval "echo \$$1") | |
| TEXT=$(echo $@ | awk '{ | |
| color_length = length($1); | |
| print substr($0, color_length + 2) | |
| }') | |
| echo -e $COLOR$TEXT$NO_COLOR | |
| } | |
| # Este comando cria uma nova pasta. | |
| # Executa os | |
| function newtemp { | |
| if [[ $1 = "newtemp" ]]; then | |
| colorize COLOR_RED "Recursions aren't-ish allowed!" | |
| return 1 | |
| fi | |
| NSDATE=$(date +%s)$(date +%N) # Segundos com nanosegundos | |
| FOLDER=/tmp/$NSDATE | |
| mkdir $FOLDER | |
| cd $FOLDER | |
| # Salva no arquivo /tmp/last_tmp_folder | |
| # o último diretório temporário criado. | |
| echo $FOLDER > /tmp/last_tmp_folder | |
| colorize COLOR_GREEN "Now in temp folder $(pwd)" | |
| eval $(echo $@ | awk '{ | |
| color_length = length($1); | |
| print substr($0, color_length + 2) | |
| }') | |
| } | |
| # Este programa encaminha o terminal | |
| # ao último diretório temporário criado. | |
| function backtemp { | |
| cd $(cat /tmp/last_tmp_folder) | |
| } | |
| # Salva nas env vars o diretório temporário. | |
| if [ -f "/tmp/last_tmp_folder" ]; then | |
| TEMP=$(cat /tmp/last_tmp_folder) | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment