summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2015-08-26 20:56:49 +0300
committerDominik Ritter <dritter03@googlemail.com>2015-08-26 20:56:49 +0300
commit61daa647f11019be316f51c4ade4b2e76c450de1 (patch)
tree2e27d297c148b4bf14f6223abed8c526a23a6b4a /powerlevel9k.zsh-theme
parent730697893e4b9c06da74f5025fe9318f70a13fdc (diff)
IP is now customizable. By default we try to get the ip of `en1` (on OSX) and `eth0` on all other systems.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rw-r--r--powerlevel9k.zsh-theme17
1 files changed, 9 insertions, 8 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index f9b14c64..3142253b 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -558,15 +558,16 @@ prompt_icons_test() {
}
prompt_ip() {
- # TODO: Specify Interface by variable!
- if [[ "$OS" == "OSX" ]]; then
- # Try to get IP addresses from common interfaces.
- ip=$(ipconfig getifaddr en0 || ipconfig getifaddr en1)
- else
- # Take the first IP that `hostname -I` gives us.
- ip=$(hostname -I | grep -o "[0-9.]*" | head -n 1)
+ if [[ -z "$POWERLEVEL9K_IP_INTERFACE" ]]; then
+ if [[ "$OS" == "OSX" ]]; then
+ POWERLEVEL9K_IP_INTERFACE="en1"
+ else
+ POWERLEVEL9K_IP_INTERFACE="eth0"
+ fi
fi
- $1_prompt_segment "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') $ip"
+
+ ip=$(ifconfig $POWERLEVEL9K_IP_INTERFACE 2> /dev/null | grep -o "inet\s[0-9.]*")
+ $1_prompt_segment "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') ${ip#inet }"
}
prompt_load() {