MacOS – how to use terminal to remove item from dock

dockmacosscriptterminalui

Hi I have a shell script in my login item , which runs whenever i log in to my system . It does work completely but once it exits the terminal , it leaves the terminal shortcut on my dock and I don't want that I want my dock to be clean and want only my required application in it.Is there any command which I can keep at the end of my script so that once the script executes completely it also remove terminal from my dock.

Best Answer

Try to run the script with launchd instead. Save a property list like this as ~/Library/LaunchAgents/some.label.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>some.label</string>
  <key>Program</key>
  <string>/path/to/script</string>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

It should run the script the next time you log in. Make sure the script is executable (chmod +x /path/to/script) and starts with a hashbang line (like #!/usr/bin/env bash).