aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorShini31 <github@capitoul.net>2018-12-30 13:26:04 +0300
committerShini31 <github@capitoul.net>2018-12-30 13:26:04 +0300
commita8fa0332d28713ad43b9258ad9b7cf0e3de8e1fb (patch)
tree858dd4db1ebfe8c0860c03a9baa0bf845dad556e /powerlevel9k.zsh-theme
parent2f4b15041fe31d85dc9ef705b818c3a0e6985da3 (diff)
Use ip command for VPN segment - fix #1125
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme36
1 files changed, 26 insertions, 10 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 79237385..65147c63 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -597,11 +597,19 @@ prompt_public_ip() {
icon='PUBLIC_IP_ICON'
# Check VPN is on if VPN interface is set
if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then
- for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1)
- do
- icon='VPN_ICON'
- break
- done
+ if [[ "$OS" == "OSX" ]]; then
+ for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1)
+ do
+ icon='VPN_ICON'
+ break
+ done
+ else
+ for vpn_iface in $(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
+ fi
fi
$1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon"
fi
@@ -1134,11 +1142,19 @@ prompt_ip() {
set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun"
# prompt if vpn active
prompt_vpn_ip() {
- for vpn_iface in $(/sbin/ifconfig | grep -e "^${POWERLEVEL9K_VPN_IP_INTERFACE}" | cut -d":" -f1)
- do
- ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2)
- "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON'
- done
+ if [[ "$OS" == "OSX" ]]; then
+ for vpn_iface in $(/sbin/ifconfig | grep -e "^${POWERLEVEL9K_VPN_IP_INTERFACE}" | cut -d":" -f1)
+ do
+ ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2)
+ "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON'
+ done
+ else
+ for vpn_iface in $(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o -E "[a-z0-9]+" | grep -o -E "^${POWERLEVEL9K_VPN_IP_INTERFACE}.*")
+ do
+ ip=$(/sbin/ip -4 a show "$vpn_iface" | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+")
+ "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON'
+ done
+ fi
}
################################################################