mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-18 21:41:57 +00:00
Change ip segment so that the tests can be executed on OSX as well
Change regular expressions to a more compatible format.
This commit is contained in:
parent
a757607476
commit
43272410c9
1 changed files with 6 additions and 4 deletions
|
@ -1088,18 +1088,20 @@ prompt_ip() {
|
||||||
else
|
else
|
||||||
if defined POWERLEVEL9K_IP_INTERFACE; then
|
if defined POWERLEVEL9K_IP_INTERFACE; then
|
||||||
# Get the IP address of the specified interface.
|
# Get the IP address of the specified interface.
|
||||||
ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*")
|
ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+")
|
||||||
else
|
else
|
||||||
local interfaces callback
|
local interfaces callback
|
||||||
# Get all network interface names that are up
|
# Get all network interface names that are up
|
||||||
interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o "[a-z0-9]*")
|
interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o -E "[a-z0-9]+")
|
||||||
callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*"'
|
callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+"'
|
||||||
|
|
||||||
ip=$(getRelevantItem "$interfaces" "$callback")
|
ip=$(getRelevantItem "$interfaces" "$callback")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ip" ]]; then
|
||||||
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
|
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
Loading…
Reference in a new issue