Skip to main content

Useful xonsh-shell commands/alias functions

Project description

Useful xonsh-shell commands/alias/completer functions

Installation

To install use pip:

xpip install xontrib-commands
# or: xpip install -U git+https://github.com/jnoortheen/xontrib-commands

Usage

xontrib load commands

building alias

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

from xontrib_commands import Command
@Command.reg
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

Commands

  • 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

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

Notes
-----
    Please use
        `import module` or `import module as mdl` patterns
    Using
        `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 v1.0.0 (nuclear v1.1.10) - A command to cd into a directory. (Default action)

Usage:
dev [COMMAND] [OPTIONS] [NAME]

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

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

Commands:
  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
                  
                  Using https://github.com/theskumar/python-dotenv

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

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.3.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

xontrib_commands-0.3.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-commands-0.3.2.tar.gz.

File metadata

  • Download URL: xontrib-commands-0.3.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.1.0

File hashes

Hashes for xontrib-commands-0.3.2.tar.gz
Algorithm Hash digest
SHA256 adea73f1b606d3714006a699b587a3ae9aa5d9117602a96e4814253479782b9b
MD5 735f12ce8c445c0a3b0bec73d9ee479b
BLAKE2b-256 da19388e58d7579668637a39bc498fa4b57558624b9382fe501e820300710d06

See more details on using hashes here.

File details

Details for the file xontrib_commands-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: xontrib_commands-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.1.0

File hashes

Hashes for xontrib_commands-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1dc636ce78183e71acacd7f6fafe5858212987ba011b5d3a6b155fa18c3c25d
MD5 eec6cd2667481939e51b307fc6555945
BLAKE2b-256 09108a6ad923e47e1f168fa0f3a5f98524a425ea2348aef5660650efc747d991

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page