Search code examples
bashmacosshellterminal

Check if an app is installed on macOS using the Terminal


I'm making a small cross-platform CLI tool in TypeScript/NodeJs. Its key feature requires that it needs to check which browsers are installed on the host. On Linux and Windows, it works flawlessly. I did a lot of research on how I can achieve that and currently I'm using "reg query" for Windows and "which" for Unix-based OS - Linux, but I don't know where to start with macOS.

I know it's a Unix-like OS but I can't test my tool. Can someone please help me because I don't physically own a MacBook so I cannot test which bash command should I use. I'm not asking you to write the complete code, just which command(s) to use or even better, a working example (screenshot) of the command that works properly. I know I could use "which", "type" or even "open -Ra" (not sure about this one) I just don't know what's their output.


Solution

  • The command:

    mdfind "kMDItemKind == 'Application'"
    

    will output a list of installed Apps on the system (one per line) with their paths. E.g.:

    /Applications/Safari Technology Preview.app
    /Applications/Safari.app

    You can search your supported browsers in this list.