From ee3eebcc0768f845f00a516296959438fdb32384 2019-12-27 14:22:53 From: Jonathan Feinberg Date: 2019-12-27 14:22:53 Subject: [PATCH] Support vi-mode 'InputFormat' prompt Prompt defining what vi-mode is in, is either 'vi-insert' or 'vi-navigate' (or something 'vi-...' I imagine). From this `[3:6]` is extracted to get either 'ins' or 'nav' in the prompt. This is consistent with the behavior I experience when manipulating a custom prompt from the most updated pip installable package. However, in the case of installing the current master from source, the prompt is on the format 'InputFormat.INSERT' and 'InputFormat.NAVIGATION'. --- diff --git a/IPython/terminal/prompts.py b/IPython/terminal/prompts.py index ee2c5d7..3f5c07b 100644 --- a/IPython/terminal/prompts.py +++ b/IPython/terminal/prompts.py @@ -17,7 +17,12 @@ class Prompts(object): def vi_mode(self): if (getattr(self.shell.pt_app, 'editing_mode', None) == EditingMode.VI and self.shell.prompt_includes_vi_mode): - return '['+str(self.shell.pt_app.app.vi_state.input_mode)[3:6]+'] ' + mode = str(self.shell.pt_app.app.vi_state.input_mode) + if mode.startswith('InputMode.'): + mode = mode[10:13].lower() + elif mode.startswith('vi-'): + mode = mode[3:6] + return '['+mode+'] ' return ''