Python interface for bash completion
Project description
A package that provides python interface for bash completion
Usage example
In the simplest case, we can just complete from the end of the line using, bash_complete_line():
from bash_completion import bash_complete_line
In [1]: bash_complete_line('git s', return_line=True)
Out[1]:
{'git shortlog',
'git show',
'git show-branch',
'git stage',
'git stash',
'git status',
'git submodule',
'git subtree'}
However, there is also a lower-level API that more closely matches the actual Bash completion interface, for those who need it!
from bash_completion import bash_completions
def get_completions(line):
split = line.split()
if len(split) > 1 and not line.endswith(' '):
prefix = split[-1]
begidx = len(line.rsplit(prefix)[0])
else:
prefix = ''
begidx = len(line)
endidx = len(line)
return bash_completions(prefix, line, begidx, endidx)
In [1]: get_completions('git s')
Out[1]:
({'shortlog',
'show',
'show-branch',
'stage',
'stash',
'status',
'submodule',
'subtree'},
1)
You may also use this as a simple command line utility:
$ python -m bash_completion "ls --s"
ls --show-control-chars
ls --si
ls --size
ls --sort
ls --sort=
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bash_completion-0.2.8.tar.gz
(7.4 kB
view details)
File details
Details for the file bash_completion-0.2.8.tar.gz
.
File metadata
- Download URL: bash_completion-0.2.8.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 pkginfo/1.8.2 readme-renderer/27.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7a9ee1963dd4f4304fda1cb93519872b57579c6940c0a2710f66b8be0031c7b |
|
MD5 | 63830db548b5aa9f495e24b66d2b90ec |
|
BLAKE2b-256 | dbe6e0a1932acb5da0081c1f2489f914a77c8200b89cd64130373c937ede18df |