diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index e9f1649..6fc8980 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -225,6 +225,10 @@ class TerminalInteractiveShell(InteractiveShell): help="Allows to enable/disable the prompt toolkit history search" ).tag(config=True) + prompt_includes_vi_mode = Bool(True, + help="Display the current vi mode (when using vi editing mode)." + ).tag(config=True) + @observe('term_title') def init_term_title(self, change=None): # Enable or disable the terminal title. diff --git a/IPython/terminal/prompts.py b/IPython/terminal/prompts.py index a108ca7..1a7563b 100644 --- a/IPython/terminal/prompts.py +++ b/IPython/terminal/prompts.py @@ -14,9 +14,8 @@ class Prompts(object): self.shell = shell def vi_mode(self): - if not hasattr(self.shell.pt_app, 'editing_mode'): - return '' - if self.shell.pt_app.editing_mode == 'VI': + if (getattr(self.shell.pt_app, 'editing_mode', None) == 'VI' + and self.shell.prompt_includes_vi_mode): return '['+str(self.shell.pt_app.app.vi_state.input_mode)[3:6]+'] ' return '' diff --git a/docs/source/whatsnew/pr/prompt_includes_vi_mode.rst b/docs/source/whatsnew/pr/prompt_includes_vi_mode.rst new file mode 100644 index 0000000..e219baa --- /dev/null +++ b/docs/source/whatsnew/pr/prompt_includes_vi_mode.rst @@ -0,0 +1,5 @@ +In vi editing mode, whether the prompt includes the current vi mode can now be configured +----------------------------------------------------------------------------------------- + +Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value +(default: True) to control this feature.