run Mac Chrome with command line arguments as a background process
Put an ampersand on the end of the commandline.
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome &"
If you also don't want to see any of the debugging chrome outputs, redirect stdout and stderr to /dev/null
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 2>&1 > &"
On Mac, you can make this even simpler:
alias chrome="open /Applications/Google\ Chrome.app/ --args --disable-web-security"
Your second requirement makes this slightly trickier though. The & needs to be at the end of the commandline; but your second alias adds commands to the end of the first command - ie, after the ampersand - and so this doesn't work.
To get around this, we can redefine 'chrome' as a function.
chrome () { /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $* 2>&1 &}
The $*
means that any commandline parameters passed to the function will be inserted here, before the ampersand. This means you can still define your second alias as
alias chromex="chrome --disable-web-security"
This will be expanded out to
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security 2>&1 &
BTW, this is just referred to as running "in the background". "As a daemon" would refer to a server process that runs whenever the machine is turned on, and is not tied to any user's session.
I defined alias on my .zshr (same for .bash_profile) like this:
open_by_browser(){ open -a $1 $2}alias firefox='open_by_browser firefox'alias chrome='open_by_browser "Google Chrome"'
then I can open html file by Firefox or Chrome
for example, by Firefox
firefox xxx/index.html
by Chrome
chrome xxx/index.html