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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xontrib_argcomplete-0.3.3.tar.gz
Algorithm Hash digest
SHA256 60fe069ec021c9d316c3a1b6ba8220d20f06d74a69ef4fd0d0a037a3c5c897c9
MD5 65cd189a1f43f5f6c421182f2b99db5f
BLAKE2b-256 3b76835d3466bd51bfaf9ac68faa8dcece33bea3e40c0b13a3766d2fc43f0e75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xontrib_argcomplete-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84e7917a41f8a6c2a50535fdc048099a84ed2e67fcc5703eca5bbfa4aa4a7ad1
MD5 5d5a2ce372059a13d15d76ec0dd7b065
BLAKE2b-256 e8e08c92b4ddddbab9659516f623bca1ab9a322ff8a92782605e7e6e194e8bb9

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