How can I avoid the prompts when installing a FreeBSD port?

I think it's worth mentioning that you might not always want to do this. I seem to remember, for instance, needing to config emacs to add xft support. If you want to bypass the prompts for a single build,

make install clean BATCH=yes

will work as well.


Probably BATCH, described in ports(7), is what you're looking for:

# cd /usr/ports/sysutils/screen
# export BATCH=yes
# make rmconfig
# make install clean
(no configuration menu is displayed)

make rmconfig removes OPTIONS config for this port, and you can use it to remove OPTIONS which were previously saved when you configured and installed screen(1) the first time. OPTIONS are stored to directory which is specifed via PORT_DB_DIR (defaults to /var/db/ports).

If you use bash, BATCH can be set automatically every time you log in:

# echo 'export BATCH=yes' >> ~/.bash_profile

This doesn't automatically accept defaults like you're asking, but I like the "make config-recursive" method which runs you through any options for the port you want as well as options for all dependencies. You don't have to change anything if you don't want to, but you go through all selection screens at once rather than whenever the building process arrives at them.

Once that's done, your "make install clean" should go pretty much unattended.