Skip to content

Instantly share code, notes, and snippets.

@mysiki
mysiki / update_windows_hosts_with_wsl_ip
Created August 28, 2020 16:27
Simple shell function for update windows hosts file with wsl IP. Can be put it in .bashrc
function wslhosts() {
vm_name="${1:-wsl}"
file_hosts="${2:-/mnt/c/Windows/System32/drivers/etc/hosts}"
wsl_ip=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
mkdir -p "$(dirname "${file_hosts}")" && touch "${file_hosts}"
grep -q " ${vm_name}" "${file_hosts}"
if [ $? -eq 1 ]; then
vagrant : INFO global: Vagrant version: 2.2.5
Au caractère Ligne:1 : 1
+ vagrant up --debug 2>&1 | Tee-Object -file vagrant-log-11073-run01.lo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( INFO global: Vagrant version: 2.2.5:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
INFO global: Ruby version: 2.4.6
INFO global: RubyGems version: 2.6.14.4
vagrant : INFO global: Vagrant version: 2.2.5
Au caractère Ligne:1 : 1
+ vagrant up afsvagrantn01t --debug 2>&1 | Tee-Object -FilePath ".\vag ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( INFO global: Vagrant version: 2.2.5:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
INFO global: Ruby version: 2.4.6
INFO global: RubyGems version: 2.6.14.4