include the command being run in the title

This commit is contained in:
adam j hartz 2015-12-05 13:39:31 -05:00
parent 6e98119c46
commit 0a46ebf54f
3 changed files with 14 additions and 2 deletions

View file

@ -203,6 +203,7 @@ class BaseShell(object):
os.system('title {}'.format(t))
else:
sys.stdout.write("\x1b]2;{0}\x07".format(t))
sys.stdout.flush()
@property
def prompt(self):

View file

@ -613,6 +613,7 @@ def run_subproc(cmds, captured=True):
'obj': prev_proc,
'bg': background
})
builtins.__xonsh_shell__.settitle()
if background:
return
if prev_is_proxy:

View file

@ -98,8 +98,8 @@ else:
DEFAULT_PROMPT = ('{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} '
'{cwd}{branch_color}{curr_branch} '
'{BOLD_BLUE}{prompt_end}{NO_COLOR} ')
DEFAULT_TITLE = '{user}@{hostname}: {cwd} | xonsh'
DEFAULT_TITLE = '{current_job}{user}@{hostname}: {cwd} | xonsh'
@default_value
def xonsh_data_dir(env):
@ -564,6 +564,15 @@ def _collapsed_pwd():
return leader + sep.join(base)
def _current_job():
j = builtins.__xonsh_active_job__
if j is not None:
j = builtins.__xonsh_all_jobs__[j]
if not j['bg']:
return '{} | '.format(j['cmds'][-1][0])
return ''
if ON_WINDOWS:
USER = 'USERNAME'
else:
@ -580,6 +589,7 @@ FORMATTER_DICT = dict(
short_cwd=_collapsed_pwd,
curr_branch=current_branch,
branch_color=branch_color,
current_job=_current_job,
**TERM_COLORS)
DEFAULT_VALUES['FORMATTER_DICT'] = dict(FORMATTER_DICT)