append newline default

This commit is contained in:
Anthony Scopatz 2018-04-03 15:51:09 -04:00
parent 2bbc942e51
commit 34a42fa06c
2 changed files with 9 additions and 3 deletions

View file

@ -344,8 +344,8 @@ class BaseShell(object):
tee_out = tee.getvalue() tee_out = tee.getvalue()
self._append_history(inp=src, ts=[ts0, ts1], tee_out=tee_out) self._append_history(inp=src, ts=[ts0, ts1], tee_out=tee_out)
self.accumulated_inputs += src self.accumulated_inputs += src
append_newline = env.get('XONSH_APPEND_NEWLINE') if tee_out and env.get('XONSH_APPEND_NEWLINE') \
if append_newline and not tee_out.endswith(os.linesep): and not tee_out.endswith(os.linesep):
print(os.linesep, end='') print(os.linesep, end='')
tee.close() tee.close()
self._fix_cwd() self._fix_cwd()

View file

@ -257,6 +257,12 @@ def default_xonshrc(env):
return dxrc return dxrc
@default_value
def xonsh_append_newline(env):
"""Appends a newline if we are in interactive mode and using prompt-toolkit"""
return env.get('XONSH_INTERACTIVE', False) and env.get('SHELL_TYPE') == 'prompt_toolkit'
# Default values should generally be immutable, that way if a user wants # Default values should generally be immutable, that way if a user wants
# to set them they have to do a copy and write them to the environment. # to set them they have to do a copy and write them to the environment.
# try to keep this sorted. # try to keep this sorted.
@ -328,7 +334,7 @@ def DEFAULT_VALUES():
'share')), 'share')),
'XONSHCONFIG': xonshconfig, 'XONSHCONFIG': xonshconfig,
'XONSHRC': default_xonshrc, 'XONSHRC': default_xonshrc,
'XONSH_APPEND_NEWLINE': False, 'XONSH_APPEND_NEWLINE': xonsh_append_newline,
'XONSH_AUTOPAIR': False, 'XONSH_AUTOPAIR': False,
'XONSH_CACHE_SCRIPTS': True, 'XONSH_CACHE_SCRIPTS': True,
'XONSH_CACHE_EVERYTHING': False, 'XONSH_CACHE_EVERYTHING': False,