mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 00:41:00 +01:00

This adds prompt_toolkit based shell in addition to existing readline shell. By default regular readline shell is loaded, to use prompt_toolkit version you need to add: $PROMPT_TOOLKIT_SHELL = True to your ~/.xonshrc Another nice thing to add there is: from xonsh.pyghooks import XonshLexer $HIGHLIGHTING_LEXER = XonshLexer that adds highlighting of shell input (may be a bit annoying sometimes). There is no key for inserting indentation yet, it will be improved in the future.
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""Tests some tools function for prompt_toolkit integration."""
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
import nose
|
|
from nose.tools import assert_equal
|
|
|
|
from xonsh.tools import FakeChar
|
|
from xonsh.tools import format_prompt_for_prompt_toolkit
|
|
|
|
|
|
def test_format_prompt_for_prompt_toolkit():
|
|
cases = [
|
|
('root $ ', ['r', 'o', 'o', 't', ' ', '$', ' ']),
|
|
('\001\033[0;31m\002>>',
|
|
[FakeChar('>', prefix='\001\033[0;31m\002'), '>']
|
|
),
|
|
('\001\033[0;31m\002>>\001\033[0m\002',
|
|
[FakeChar('>', prefix='\001\033[0;31m\002'),
|
|
FakeChar('>', suffix='\001\033[0m\002')]
|
|
),
|
|
('\001\033[0;31m\002>\001\033[0m\002',
|
|
[FakeChar('>',
|
|
prefix='\001\033[0;31m\002',
|
|
suffix='\001\033[0m\002')
|
|
]
|
|
),
|
|
('\001\033[0;31m\002> $\001\033[0m\002',
|
|
[FakeChar('>', prefix='\001\033[0;31m\002'),
|
|
' ',
|
|
FakeChar('$', suffix='\001\033[0m\002')]
|
|
),
|
|
('\001\033[0;31m\002\001\033[0;32m\002$> \001\033[0m\002',
|
|
[FakeChar('$', prefix='\001\033[0;31m\002\001\033[0;32m\002'),
|
|
'>',
|
|
FakeChar(' ', suffix='\001\033[0m\002')]
|
|
),
|
|
]
|
|
for test, ans in cases:
|
|
assert_equal(format_prompt_for_prompt_toolkit(test), ans)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
nose.runmodule()
|