Created
December 1, 2020 13:13
-
-
Save felipepodesta/22ab0bee27ebe7f786c603964f7ffd9b to your computer and use it in GitHub Desktop.
Config WSL
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
export ZSH="/home/dinh/.oh-my-zsh" | |
ZSH_THEME="agnoster" | |
plugins=(git) | |
source $ZSH/oh-my-zsh.sh | |
export PATH="$PATH:$HOME/.rvm/bin" | |
prompt_context() {} | |
export EDITOR='/usr/bin/vim' | |
alias gc.="git checkout ." | |
alias gcb="git checkout -b" | |
alias gdf="git diff --name-only" | |
alias gaa="git add -A" | |
alias rs="rails s" | |
alias rc="rails c" | |
alias gcm="git commit -m" | |
alias gca="git commit --amend --no-edit" | |
alias gco="git checkout" | |
alias gst="git status" | |
alias Log="git log" | |
alias gbm="git branch -m" | |
alias gitr="git reset --hard HEAD~" | |
alias rspec="bundle exec rspec" | |
alias rubocop="bundle exec rubocop" | |
alias remove="sudo apt-get --purge remove" | |
alias dbc="rake db:create" | |
alias dbd="rake db:drop" | |
alias dbr="rake db:reset" | |
alias dbm="rake db:migrate" | |
alias dbs="rake db:seed" | |
alias bi="bundle install" | |
alias biw="bundle install --without production" | |
function push() { | |
branch=$(git symbolic-ref --short HEAD) | |
git push origin $branch | |
} | |
function pull() { | |
branch=$(git symbolic-ref --short HEAD) | |
git pull origin $branch | |
} | |
if [[ $TERM == xterm ]]; then | |
export TERM=xterm-256color | |
fi | |
cd | |
# postgresql_status=`sudo service postgresql status` | |
# if [ "$postgresql_status" "=~" "down" ]; then postgresql_start=`sudo service postgresql start`; fi | |
# mysql_status=`sudo service mysql status` | |
# if [ "$mysql_status" "=~" "stopped" ]; then mysql_start=`sudo service mysql start`; fi |
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
#!/bin/bash | |
printf "Enter MySQL user's name: " | |
read mysql_user_name | |
printf "Enter MySQL user's password: " | |
read mysql_user_password | |
printf "Enter PostgreSQL user's password: " | |
read postgres_user_password | |
printf "Enter global git user's name: " | |
read git_name | |
printf "Enter global git user's email: " | |
read git_email | |
echo 'Config Git successfully!' | |
git config --global color.ui true &> /dev/null | |
git config --global user.name "$git_name" &> /dev/null | |
git config --global user.email "$git_email" &> /dev/null | |
ssh-keygen -t rsa -b 4096 -C "$git_email" -f ~/.ssh/id_rsa -q -P '' &> /dev/null | |
echo 'Installing MySQL...' | |
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev &> /dev/null | |
sudo service mysql stop &> /dev/null | |
sudo usermod -d /var/lib/mysql/ mysql &> /dev/null | |
sudo service mysql restart &> /dev/null | |
sudo mysql -uroot -e "CREATE USER '$mysql_user_name'@'%' IDENTIFIED BY '$mysql_user_password';" &> /dev/null | |
sudo mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" &> /dev/null | |
sudo mysql -uroot -e "FLUSH PRIVILEGES;" &> /dev/null | |
sudo mysql -uroot -e "DROP USER 'root'@'localhost';" &> /dev/null | |
echo "Completed!" | |
echo 'Installing PostgreSQL...' | |
sudo apt install -y postgresql libpq-dev &> /dev/null | |
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$postgres_user_password';" &> /dev/null | |
echo "Completed!" | |
echo 'Installing Ruby on Rails...' | |
sudo apt-get install -y libgdbm-dev libncurses5-dev automake libtool bison libffi-dev &> /dev/null | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB &> /dev/null | |
curl -sSL https://get.rvm.io | bash -s stable &> /dev/null | |
source ~/.rvm/scripts/rvm &> /dev/null | |
rvm install 2.6.5 &> /dev/null | |
rvm use 2.6.5 --default &> /dev/null | |
echo "gem: --no-document" >> ~/.gemrc &> /dev/null | |
gem install bundler &> /dev/null | |
gem install rails &> /dev/null | |
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.zshrc &> /dev/null | |
source ~/.zshrc &> /dev/null | |
echo "Completed! Ruby version: `ruby -v`, Rails version: `rails -v`" |
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
#!/bin/bash | |
echo -n 'Enter password: ' | |
read -s password | |
echo | |
sudo -k | |
if sudo -lS &> /dev/null << EOF | |
$password | |
EOF | |
then | |
clear | |
echo $password | sudo -S ls &> /dev/null | |
echo 'Installing Common Packages...' | |
sudo apt-get update &> /dev/null | |
sudo apt-get install -y curl git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev zsh vim &> /dev/null | |
echo "Completed!" | |
echo 'Installing NodeJs + Yarn...' | |
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - &> /dev/null | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - &> /dev/null | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list &> /dev/null | |
sudo apt-get update &> /dev/null | |
sudo apt-get install -y nodejs yarn &> /dev/null | |
echo "Completed! Yarn version: `yarn -v`, Node version: `node -v`" | |
echo 'Installing Expo...' | |
sudo npm -g install expo-cli --unsafe-perm=true &> /dev/null | |
echo "Completed! Expo version: `expo --version`" | |
echo 'Install Oh my ZSH...' | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
fi |
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
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '" | |
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'; | |
if( $found ){ | |
$remoteport = $matches[0]; | |
} else{ | |
echo "The Script Exited, the ip address of WSL 2 cannot be found"; | |
exit; | |
} | |
#[Ports] | |
#All the ports you want to forward separated by coma | |
$ports=@(80,443,10000,3000,5000,19000,19001,19002); | |
#[Static ip] | |
#You can change the addr to your ip config to listen to a specific address | |
$addr='192.168.0.103'; | |
$ports_a = $ports -join ","; | |
#Remove Firewall Exception Rules | |
iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' "; | |
#adding Exception Rules for inbound and outbound Rules | |
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP"; | |
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP"; | |
for( $i = 0; $i -lt $ports.length; $i++ ){ | |
$port = $ports[$i]; | |
iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; | |
iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport"; | |
} |
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
Import-Module posh-git | |
Import-Module oh-my-posh | |
Set-Theme Agnoster | |
del alias:gc -Force | |
del alias:gcb -Force | |
del alias:gcm -Force | |
del alias:gcs -Force | |
del alias:gl -Force | |
del alias:gm -Force | |
del alias:gp -Force | |
del alias:gpv -Force | |
function gc. { git checkout . $args } | |
function gcb { git checkout -b $args } | |
function gdf { git diff --name-only $args } | |
function gaa { git add -A $args } | |
function rs { rails s $args } | |
function rc { rails c $args } | |
function gcm { git commit -m $args } | |
function gca { git commit --amend --no-edit $args } | |
function gco { git checkout $args } | |
function gst { git status $args } | |
function Log { git log $args } | |
function gbm { git branch -m $args } | |
function gbD { git branch -D $args } | |
function gitr { git reset --hard HEAD~ $args } | |
function rspec { bundle exec rspec $args } | |
function rubocop { bundle exec rubocop $args } | |
function remove { sudo apt-get --purge remove $args } | |
function dbc { rake db:create $args } | |
function dbd { rake db:drop $args } | |
function dbr { rake db:reset $args } | |
function dbm { rake db:migrate $args } | |
function dbs { rake db:seed $args } | |
function bi { bundle install $args } | |
function biw { bundle install --without production $args } | |
function Push { git push origin $args } | |
function Pull { git pull origin $args } |
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
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}", | |
"copyOnSelect": true, | |
"copyFormatting": false, | |
"launchMode": "maximized", | |
"profiles": | |
{ | |
"defaults": | |
{ | |
"colorScheme" : "Material Palenight", | |
"cursorShape": "filledBox", | |
"fontFace": "Monaco for Powerline", | |
"fontSize": 12, | |
"backgroundImage": "https://www.pixel4k.com/wp-content/uploads/2019/03/wolf-hunting-prey-4k_1551641791.jpg", | |
"backgroundImageOpacity": 0.2, | |
"backgroundImageAlignment": "topRight" | |
}, | |
"list": | |
[ | |
{ | |
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"name": "Windows PowerShell", | |
"commandline": "powershell.exe", | |
"hidden": true | |
}, | |
{ | |
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", | |
"name": "Command Prompt", | |
"commandline": "cmd.exe", | |
"hidden": true | |
}, | |
{ | |
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", | |
"hidden": true, | |
"name": "Azure Cloud Shell", | |
"source": "Windows.Terminal.Azure" | |
}, | |
{ | |
"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}", | |
"hidden": false, | |
"name": "Ubuntu-18.04", | |
"source": "Windows.Terminal.Wsl", | |
"icon": "https://4.bp.blogspot.com/-bCJ2pj4tGQo/UGhsnQAWwvI/AAAAAAAAG68/petJuQ5Uznk/s1600/Ubuntu.png" | |
} | |
] | |
}, | |
"schemes": [ | |
{ | |
"name": "Material Palenight", | |
"background": "#292d3e", | |
"foreground": "#a6accd", | |
"black": "#000000", | |
"blue": "#82aaff", | |
"brightBlack": "#676e95", | |
"brightBlue": "#82aaff", | |
"brightCyan": "#89ddff", | |
"brightGreen": "#c3e88d", | |
"brightPurple": "#c792ea", | |
"brightRed": "#ff5370", | |
"brightWhite": "#ffffff", | |
"brightYellow": "#ffcb6b", | |
"cyan": "#89ddff", | |
"green": "#c3e88d", | |
"purple": "#c792ea", | |
"red": "#ff5370", | |
"white": "#ffffff", | |
"yellow": "#ffcb6b" | |
} | |
], | |
"keybindings": | |
[ | |
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" }, | |
{ "command": "paste", "keys": "ctrl+v" }, | |
{ "command": "find", "keys": "ctrl+shift+f" }, | |
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "ctrl+shift+d" } | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment