Skip to content

Instantly share code, notes, and snippets.

@j-martinez-dev
Created October 5, 2021 14:55
Show Gist options
  • Save j-martinez-dev/936d60a5199f6e109a91329af624e1a7 to your computer and use it in GitHub Desktop.
Save j-martinez-dev/936d60a5199f6e109a91329af624e1a7 to your computer and use it in GitHub Desktop.

Revisions

  1. Jaime Martinez created this gist Oct 5, 2021.
    146 changes: 146 additions & 0 deletions wsl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,146 @@
    echo "Please write your name:"
    read NAME

    echo "Please write your personal email:"
    read PERSONAL

    echo "Please write your work email:"
    read WORK

    init() {
    sudo apt update
    sudo apt upgrade -y
    }

    install_common_utils() {
    sudo apt install -y curl xclip jq
    }

    install_git() {
    rm -rf ~/workspace
    rm ~/.gitconfig
    rm ~/.gitconfig-personal
    rm ~/.gitconfig-work

    mkdir ~/workspace
    mkdir ~/workspace/personal
    mkdir ~/workspace/work

    echo '' >> ~/.gitconfig
    echo '[core]' >> ~/.gitconfig
    echo ' editor = code --wait' >> ~/.gitconfig
    echo '[merge]' >> ~/.gitconfig
    echo ' ff = only' >> ~/.gitconfig
    echo '[user]' >> ~/.gitconfig
    echo " name = $NAME" >> ~/.gitconfig
    echo '[includeIf "gitdir:~/workspace/work/"]' >> ~/.gitconfig
    echo ' path = ~/.gitconfig-work' >> ~/.gitconfig
    echo '[includeIf "gitdir:~/workspace/personal/"]' >> ~/.gitconfig
    echo ' path = ~/.gitconfig-personal' >> ~/.gitconfig
    echo '' >> ~/.gitconfig

    echo '' >> ~/.gitconfig-personal
    echo '[user]' >> ~/.gitconfig-personal
    echo " email = $PERSONAL" >> ~/.gitconfig-personal
    echo '' >> ~/.gitconfig-personal

    echo '' >> ~/.gitconfig-work
    echo '[user]' >> ~/.gitconfig-work
    echo " email = $WORK" >> ~/.gitconfig-work
    echo '' >> ~/.gitconfig-work


    sudo apt-get install -y git gitk

    echo '' >> ~/.bashrc
    echo 'force_color_prompt=yes' >> ~/.bashrc
    echo 'color_prompt=yes' >> ~/.bashrc
    echo 'parse_git_branch() {' >> ~/.bashrc
    echo ' git branch 2> /dev/null | sed -e '\''/^[^*]/d'\'' -e '\''s/* \(.*\)/(\\1)/'\'' ' >> ~/.bashrc
    echo '}' >> ~/.bashrc
    echo 'if [ "$color_prompt" = yes ]; then' >> ~/.bashrc
    echo ' PS1='\''${debian_chroot:+($debian_chroot)}\[\\033[01;32m\]\u@\h\[\\033[00m\]:\[\\033[01;34m\]\w\[\\033[01;31m\]$(parse_git_branch)\[\\033[00m\]\$ '\'' ' >> ~/.bashrc
    echo 'else' >> ~/.bashrc
    echo ' PS1='\''${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '\'' ' >> ~/.bashrc
    echo 'fi' >> ~/.bashrc
    echo 'unset color_prompt force_color_prompt' >> ~/.bashrc
    echo '' >> ~/.bashrc
    }

    install_java(){
    rm -rf ~/.m2

    sudo apt-get install -y openjdk-11-jdk maven
    mkdir ~/.m2
    mkdir ~/.m2/repository

    echo '<?xml version="1.0" encoding="UTF-8"?>' >> ~/.m2/settings.xml
    echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" ' >> ~/.m2/settings.xml
    echo ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">' >> ~/.m2/settings.xml
    echo " <localRepository>/home/$USER/.m2/repository</localRepository>" >> ~/.m2/settings.xml
    echo ' <pluginGroups>' >> ~/.m2/settings.xml
    echo ' </pluginGroups>' >> ~/.m2/settings.xml
    echo ' <proxies>' >> ~/.m2/settings.xml
    echo ' </proxies>' >> ~/.m2/settings.xml
    echo ' <servers>' >> ~/.m2/settings.xml
    echo ' </servers>' >> ~/.m2/settings.xml
    echo ' <mirrors>' >> ~/.m2/settings.xml
    echo ' </mirrors>' >> ~/.m2/settings.xml
    echo ' <profiles>' >> ~/.m2/settings.xml
    echo ' </profiles>' >> ~/.m2/settings.xml
    echo '</settings>' >> ~/.m2/settings.xml
    }

    install_node() {
    rm -rf ~/.npm-global

    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    sudo apt-get install -y nodejs
    sudo apt-get install gcc g++ make
    mkdir ~/.npm-global
    npm config set prefix '~/.npm-global'
    echo '' >> ~/.bashrc
    echo 'PATH=~/.npm-global/bin:$PATH' | tee -a ~/.bashrc
    echo '' >> ~/.bashrc

    npm install -g npm@latest-6
    npm install -g @angular/cli
    }

    install_intellij(){
    wget https://download.jetbrains.com/idea/ideaIU-2021.2.2.tar.gz
    sudo tar -xzf ideaIU-2021.2.2.tar.gz -C /opt

    echo '' >> ~/.bashrc
    echo 'PATH=/opt/idea-IU-212.5284.40/bin:$PATH' | tee -a ~/.bashrc
    echo '' >> ~/.bashrc
    }

    install_terraform(){
    sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
    curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
    sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
    sudo apt-get update && sudo apt-get install terraform
    }

    create_sh_key() {
    rm ~/.ssh/id_rsa
    ssh-keygen -b 4096 -t rsa -P "" -C "$NAME" -f ~/.ssh/id_rsa
    }

    clean() {
    sudo apt update
    sudo apt upgrade -y
    sudo apt autoremove -y
    }


    init
    install_common_utils
    install_git
    install_java
    install_node
    install_intellij
    install_terraform
    create_sh_key
    clean