I am trying to connect and pair a Bluetooth device from the command line. I can do it over the GUI using the standard process but I am looking to automate the whole process.

I am looking for commands that can be executed in a shell script to connect to the Bluetooth device. Just like Linux has "hcitool", "pand" commands, I am trying to find equivalent commands for macOS.

How can I accomplish this?


This seems a little bit "hacky", but you can do this by using an oascript which emulates the GUI-interactions needed for connecting: https://stackoverflow.com/a/23018886/5269642

I couldn't really find any documented API's for bluetooth unfortunately, the oascript-approach was the best I could find/think of so far.


The tool blueutil uses private APIs from the IOBluetooth framework to interact with bluetooth devices. You are able to list recent devices using:

blueutil --recent

and connect to a specific device using:

blueutil --connect $device_adress

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .