@@ -233,6 +233,7 @@ def __init__(self, completer, model_completer, docs):
233233 self ._dot_cmd = DotCommandHandler ()
234234 self ._env = os .environ .copy ()
235235 self ._profile = None
236+ self .prompt_tokens = u'aws> '
236237
237238 # These attrs come from the config file.
238239 self .config_obj = None
@@ -279,7 +280,10 @@ def run(self):
279280 while True :
280281 try :
281282 document = self .cli .run (reset_current_buffer = True )
282- text = document .text
283+ if self .model_completer .context and isinstance (self .model_completer .context , list ):
284+ text = " " .join (self .model_completer .context ) + " " + document .text
285+ else :
286+ text = document .text
283287 except InputInterrupt :
284288 pass
285289 except (KeyboardInterrupt , EOFError ):
@@ -297,6 +301,25 @@ def run(self):
297301 if text .startswith ('!' ):
298302 # Then run the rest as a normally shell command.
299303 full_cmd = text [1 :]
304+ elif text .startswith ('@' ) and len (text .split ()) == 1 :
305+ # Add word as context to completions
306+ self .model_completer .context .append (text .split ()[0 ].strip ('@' ))
307+ self .model_completer .reset ()
308+ self .prompt_tokens = u'aws ' + ' ' .join (self .model_completer .context ) + u' > '
309+ self .refresh_cli = True
310+ self .cli .request_redraw ()
311+ continue
312+ elif 'exit' in text .split ():
313+ # Remove most recently added context
314+ if self .model_completer .context :
315+ self .model_completer .context .pop ()
316+ if self .model_completer .context :
317+ self .prompt_tokens = u'aws ' + ' ' .join (self .model_completer .context ) + u' > '
318+ else :
319+ self .prompt_tokens = u'aws > '
320+ self .refresh_cli = True
321+ self .cli .request_redraw ()
322+ continue
300323 else :
301324 full_cmd = 'aws ' + text
302325 self .history .append (full_cmd )
@@ -328,7 +351,7 @@ def create_layout(self, display_completions_in_columns, toolbar):
328351 if self .config_section ['theme' ] == 'none' :
329352 lexer = None
330353 return create_default_layout (
331- self , u'aws> ' , lexer = lexer , reserve_space_for_menu = True ,
354+ self , self . prompt_tokens , lexer = lexer , reserve_space_for_menu = True ,
332355 display_completions_in_columns = display_completions_in_columns ,
333356 get_bottom_toolbar_tokens = toolbar .handler )
334357
0 commit comments