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

Also rely less on global options.
Fixes #1213.
Not sure if this is an improvement?