Most of the time Finder will show you multiple entries for each application when right clicking a file and choosing Open With. Getting rid of Open With duplicates gives us an alias to remove those duplicates. Below is not only the alias, but a one-line command to add the alias to your
~/.bash_profile. Just copy and paste it onto the shell and you’ll have the
fixopenwith alias available.
Above that the version below is a slightly improved version: not only will it rebuild the index, it’ll also relaunch Finder and open TotalFinder (if you have it installed) after having rebuilt the index.
echo "alias fixopenwith='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder && open /Applications/TotalFinder.app'" >> ~/.bash_profile
Once done, just call
fixopenwith and it’ll do it all automatically.
Note: also to be found in Mathias’ dotfiles, an exquisite resource I’ve been cherrypicking from lately 🙂