From 77109e6dd7d92a5bf53b0102f150324857bbb440 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Wed, 27 Jan 2016 18:47:17 -0500 Subject: [PATCH] set process title --- CHANGELOG.rst | 2 ++ docs/index.rst | 1 + xonsh/main.py | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b38487d83..b14721836 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,8 @@ Current Developments and a subprocess command exits with a non-zero return code, a CalledProcessError will be raised. This is useful in scripts that should fail at the first error. +* If the ``setproctitle`` package is installed, the process title will be + set to ``'xonsh'`` rather than the path to the Python interpreter. **Changed:** None diff --git a/docs/index.rst b/docs/index.rst index ec517c707..2b2942165 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -232,6 +232,7 @@ Xonsh currently has the following external dependencies, #. PLY #. prompt-toolkit (optional) #. Jupyter (optional) + #. setproctitle (optional) *Documentation:* diff --git a/xonsh/main.py b/xonsh/main.py index d88abb742..badce6f27 100644 --- a/xonsh/main.py +++ b/xonsh/main.py @@ -6,6 +6,11 @@ import builtins from argparse import ArgumentParser, ArgumentTypeError from contextlib import contextmanager +try: + from setproctitle import setproctitle +except ImportError: + setproctitle = None + from xonsh import __version__ from xonsh.shell import Shell from xonsh.pretty import pprint @@ -124,6 +129,8 @@ def _pprint_displayhook(value): def premain(argv=None): """Setup for main xonsh entry point, returns parsed arguments.""" + if setproctitle is not None: + setproctitle('xonsh') args, other = parser.parse_known_args(argv) if args.file is not None: real_argv = (argv or sys.argv)