How to change default app to open magnet:// link without using a third-party UI app? How to change default app to open magnet:// link without using a third-party app?

I knew I maybe could use RCDefaultApp to do it but I am trying to figure out how to do it without installation of another app. Thanks a lot.
I found one solution after posting the question. A command line tool duti has a live github repo and can be installed easily with: 

brew install duti


And then, check the current magnet:// link setup:

$ duti -d magnet
com.bittorrent.uTorrent


Change and set another default app with the following cmd:

$ duti -s com.foo.foo magnet


That's all.

MORE:

To get a bundle_id of the app, there are two ways:


If you know the app is a default app for an extension, you can do something like


$ duti -x html
Google Chrome.app
/Applications/Google Chrome.app
com.google.Chrome



If you know the app name, you can do something like


$ osascript -e 'id of app "Google Chrome"'
com.google.Chrome