Bug fixes: ~ completion

This fixes the ~ completion bug. Now you can tab with paths that start with a ~ and completion does the right thing.

Another small fix was not propagating the set flags from the command line into the shell.