You can cmd-drag an item to the Finder toolbar to have it there permanently, but is there a way you do this in the Terminal?
The closest I've found is this old thread: http://macscripter.net/viewtopic.php?id=21344
Which suggests something like this:
defaults write com.apple.finder FXToolbarItems -array-add '<dict><key>file-data</key><dict><key>_CFURLString</key><string>"/Applications/Chess.app"</string><key>_CFURLStringType</key><integer>0</integer></dict></dict>'
killall -HUP Finder
.. or perhaps ...
defaults write com.apple.finder FXToolbarItems -array-add '<dict><key>file-data</key><dict><key>_CFURLString</key><string>"/Applications/Chess.app"</string><key>_CFURLStringType</key><integer>0</integer></dict><key>item-id</key><string>loc%20</string></dict>'
killall -HUP Finder
Neither seem to work. Is there something which works with Yosemite and above?
I notice that if I manually add the Chess app to the Finder toolbar, and then output the finder prefs like so:
defaults read com.apple.finder >> finderprefs
I can see it puts it in like so:
"TB Item Plists" = {
7 = {
"_CFURLAliasData" = <(lots of hex code)>;
"_CFURLString" = "file:///Applications/Chess.app";
"_CFURLStringType" = 15;
};
};
So I guess I need to find a way to do that with defaults write
More research suggests adding items programmatically is not advisable: http://prod.lists.apple.com/archives/cocoa-dev/2015/May/msg00212.html
If you know different, I'd love to know...