Skip to main content

Argcomplete support for python and xonsh scripts in xonsh shell.

Project description

Argcomplete support for python and xonsh scripts in xonsh shell.

If you like the idea click ⭐ on the repo and and tweet.

[Demo]
Screenshot made with xontrib-prompt-bar and Konsole.

Install

xpip install xontrib-argcomplete
echo 'xontrib load argcomplete' >> ~/.xonshrc
# Reload xonsh

Usage

First of all you need to add the argcomplete support to your script:

  • The PYTHON_ARGCOMPLETE_OK marker should be found in the first 10 lines of the file (example).
  • Additional .completer was set for add_argument (example).
  • argcomplete.autocomplete(parser) added before parser.parse_args() (example).

Example for proto.py sample:

xpip install xontrib-argcomplete
xontrib load argcomplete

cd /tmp && git clone https://github.com/anki-code/xontrib-argcomplete
cd xontrib-argcomplete/tests

python proto.py <Tab>  # Suggestions: --help --proto -h
./proto.py --proto tt<Tab>  # Suggestions: http https
./proto.xsh --proto tt<Tab>  # Suggestions: http https
./proto --proto tt<Tab>  # Suggestions: http https

$PATH.append($PWD)
proto --proto tt<Tab>  # Suggestions: http https

The argcomplete xonsh completer will be activated with this cases:

python script.py <Tab>
./script.py <Tab>
./path/script.py <Tab>

xonsh script.xsh <Tab>
./script.xsh <Tab>
./path/script.xsh <Tab>

# scripts without extension should have "env python" or "env xonsh" or path to python/xonsh in the shebang
./script <Tab>
script <Tab>    # script should be found in $PATH

Known issues

Windows is not supported. PRs are welcome!

Development

Links

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_argcomplete-0.3.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

xontrib_argcomplete-0.3.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_argcomplete-0.3.4.tar.gz.

File metadata

  • Download URL: xontrib_argcomplete-0.3.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xontrib_argcomplete-0.3.4.tar.gz
Algorithm Hash digest
SHA256 9a9d652e91976a1e183138075f5757d0894f75287878e90a52f21b1dbc91a451
MD5 29d057a15c85a6805333220e26690ce9
BLAKE2b-256 51a4f99338ec4b45be0547417cdc38e20a5c748bb5e10be8c88d0184d2d1f27b

See more details on using hashes here.

File details

Details for the file xontrib_argcomplete-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_argcomplete-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7798e8f97dd0db02de82075af000e2bb787385084128b412311301e0ef7271
MD5 075dba88ea9187e3811936297b49da09
BLAKE2b-256 3651798dde809b588b06aa41295c7dbad427a5598ed77415b5471f3a43e48621

See more details on using hashes here.

Supported by

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