aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-11-09 15:49:08 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-11-09 15:49:08 +0300
commit39b2064a97b8069dd591554460f501884fe0cb1e (patch)
treed58f129576674f78475d61cd0c67889e316413b8 /internal/p10k.zsh
parentff305e3d45e75a4603de21699439c54589d27c08 (diff)
when ifconfig is not available, use ip; fixes #305
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh34
1 files changed, 23 insertions, 11 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index c4e45286..2a12f1d2 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -3428,17 +3428,29 @@ _p9k_preexec() {
function _p9k_set_iface() {
_p9k_iface=()
- [[ -x /sbin/ifconfig ]] || return
- local line
- local iface
- for line in ${(f)"$(/sbin/ifconfig 2>/dev/null)"}; do
- if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=(<->)'<'* ]]; then
- [[ $match[2] == *[13579] ]] && iface=$match[1] || iface=
- elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
- _p9k_iface[$iface]=$match[1]
- iface=
- fi
- done
+ if [[ -x /sbin/ifconfig ]]; then
+ local line
+ local iface
+ for line in ${(f)"$(/sbin/ifconfig 2>/dev/null)"}; do
+ if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=(<->)'<'* ]]; then
+ [[ $match[2] == *[13579] ]] && iface=$match[1] || iface=
+ elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
+ _p9k_iface[$iface]=$match[1]
+ iface=
+ fi
+ done
+ elif [[ -x /sbin/ip ]]; then
+ local line
+ local iface
+ for line in ${(f)"$(/sbin/ip -4 a show 2>/dev/null)"}; do
+ if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then
+ [[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface=
+ elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
+ _p9k_iface[$iface]=$match[1]
+ iface=
+ fi
+ done
+ fi
}
function _p9k_build_segment() {