Insert repl options at top of file based on user's choices.

Also rely less on global options.
Fixes #1213.
done