How to make macOS open RAR archive in Terminal using unrar on double-click? I want to make macOS open RAR files: On double-click macOS should open Terminal with command unrar x /path/filename.rar

Is there any way to do this?
Launch Automator.app and create a new Application.

Add the "Run Shell Script" action. As unrar seems to be a command installed in /usr/local/bin/, set the Shell type to /bin/bash, and Pass input to as arguments.

You'll be given a free bit of shell code, which you can easily modify:

for f in "$@"
do
    /usr/local/bin/unrar x "$f"
done


Save the app. Then select a .rar file, choose File > Get Info, and change the default handler for that type to your new app. 

Alternatively, there are plenty of third-party apps that unwrap rar and other archive types, such as TheUnarchiver.