How to fully uninstall apps in macOS just using bash
This is bad form. First of all, we have a homebrew plug. homebrew makes a mess and...<p><i>Homebrew does not honor the default privileges of &#x2F;usr&#x2F;local; directory ownership is changed from root with group permissions for the wheel group to the installing user and the &quot;admin&quot; group. Specifically, the mode changes from drwxr-xr-x root wheel to drwxrwxr-x myuser admin. All files, not just the directories, have their ownership changed by the installer. This is considered by some as a major security flaw.</i>[1]<p>MacPorts is superior and it is what the pros use. Now enough of that.<p>OP&#x27;s method pays absolutely no attention to the BoM Receipts that every application installed with an installer will honor. This method doesn&#x27;t consult the BoM, and obviously leaves stuff lying around.<p>BoMs are found in &#x2F;var&#x2F;db&#x2F;receipts for all App Store installations and updates, and all other installations performed by the Installer app. macOS system, security, and security data updates have their BoMs stored in &#x2F;System&#x2F;Library&#x2F;Receipts<p>Below somewhere is a superior uninstaller script I picked up at some point.
First install the appropriate version of Xcode for your macOS version. Then install MacPorts package manager thusly:<p><pre><code>     curl -O https:&#x2F;&#x2F;distfiles.macports.org&#x2F;MacPorts&#x2F;MacPorts-2.7.2.tar.bz2

     tar xjvf MacPorts-2.7.2.tar.bz2
 
     cd MacPorts-2.7.2&#x2F;

     .&#x2F;configure
     make
     sudo make install #not war!
     cd ..
     sudo rm -rf Macports-*
     sudo &#x2F;opt&#x2F;local&#x2F;bin&#x2F;port -vs selfupdate
</code></pre>
Add this line to your ~&#x2F;.bash_profile<p><pre><code>     export PATH=$PATH:$HOME&#x2F;bin:&#x2F;opt&#x2F;local&#x2F;bin:&#x2F;opt&#x2F;local&#x2F;sbin:&#x2F;opt&#x2F;local&#x2F;share&#x2F;man:&#x2F;usr&#x2F;X11&#x2F;bin
</code></pre>
Then drop below in a file in your ~&#x2F;bin (or &#x2F;usr&#x2F;local&#x2F;bin if you want all users to have access), maybe call it &quot;uninstaller,&quot; and<p><pre><code>     chmod +x uninstaller
</code></pre>
--------------------------<p><pre><code>     #!&#x2F;bin&#x2F;bash

     #uninstall application installed with installer -pkg
     #using (user) provided bom receipt
     #place all installed files and directories in user&#x27;s Trash

     lsbom=&quot;&#x2F;usr&#x2F;bin&#x2F;lsbom&quot;
     cd=&quot;&#x2F;usr&#x2F;bin&#x2F;cd&quot;
     sudo=&quot;&#x2F;usr&#x2F;bin&#x2F;sudo&quot;
     xargs=&quot;&#x2F;usr&#x2F;bin&#x2F;xargs&quot;
     rmtrash=&quot;&#x2F;opt&#x2F;local&#x2F;bin&#x2F;rmtrash&quot;

     lsbom -fls &quot;$1&quot; | (cd &#x2F;; sudo xargs rmtrash -u $USER)
     exit</code></pre>
--------------------------<p>make sure to install rmtrash before using<p><pre><code>     sudo port -vsN install rmtrash

</code></pre>
To make this clearer, user must find the BoM receipt and the path to the BoM for whatever application for the input for this script. Again find BoMs in &#x2F;var&#x2F;db&#x2F;receipts or &#x2F;System&#x2F;Library&#x2F;Receipts<p>So, for e.g., say you&#x27;ve installed an application called Test.app. First find the $PATH to the correct BoM then call its path with the script.<p><pre><code>     uninstaller &#x2F;var&#x2F;db&#x2F;receipts&#x2F;com.somedeveloper.test.bom
</code></pre>
after entering password, this execution will uninstall <i>everything</i> that installer installed for Test.app because all those files are listed in the BoM, and it will move all files the Test.app installer installed into your Trash.<p>I think it is just nuts to use &#x2F;bin&#x2F;rm in a script like this, so rmtrash is a little cli utility that moves things into your Trash, rather than deleting immediately. Much safer. Also, my script does not rely on Spotlight (mdfind). No telling what mdfind will return. Use the Bill of Materials receipts to uninstall, not Spotlight. That&#x27;s crazy talk.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Homebrew_(package_manager)#Implementation" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Homebrew_(package_manager)#Imp...</a>