Andrea Mastrangelo
Andrea Mastrangelo

Reputation: 1

wsl2 DISPLAY variable on windows host

I use windows 10 and WSL2. To run linux applications on the X server hosted by the windows machine, I use the second command: export WSL_HOST_IP=$( cmd.exe /C netsh interface ip show addresses "vEthernet (WSL)" | grep "IP Address" | sed -e "s/\sIP Address:\s//g" ) and it works:

echo $WSL_HOST_IP 172.20.48.1

how do i transform it into the DISPLAY variable? what I want to get is this: DISPLAY = $WSL_HOST_IP:0.0 but I can't write ": 0.0" in bash. Anyone help me? Thanks in advance

Upvotes: 0

Views: 1020

Answers (1)

Philippe
Philippe

Reputation: 26452

You need to remove DOS line ending with s/\r//:

export WSL_HOST_IP=$( cmd.exe /C netsh interface ip show addresses "vEthernet (WSL)" | grep "IP Address" | sed -e "s/\sIP Address:\s//g; s/\r//" )

Upvotes: 1

Related Questions