summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2019-01-23 20:56:07 +0300
committerDominik Ritter <dritter03@googlemail.com>2019-01-23 20:56:07 +0300
commitbde4337992e01738e72ef589c321299193580838 (patch)
treee6f87cb51c043931e93896a4d174e12283258431 /powerlevel9k.zsh-theme
parent54a985cb11861f3857daa7001558f015d971dc3d (diff)
Match VPN Interface fuzzy
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme22
1 files changed, 19 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 7437fe32..081562b5 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -600,9 +600,25 @@ prompt_public_ip() {
# Check VPN is on if VPN interface is set
if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then
if [[ "$OS" == "OSX" ]]; then
- local interface="$(${ROOT_PREFIX}/sbin/ifconfig $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE)"
- # Check if interface is UP.
- [[ "$interface" =~ "<UP," ]] && icon='VPN_ICON'
+ # Get a plain list of all interfaces
+ local rawInterfaces="$(${ROOT_PREFIX}/sbin/ifconfig -l)"
+ # Parse into array (split by whitespace)
+ local -a interfaces
+ interfaces=(${=rawInterfaces})
+ # Parse only relevant interface names
+ local pattern="${POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE}[^ ]?"
+ local -a relevantInterfaces
+ for rawInterface in $interfaces; do
+ [[ "$rawInterface" =~ $pattern ]] && relevantInterfaces+=( $MATCH )
+ done
+ for interfaceName in $relevantInterfaces; do
+ local interface="$(${ROOT_PREFIX}/sbin/ifconfig $interfaceName)"
+ # Check if interface is UP.
+ if [[ "$interface" =~ "<UP," ]]; then
+ icon='VPN_ICON'
+ break
+ fi
+ done
else
local interface=$(${ROOT_PREFIX}/sbin/ip -brief -4 a show "${POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE}")
[[ -n "$interface" ]] && icon='VPN_ICON'