Turn Bluetooth On & Off via Terminal [duplicate]

I'm trying to find out how to turn Bluetooth On or Off by using the Terminal on macOS Catalina.

I used to be able to do it with the following commands:

alias bton="sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1"
alias btoff="sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \sudo killall -HUP blued"

Unfortunately these no longer work.


Blueutil, a command-line utility for macOS that lets us turn Bluetooth on and off with one command!

Start by installing blueutil with HomeBrew:

brew install blueutil

The -p flag is a switch for turning Bluetooth on and off:

Turn bluetooth off

blueutil -p 0

Turn bluetooth on

blueutil -p 1