diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index ca9976ac4a8..0c5bbaf3edd 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -527,7 +527,10 @@ private: std::cerr << std::fixed << std::setprecision(3); if (is_interactive) + { + clearTerminal(); showClientVersion(); + } is_default_format = !config().has("vertical") && !config().has("format"); if (config().has("vertical")) @@ -2467,6 +2470,17 @@ private: std::cout << DBMS_NAME << " client version " << VERSION_STRING << VERSION_OFFICIAL << "." << std::endl; } + static void clearTerminal() + { + /// Clear from cursor until end of screen. + /// It is needed if garbage is left in terminal. + /// Show cursor. It can be left hidden by invocation of previous programs. + /// A test for this feature: perl -e 'print "x"x100000'; echo -ne '\033[0;0H\033[?25l'; clickhouse-client + std::cout << + "\033[0J" + "\033[?25h"; + } + public: void init(int argc, char ** argv) {