Skip to main content

Useful xonsh-shell commands/alias functions

Project description


Useful xonsh-shell commands/alias/completer functions


To install use pip:

xpip install xontrib-commands
# or: xpip install -U git+


xontrib load commands

building alias

Use xontrib_commands.Command to build arger dispatcher for your functions.

from xontrib_commands.utils import Command
def record_stats(pkg_name=".", path=".local/stats.txt"):
    stat = $(scc @(pkg_name))
    echo @($(date) + stat) | tee -a @(path)

Now a full CLI is ready

$ record-stats --help                                                                        
usage: xonsh [-h] [-p PKG_NAME] [-a PATH]

optional arguments:
  -h, --help            show this help message and exit
  -p PKG_NAME, --pkg-name PKG_NAME
  -a PATH, --path PATH


  • The following commands are available once the xontrib is loaded.

1. reload-mods

usage: reload-mods [-h] name

Reload any python module in the current xonsh session.
Helpful during development.

positional arguments:
  name        Name of the module/package to reload. Giving partial names matches all the nested modules.

optional arguments:
  -h, --help  show this help message and exit

$ reload-mods xontrib
    - this will reload all modules imported that starts with xontrib name

    Please use
        `import module` or `import module as mdl` patterns
        `from module import name`
        will not reload the name imported

2. report-key-bindings

usage: report-key-bindings [-h]

Show current Prompt-toolkit bindings in a nice table format

optional arguments:
  -h, --help  show this help message and exit

3. dev

dev - A command to cd into a directory. (Default action)


   [NAME] - name of the folder to cd into. This searches for names under $PROJECT_PATHS or the ones registered with ``dev add``

  --help [SUBCOMMANDS...] - Display this help and exit

  add           - Register the current folder to dev command.
                  When using this, it will get saved in a file, also that is used during completions.
  ls            - Show currently registered paths
  load-env FILE - Load environment variables from the given file into Xonsh session

Run "dev COMMAND --help" for more information on a command.

4. parallex

usage: parallex [-h] [-s] [-n] [-c] [args ...]

Execute multiple subprocess in parallel

positional arguments:
  args  individual commands need to be quoted and passed as separate arguments

  -h, --help
                        show this help message and exit
  -s, --shell
                        each command should be run with system's commands
  -n, --no-order
                        commands output are interleaved and not ordered
  -c, --hide-cmd
                        do not print the running command

running linters in parallel
    $ parallex "flake8 ." "mypy xonsh"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib-commands-0.4.1.tar.gz (10.4 kB view hashes)

Uploaded source

Built Distribution

xontrib_commands-0.4.1-py3-none-any.whl (11.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page