diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2019-01-23 03:02:42 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2019-01-23 03:02:42 +0300 |
commit | 54a985cb11861f3857daa7001558f015d971dc3d (patch) | |
tree | 684ba98e8d24edf9c7112587e28e428ba5b10317 /powerlevel9k.zsh-theme | |
parent | 480ade162bd6a99b5c71dab12579bf613da03715 (diff) |
Simplify code that checks if a VPN is running
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6902ed10..7437fe32 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -600,17 +600,12 @@ prompt_public_ip() { # Check VPN is on if VPN interface is set if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then if [[ "$OS" == "OSX" ]]; then - for vpn_iface in $(${ROOT_PREFIX}/sbin/ifconfig | grep -e "^$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) - do - icon='VPN_ICON' - break - done + local interface="$(${ROOT_PREFIX}/sbin/ifconfig $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE)" + # Check if interface is UP. + [[ "$interface" =~ "<UP," ]] && icon='VPN_ICON' else - for vpn_iface in $(${ROOT_PREFIX}/sbin/ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o -E "[a-z0-9]+" | grep -o -E "^$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE.*") - do - icon='VPN_ICON' - break - done + local interface=$(${ROOT_PREFIX}/sbin/ip -brief -4 a show "${POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE}") + [[ -n "$interface" ]] && icon='VPN_ICON' fi fi $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" |