Skip to content

Instantly share code, notes, and snippets.

@buxtonpaul
Created May 14, 2020 15:10
Show Gist options
  • Save buxtonpaul/2074bc4c56f53cf37a27e3d59ca7a29b to your computer and use it in GitHub Desktop.
Save buxtonpaul/2074bc4c56f53cf37a27e3d59ca7a29b to your computer and use it in GitHub Desktop.
Quick'n'dirty python script to create the display variable for use with WSL2
#!/usr/bin/python3
import os
for line in os.popen('ipconfig.exe'):
if not line[0] in [' ', '\n']:
current_section = line
active = False
if 'Link-local IPv6 Address' in line:
active = True
if 'IPv4 Address' in line and active and not 'vEthernet' in current_section:
vals = line.split(':')
print(vals[-1].strip()+":0")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment