Some applications lack the option to only display a menu bar icon rather than a dock icon. Luckily, you can force some of these icons to be hidden from the dock. Here’s how.
How to Hide Dock Icons
For this example, we will hide an application that everyone has installed by default on their Mac, the Safari web browser. There are several ways to do this, but we will be focusing on the most simple method: using the “defaults” command to edit the app’s “Info.plist” file.
To do this, we are first going to pop open a fresh instance/window of Terminal (found in Applications > Utilities).
Since modifying the “Info.plist” file usually requires elevated privileges, issue the following command, authenticating with your password (or Touch ID) when prompted:
sudo defaults write /Applications/Safari.app/Contents/Info LSUIElement -bool yes
After executing the command, restart the application and voilà! it will be hidden from view while still running in the background. But what if you want to undo the changes you’ve made? All you need to do to accomplish this is change the last word of the command from “yes” to “no” as shown in the command below:
sudo defaults write /Applications/Safari.app/Contents/Info LSUIElement -bool no
Then use the following command to kill Safari’s process:
killall Safari
Upon re-opening Safari, you will see it shown in your Mac dock as is expected by default!
If you want to hide a different app, you need only edit the path. So instead of:
/Applications/Safari.app/Contents/Info
You might hide Slack instead with:
/Applications/Slack.app/Contents/Info
Why Hide Dock Icons?
Depending on how you use your Mac, there may be some apps that you prefer to always have running. Maybe in your case, this is something like a remote desktop server or a program that needs to be open to receive hotkeys, automation, or shortcut commands.
If one of these lacks the option to show a menu bar icon in lieu of a dock icon, this can result in your dock bearing unnecessary clutter. Clean things up by hiding the icon using the command above!
Keep in mind that some apps may be programmed specifically to resist their dock icons being affected in this way but most apps can be hidden in this manner.