Setup Chrome alias macOS
Tried to open a link in the command line, but was unable to because terminal did not recognize
chrome as a registered binary to handle and open urls.
Tried to do this:
zsh: command not found: chrome
Ok, so I will fall back to the default handler for urls as specified by my macOS
That works, but as Safari is set to my default it opens with Safari which is not my intention. I need to add an alias that refers to
Chrome to handle urls when I specify. In macOS you can override what the
open command will use by the following command line parameter
-a Opens with the specified application.
Therefore I should do this to open
chrome from the command line
open -a 'Google Chrome' - Yes, that works as expected opening
Add the alias
Now add this as a permanent alias so I won't have to do this every time. In this case I want to alias
open -a 'Google Chrome' so the alias command is
alias chrome="open -a 'Google Chrome'". Remember the parenthesis for the command to be run as a single variable replacement on the command line.
Add this line to your preferred shell in my case this the trusty
.bashrc file at your home directory. You can get to this folder by
cd ~/ and then find it with
ls -la. I am also using
zsh so I add this alias to my
.zshrc profile file as well.
Reload the profile with the
source command and my designated profile file. For example
zsh would be
source ~/.zshrc and it works.