mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-16 17:50:09 +00:00
Match VPN interface fuzzy on Linux
This commit is contained in:
parent
bde4337992
commit
747b94b1b6
2 changed files with 18 additions and 2 deletions
|
@ -620,8 +620,15 @@ prompt_public_ip() {
|
|||
fi
|
||||
done
|
||||
else
|
||||
local interface=$(${ROOT_PREFIX}/sbin/ip -brief -4 a show "${POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE}")
|
||||
[[ -n "$interface" ]] && icon='VPN_ICON'
|
||||
local -a interfaces
|
||||
interfaces=( "${(f)$(${ROOT_PREFIX}/sbin/ip -brief -4 a show)}" )
|
||||
local pattern="^${POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE}[ ]+UP[ ]+"
|
||||
for interface in "${(@)interfaces}"; do
|
||||
if [[ "$interface" =~ $pattern ]]; then
|
||||
icon='VPN_ICON'
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
$1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon"
|
||||
|
|
|
@ -113,6 +113,15 @@ function fakeIp() {
|
|||
INNER
|
||||
fi
|
||||
|
||||
if [[ "\$*" =~ '-brief.*show' ]]; then
|
||||
cat <<INNER
|
||||
lo UNKNOWN 127.0.0.1/8
|
||||
${INTERFACE1} UP 1.2.3.4/24
|
||||
${INTERFACE2} UP 5.4.3.2/16
|
||||
docker0 DOWN 172.17.0.1/16
|
||||
INNER
|
||||
fi
|
||||
|
||||
if [[ "\$*" =~ 'show ${INTERFACE1}' ]]; then
|
||||
cat <<INNER
|
||||
3: ${INTERFACE1}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
|
|
Loading…
Reference in a new issue