From 34a42fa06c10deb7451bb176f26820cf131e459f Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 3 Apr 2018 15:51:09 -0400 Subject: [PATCH] append newline default --- xonsh/base_shell.py | 4 ++-- xonsh/environ.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index 8db59eff0..865216d9e 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -344,8 +344,8 @@ class BaseShell(object): tee_out = tee.getvalue() self._append_history(inp=src, ts=[ts0, ts1], tee_out=tee_out) self.accumulated_inputs += src - append_newline = env.get('XONSH_APPEND_NEWLINE') - if append_newline and not tee_out.endswith(os.linesep): + if tee_out and env.get('XONSH_APPEND_NEWLINE') \ + and not tee_out.endswith(os.linesep): print(os.linesep, end='') tee.close() self._fix_cwd() diff --git a/xonsh/environ.py b/xonsh/environ.py index 39f2897f9..60b213042 100644 --- a/xonsh/environ.py +++ b/xonsh/environ.py @@ -257,6 +257,12 @@ def default_xonshrc(env): 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 # to set them they have to do a copy and write them to the environment. # try to keep this sorted. @@ -328,7 +334,7 @@ def DEFAULT_VALUES(): 'share')), 'XONSHCONFIG': xonshconfig, 'XONSHRC': default_xonshrc, - 'XONSH_APPEND_NEWLINE': False, + 'XONSH_APPEND_NEWLINE': xonsh_append_newline, 'XONSH_AUTOPAIR': False, 'XONSH_CACHE_SCRIPTS': True, 'XONSH_CACHE_EVERYTHING': False,