osx - How to create an alias in MAC OS that can open a URL in terminal? -


i made alias that

zsh

alias google="open https://www.google.com/s\?wd\=" 

and then

$ source ~/.zshrc $ google test 

but chrome has not been called , prints

the file /users/a2014/test not exist 

so , how can write alias , call google cli ?

you cannot aliases, because there no way concatenate argument test whatever came alias expansion. final command line is:

open https://www.google.com/s\?wd\= test 

(notice space before test), asks os x open https://www.google.com/s\?wd\= , test respective default applications.

use function instead:

google() {   open "https://www.google.com/search?q="$1 } google test # => opens https://www.google.com/search?q=test 

Comments