While it's possible for Beeline to do some initialization w/o a connection, such as set color or execute a shell command (
HIVE-6694), per my experience, init script for Hive is mostly used to control server behavior, such as loading jars or setting conf variables. Without a connection, these become meaningless.
Hive CLI doesn't have the issue because a connection always exist, either embedded "server" or a remote server. Beeline can be started w/o either an embedded server or remote server, on the other hand.
When I said "doing it after connection", I really meant "doing immediately WHEN the connection is made", which is the current Beeline behavior for variables that come either from connection string or command line. I'd propose that we execute additional commands specified in the init file whenever a connection is made. This is consistent with both Hive CLI and existing Beeline behavior. Under this proposal, client-side initialization is skipped w/o a connection, but I think we should be Okay: 1. most of time beeline will have a connection when started; 2. user can do "!run script.init" to execute a script file w/o a connection.