0

I would like to add an app to my dock via a command. I'm able to add an icon to the dock when there are no blanks in the path. I get an error message when I have a blank in the path.

The command syntax came from jonn8's post here:

https://macscripter.net/viewtopic.php?id=13548

works:

mac $ defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Users/mac/Downloads/Yahoo/YahooWeather.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
mac $ 

note: You need to restart the dock to see the change.

fails. I tried various forms of the command:

mac $ defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString' '/Users/mac/Downloads/Yahoo News, Send & Weather2/YahooWeather.app/''_CFURLStringType0'

2019-02-20 14:30:36.132 defaults[10804:2010845] Could not parse: tile-datafile-data_CFURLString. Try single-quoting it.

mac $ defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo\ News,\ Send\ \&\ Weather2/YahooWeather.app/_CFURLStringType0'

2019-02-20 14:31:45.327 defaults[10807:2011376] Could not parse: tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo\ News,\ Send\ \&\ Weather2/YahooWeather.app/_CFURLStringType0. Try single-quoting it.

mac $ defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo\ News\,\ Send\ \&\ Weather2/YahooWeather.app/_CFURLStringType0'

2019-02-20 14:33:01.617 defaults[10810:2011938] Could not parse: tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo\ News\,\ Send\ \&\ Weather2/YahooWeather.app/_CFURLStringType0. Try single-quoting it.

mac $ defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo%20News,%20Send%20&%20Weather2/YahooWeather.app/_CFURLStringType0'

2019-02-20 14:34:31.043 defaults[10815:2012590] Could not parse: tile-datafile-data_CFURLString/Users/mac/Downloads/Yahoo%20News,%20Send%20&%20Weather2/YahooWeather.app/_CFURLStringType0. Try single-quoting it.

Yet when I drag an app with blanks in the name I get via:

defaults read com.apple.dock

 autohide = 0;
    largesize = 66;
    "last-messagetrace-stamp" = "571873654.853677";
    magnification = 1;
    "minimize-to-application" = 0;
    "mod-count" = 732;
    orientation = bottom;
    "persistent-apps" =     (
                {
            GUID = 1620538228;
            "tile-data" =             {
                "bundle-identifier" = "com.apple.ScriptEditor.id.YahooWeather";
                "dock-extra" = 0;
                "file-data" =                 {
                    "_CFURLAliasData" = <00000000 00e80003 00010000 d876e512 0000482b 00000000 00208447 00208474 0000d872 b3e50000 00000920 fffe0000 00000000 0000ffff ffff0001 00100020 84470014 5ea40013 f6360000 0078000e 00220010 00590061 0068006f 006f0057 00650061 00740068 00650072 002e0061 00700070 000f001c 000d004d 00610063 0069006e 0074006f 00730068 00200053 00530044 0012003f 55736572 732f6d61 632f446f 776e6c6f 6164732f 5961686f 6f204e65 77732c20 53656e64 20262057 65617468 65722f59 61686f6f 57656174 6865722e 61707000 00130001 2f000015 0002000a ffff0000>;
                    "_CFURLString" = "file:///Users/mac/Downloads/Yahoo%20News,%20Send%20&%20Weather/YahooWeather.app/";
                    "_CFURLStringType" = 15;
                };
                "file-label" = YahooWeather;
                "file-mod-date" = 3633311607;
                "file-type" = 41;
                "parent-mod-date" = 3633311607;
            };
            "tile-type" = "file-tile";
        },
  • Just wondering, why not launch the app and select keep in dock? – Sam Feb 21 at 4:44
  • I was hoping to do everything from the command line. But yours is a good suggestion. I forgot about this possibility. Can I issue this selection from the command line? – historystamp Feb 21 at 6:25
1

I recommend using dockutil for this. You can either download and install this directly from github, or you can install it using Homebrew with the command

brew install dockutil

Once installed, you can use a command like this to add an app with spaces in the path

dockutil --add '/Users/mac/Downloads/Yahoo News, Send & Weather2/YahooWeather.app'

You must log in to answer this question.

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