Setting up system-wide AD on Windows makes it easier to execute commands from anywhere. If you are a Mac user, you are not out of luck as you can set up global ADB by adding an ADB variable environment. Typically, ADB and Fasboot commands work only when they are used with the path of the drivers otherwise you might encounter the ‘ADB command not found‘ error in the Terminal. Fortunately, there’s an easy way to add ADB to a path on Mac by setting up the PATH variable in the bash profile and enabling universally present ADB and Fastboot.
Dragging the ‘Platform-tools’ folder to the Mac Terminal opens ADB with the folder path. However, if you set up global ADB by adding Platform tools to a path via a Bash profile in the Mac Terminal, you can run ADB commands from any screen.
Must Read: 300 Mac Keyboard Shortcuts You Must Know
Set up ADB Path in Mac Terminal Bash Profile
To enjoy global access to the ADB and Fastboot command-line tools right after launching the Mac Terminal.
- Download the latest Android SDK Platform-tools that contain ADB and Fastboot drivers for Mac. Extract the downloaded zip to get a folder named ‘platform-tools‘.
- Now open the Home directory on your Mac. If you don’t know how to do that, there are 3 ways to open it.
- Create a new folder called ‘android-sdk-macosx‘ in the Home directory. You can rename it as ‘ADB’ or ‘AndroidSDK’ too if you want.
- Now, right-click the ‘platform-tools‘ folder icon and select the Copy “platform-tools” option from the context menu.
- Paste the ‘platform-tools‘ folder into the new folder you created. You can move this folder to any other location where you won’t accidentally delete them. I moved it to the root of my Macbook Pro’s storage.
- Launch the Mac Terminal app from Finder > Go > Utilities.
- When the Terminal is open, type the following command and press Enter. To avoid typo mistakes, simply copy and paste the command into the Terminal window. Just make sure to use the correct path of the ‘platform-tools‘ folder in the command line. You can easily copy the folder path on Mac using the tips in my guide.
echo 'export PATH=$PATH:~/android-sdk-macosx/platform-tools/' >> ~/.bash_profile
- In case you moved ‘platform-tools’ to the Home directory, you can use the following command after replacing the username with yours.
echo 'export PATH=$PATH:~/Users/rakeshshukla/platform-tools/' >> ~/.bash_profile
- Now that the ADB PATH variable has been added to your bash profile, you need to reload it using the following command. Alternatively, you can close the Terminal window and re-launch it.
source ~/.bash_profile
- If you want to check the current value of the PATH variable, you can use the following command. Otherwise, skip to the next step.
echo $PATH
- Since you have already added ADB to Path on your Mac, you can start using ADB or Fastboot commands. It’s time to verify that you have set up ADB properly on your Mac. Just type
adb
oradb devices
in the Terminal and hit the Enter key. - In case you get the ‘adb: command not found‘ error on your Mac, you might have made a mistake. Try the steps given above again more carefully.
Add Terminal Shortcut to Platform-Tools
Finally, here’s the easiest method to add any folder path to the Mac terminal. Just follow the tip described below to get rid of typing the ‘platform-tools‘ folder path in the Mac Terminal every time you have to use ADB and Fastboot commands. It doesn’t provide global or system-wide ADB support as the above method does.
- Open System Preferences on your Mac.
- Click on Keyboard.
- On the next screen, click on Shortcuts and select Services from the left pane.
- Now, look for Files and Folders in the right pane and enable New Terminal at Folder.
- The shortcut will be added to the folder context menu. You can close the System Preferences window.
- Right-click the ‘platform-tools‘ folder icon and select the New Terminal at Folder option.
- When the Terminal window launches, run any ADB and Fastboot command directly without typing the folder path.
If you want to learn more about ADB and Fastboot, read my tutorial describing some more ways to install ADB and fastboot on Mac. You should also check out these ADB Shell commands and other stuff you can do on your Android device with ADB.