According to the Homebrew installation instructions, the following command can be used to install:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
This works, but it needs user input two times; to confirm the install and in a sudo prompt invoked by the script:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
Homebrew doesn't have arguments for unattended installations, so the only option I can think of is to programatically input the expected data. I tried using expect
, but I can't quite get the syntax right:
$ expect -c 'spawn ruby -e \"\$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";expect "RETURN";send "\n"'
ruby: invalid option -f (-h will show valid options) (RuntimeError)
send: spawn id exp7 not open
while executing
"send "\n""
What am I doing wrong?
If you want to create a setup script which installs homebrew
silently then just pipe a blank echo
to the homebrew's installer. Then redirect the results to /dev/null
as @charles-duffy suggested.
#!/usr/bin/env bash
# install.sh
URL_BREW='https://raw.githubusercontent.com/Homebrew/install/master/install'
echo -n '- Installing brew ... '
echo | /usr/bin/ruby -e "$(curl -fsSL $URL_BREW)" > /dev/null
if [ $? -eq 0 ]; then echo 'OK'; else echo 'NG'; fi
$ ./install.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With