mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Use the new defined
function to test if a network interface was specified.
This commit is contained in:
parent
0f30504362
commit
b8b82eee21
1 changed files with 8 additions and 8 deletions
|
@ -579,28 +579,28 @@ prompt_icons_test() {
|
||||||
|
|
||||||
prompt_ip() {
|
prompt_ip() {
|
||||||
if [[ "$OS" == "OSX" ]]; then
|
if [[ "$OS" == "OSX" ]]; then
|
||||||
if [[ -z "$POWERLEVEL9K_IP_INTERFACE" ]]; then
|
if defined POWERLEVEL9K_IP_INTERFACE; then
|
||||||
|
# Get the IP address of the specified interface.
|
||||||
|
ip=$(ipconfig getifaddr $POWERLEVEL9K_IP_INTERFACE)
|
||||||
|
else
|
||||||
local interfaces callback
|
local interfaces callback
|
||||||
# Get network interface names ordered by service precedence.
|
# Get network interface names ordered by service precedence.
|
||||||
interfaces=$(networksetup -listnetworkserviceorder | grep -o "Device:\s*[a-z0-9]*" | grep -o -E '[a-z0-9]*$')
|
interfaces=$(networksetup -listnetworkserviceorder | grep -o "Device:\s*[a-z0-9]*" | grep -o -E '[a-z0-9]*$')
|
||||||
callback='ipconfig getifaddr $item'
|
callback='ipconfig getifaddr $item'
|
||||||
|
|
||||||
ip=$(getRelevantItem $interfaces $callback)
|
ip=$(getRelevantItem $interfaces $callback)
|
||||||
else
|
|
||||||
# Get the IP address of the specified interface.
|
|
||||||
ip=$(ipconfig getifaddr $POWERLEVEL9K_IP_INTERFACE)
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -z "$POWERLEVEL9K_IP_INTERFACE" ]]; then
|
if defined POWERLEVEL9K_IP_INTERFACE; then
|
||||||
|
# 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.]*")
|
||||||
|
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 "[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 "[0-9.]*"'
|
||||||
|
|
||||||
ip=$(getRelevantItem $interfaces $callback)
|
ip=$(getRelevantItem $interfaces $callback)
|
||||||
else
|
|
||||||
# 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.]*")
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue