From 1f17bd209445b7be0febbd733b8c299c8d309525 Mon Sep 17 00:00:00 2001 From: Josh Willox <39120423+jcwillox@users.noreply.github.com> Date: Wed, 23 Dec 2020 20:29:48 +1100 Subject: [PATCH] Add IP info --- src/posh-winfetch.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/posh-winfetch.ps1 b/src/posh-winfetch.ps1 index e1175b4..008eb14 100644 --- a/src/posh-winfetch.ps1 +++ b/src/posh-winfetch.ps1 @@ -428,6 +428,24 @@ function info_battery { } +# ===== IP ===== +function info_local_ip { + $indexDefault = Get-NetRoute -DestinationPrefix 0.0.0.0/0 | Sort-Object -Property RouteMetric | Select-Object -First 1 | Select-Object -ExpandProperty ifIndex + $local_ip = Get-NetIPAddress -AddressFamily IPv4 -InterfaceIndex $indexDefault | Select-Object -ExpandProperty IPAddress + return @{ + title = "Local IP" + content = $local_ip + } +} + +function info_public_ip { + return @{ + title = "Public IP" + content = (Resolve-DnsName -Name myip.opendns.com -Server resolver1.opendns.com).IPAddress + } +} + + # reset terminal sequences and display a newline Write-Host "$e[0m"