Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anki-code/xontrib-argcomplete
Argcomplete support to tab completion of python and xonsh scripts in xonsh shell.
https://github.com/anki-code/xontrib-argcomplete
argcomplete python shell xonsh xontrib
Last synced: 8 days ago
JSON representation
Argcomplete support to tab completion of python and xonsh scripts in xonsh shell.
- Host: GitHub
- URL: https://github.com/anki-code/xontrib-argcomplete
- Owner: anki-code
- License: bsd-2-clause
- Created: 2020-09-07T12:01:55.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-09T08:21:04.000Z (26 days ago)
- Last Synced: 2024-10-12T15:56:38.090Z (22 days ago)
- Topics: argcomplete, python, shell, xonsh, xontrib
- Language: Python
- Homepage:
- Size: 339 KB
- Stars: 27
- Watchers: 1
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-xontribs - argcomplete - Argcomplete support to tab completion of python and xonsh scripts in xonsh. (Tab-completions)
README
Argcomplete support for python and xonsh scripts in xonsh shell.
If you like the idea click ⭐ on the repo and and tweet.
Screenshot made with xontrib-prompt-bar and Konsole.## Install
```shell script
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](https://kislyuk.github.io/argcomplete/#synopsis):
* The `PYTHON_ARGCOMPLETE_OK` marker should be found in the first 10 lines of the file ([example](https://github.com/anki-code/xontrib-argcomplete/blob/37e24660351780501eed64a2a77cb2a3309c109c/tests/proto.py#L2)).
* Additional `.completer` was set for `add_argument` ([example](https://github.com/anki-code/xontrib-argcomplete/blob/37e24660351780501eed64a2a77cb2a3309c109c/tests/proto.py#L7)).
* `argcomplete.autocomplete(parser)` added before `parser.parse_args()` ([example](https://github.com/anki-code/xontrib-argcomplete/blob/37e24660351780501eed64a2a77cb2a3309c109c/tests/proto.py#L8)).Example for [`proto.py`](https://github.com/anki-code/xontrib-argcomplete/blob/master/tests/proto.py) sample:
```xsh
xpip install xontrib-argcomplete
xontrib load argcompletecd /tmp && git clone https://github.com/anki-code/xontrib-argcomplete
cd xontrib-argcomplete/testspython proto.py # Suggestions: --help --proto -h
./proto.py --proto tt # Suggestions: http https
./proto.xsh --proto tt # Suggestions: http https
./proto --proto tt # Suggestions: http https$PATH.append($PWD)
proto --proto tt # Suggestions: http https
```The argcomplete xonsh completer will be activated with this cases:
```xsh
python script.py
./script.py
./path/script.pyxonsh script.xsh
./script.xsh
./path/script.xsh# scripts without extension should have "env python" or "env xonsh" or path to python/xonsh in the shebang
./script
script # script should be found in $PATH
```## Known issues
Windows is not supported. PRs are welcome!
## Development
* To switch on the debug mode run `$XONTRIB_ARGCOMPLETE_DEBUG = True`.
* [Argcomplete environment variables](https://github.com/kislyuk/argcomplete/issues/319#issuecomment-693295017)
* [Argcomplete documentation](https://kislyuk.github.io/argcomplete/)## Links
* This package is the part of [ergopack](https://github.com/anki-code/xontrib-ergopack) - the pack of ergonomic xontribs.
* This package was created with [xontrib cookiecutter template](https://github.com/xonsh/xontrib-cookiecutter).