diff --git a/CHANGES.txt b/CHANGES.txt index bf861c9f54..711ca08cf4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,7 @@ 2.1.1 + * (cqlsh) Display the current logged-in user (CASSANDRA-7785) * (cqlsh) Don't ignore CTRL-C during COPY FROM execution (CASSANDRA-7815) * (cqlsh) Order UDTs according to cross-type dependencies in DESCRIBE output (CASSANDRA-7659) diff --git a/bin/cqlsh b/bin/cqlsh index 3fb972ad72..c055771ccc 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -504,6 +504,7 @@ class Shell(cmd.Cmd): if not password: password = getpass.getpass() self.auth_provider = PlainTextAuthProvider(username=username, password=password) + self.username = username self.keyspace = keyspace self.tracing_enabled = tracing_enabled self.expand_enabled = expand_enabled @@ -712,9 +713,9 @@ class Shell(cmd.Cmd): def reset_prompt(self): if self.current_keyspace is None: - self.set_prompt(self.default_prompt) + self.set_prompt(self.default_prompt, True) else: - self.set_prompt(self.keyspace_prompt % self.current_keyspace) + self.set_prompt(self.keyspace_prompt % self.current_keyspace, True) def set_continue_prompt(self): if self.empty_lines >=3: @@ -1062,7 +1063,10 @@ class Shell(cmd.Cmd): return cqlruleset.cql_complete(stuff_to_complete, text, cassandra_conn=self, debug=debug_completion, startsymbol='cqlshCommand') - def set_prompt(self, prompt): + def set_prompt(self, prompt, prepend_user=False): + if prepend_user and self.username: + self.prompt = "%s@%s" % (self.username, prompt) + return self.prompt = prompt def cql_unprotect_name(self, namestr):