powerlevel9k icon indicating copy to clipboard operation
powerlevel9k copied to clipboard

No nmcli in MacOS Sierra

Open joeqread opened this issue 10 years ago • 4 comments

In your documentation, you reference using nmcli for wifi status. This does not exist in MacOS.

While nmcli will work for almost everything else, here's a working example for MacOS Sierra (and previous versions down to Yosemite I believe)

POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow"

zsh_wifi_signal(){
        local output=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I) 
        local airport=$(echo $output | grep 'AirPort' | awk -F': ' '{print $2}')

        if [ "$airport" = "Off" ]; then
                local color='%F{yellow}'
                echo -n "%{$color%}Wifi Off"
        else
                local ssid=$(echo $output | grep ' SSID' | awk -F': ' '{print $2}')
                local speed=$(echo $output | grep 'lastTxRate' | awk -F': ' '{print $2}')
                local color='%F{yellow}'

                [[ $speed -gt 100 ]] && color='%F{green}'
                [[ $speed -lt 50 ]] && color='%F{red}'

                echo -n "%{$color%}$ssid $speed Mb/s%{%f%}" # removed char not in my PowerLine font 
        fi
}

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status battery custom_wifi_signal time)

joeqread avatar Sep 24 '16 18:09 joeqread

@joeqread - Awesome! Thanks so much for putting this together!

Would you be willing to submit this as a new segment in a Pull Request? I would be happy to merge it in.

bhilburn avatar Sep 28 '16 14:09 bhilburn

Hey @joeqread - I added this to the wiki! Thanks for sharing =)

bhilburn avatar Oct 26 '16 17:10 bhilburn

@joeqread - Thanks!

romenigld avatar Jan 03 '19 12:01 romenigld

I can not see nmcli for Mac OS Catalina

aakashsingh90 avatar Apr 07 '20 06:04 aakashsingh90