
I have a number of external drives hanging off my laptop, but sometimes I want to disconnect them. I used to go into Finder and click the eject button but I have five drives now so that’s getting unwieldy.
There are a few different ways of doing this. I wrote a small BASH script based on information here.
I created a shell script on my Desktop, added the following, changing DRIVE to the volume path for each of my external drives:
osascript -e ‘do shell script “diskutil unmountDisk /Volumes/DRIVE”‘
After creating that script I made it executable with chmod +x and as I use iTerm2 as a terminal I associated .sh files with that (Finder, right click on script, Get Info->Open With).
Every time I double click the script a new tab opens in iTerm2 and I see the progress of the unmount commands!