aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2018-07-18 23:17:54 +0300
committerDominik Ritter <dritter03@googlemail.com>2018-07-18 23:17:54 +0300
commit43272410c90e41affd20afa3110c519e1bd8bada (patch)
tree6583a3486ab95a6fe4e2dd3c98f3793e8f19ac7d /powerlevel9k.zsh-theme
parenta7576074760eb773b2f7bbdfdad56f7dadae296c (diff)
Change ip segment so that the tests can be executed on OSX as well
Change regular expressions to a more compatible format.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme10
1 files changed, 6 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 2e645f0a..1c9194f7 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1088,18 +1088,20 @@ prompt_ip() {
else
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.]*")
+ ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+")
else
local interfaces callback
# 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]*")
- callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-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 -E "[0-9.]+"'
ip=$(getRelevantItem "$interfaces" "$callback")
fi
fi
- "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
+ if [[ -n "$ip" ]]; then
+ "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
+ fi
}
################################################################