##// END OF EJS Templates
Merge pull request #9271 from minrk/pt-term-title...
Thomas Kluyver -
r22125:a9fd69df merge
parent child Browse files
Show More
@@ -5,6 +5,8 b' import sys'
5
5
6 from IPython.core.interactiveshell import InteractiveShell
6 from IPython.core.interactiveshell import InteractiveShell
7 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
7 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
8 from IPython.utils.terminal import toggle_set_term_title, set_term_title
9 from IPython.utils.process import abbrev_cwd
8 from traitlets import Bool, Unicode, Dict
10 from traitlets import Bool, Unicode, Dict
9
11
10 from prompt_toolkit.completion import Completer, Completion
12 from prompt_toolkit.completion import Completer, Completion
@@ -28,6 +30,7 b' from .pt_inputhooks import get_inputhook_func'
28 from .interactiveshell import get_default_editor
30 from .interactiveshell import get_default_editor
29
31
30
32
33
31 class IPythonPTCompleter(Completer):
34 class IPythonPTCompleter(Completer):
32 """Adaptor to provide IPython completions to prompt_toolkit"""
35 """Adaptor to provide IPython completions to prompt_toolkit"""
33 def __init__(self, ipy_completer):
36 def __init__(self, ipy_completer):
@@ -69,6 +72,20 b' class TerminalInteractiveShell(InteractiveShell):'
69 editor = Unicode(get_default_editor(), config=True,
72 editor = Unicode(get_default_editor(), config=True,
70 help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
73 help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
71 )
74 )
75
76 term_title = Bool(True, config=True,
77 help="Automatically set the terminal title"
78 )
79 def _term_title_changed(self, name, new_value):
80 self.init_term_title()
81
82 def init_term_title(self):
83 # Enable or disable the terminal title.
84 if self.term_title:
85 toggle_set_term_title(True)
86 set_term_title('IPython: ' + abbrev_cwd())
87 else:
88 toggle_set_term_title(False)
72
89
73 def get_prompt_tokens(self, cli):
90 def get_prompt_tokens(self, cli):
74 return [
91 return [
@@ -187,6 +204,7 b' class TerminalInteractiveShell(InteractiveShell):'
187 def __init__(self, *args, **kwargs):
204 def __init__(self, *args, **kwargs):
188 super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
205 super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
189 self.init_prompt_toolkit_cli()
206 self.init_prompt_toolkit_cli()
207 self.init_term_title()
190 self.keep_running = True
208 self.keep_running = True
191
209
192 def ask_exit(self):
210 def ask_exit(self):
General Comments 0
You need to be logged in to leave comments. Login now