Skip to main content

completions

pypi tag travis codacy quality pyver

Shell completions for your program made easy.

Installation

pip install completions
# install lastest version using poetry
git clone https://github.com/pwwang/completions
cd completions
poetry install

Usage

Defining your completions

You may define your completions, basically commands and options, by following schema (showed in yaml, but can be any format supported by python-simpleconf: example.yaml

program:
    # your program, or path to your program
    name: completions-example
    desc: Shell completions for your program made easy.
    # whether global options should be inherited by commands
    inherit: true
    # options or global options if you have commands
    options:
        -s: The shell, one of bash, fish, zsh and auto.
        --shell: The shell, one of bash, fish, zsh and auto.
        -a: Automatically write completions to destination file.
        --auto: Automatically write completions to destination file.
commands:
    # No other options for command, give the description
    self: Generate completions for myself.
    generate:
        desc: Generate completions from configuration files.
        options:
            -c: The configuration file to load.
            --config: The configuration file to load.

How it looks like in fish: command option

Generating completion scripts

  • Bash
    > completions generate --shell bash \
        --config example.yaml > ~/bash_completion.d/completions.bash-completion
    
    You may need to source it in your .bashrc and restart your shell for the changes to take effect.
  • Fish
    > completions generate --shell fish \
        --config example.yaml > ~/.config/fish/completions/completions.fish
    
    You may need to restart your shell for the changes to take effect.
  • Zsh
    > completions generate --shell zsh \
        --config example.yaml > ~/.zsh-completions/_completions
    
    Make sure fpath+=~/.zsh-completions is put before compinit in you .zshrc

Saving completions scripts automatically

  • Bash

    > completions generate --shell bash --config example.yaml --auto
    
  • Fish

    > completions generate --shell fish --config example.yaml --auto
    
  • Zsh

    > completions generate --shell zsh --config example.yaml --auto
    

Python API

from completions import Completions
completions = Completions(
    # if not given, will be read from sys.argv[0]
    name    = 'completions',
    # Add global options to commands
    inherit = True,
    desc    = 'Shell completions for your program made easy.')
completions.addOption(
    ['-s', '--shell'],
    'The shell, one of bash, fish, zsh and auto.')
completions.addOption(
    ['-a', '--auto'],
    'Automatically write completions to destination file.')
completions.addCommand(
    'self', 'Generate completions for myself.')
completions.addCommand(
    'generate', 'Generate completions from configuration files.')
completions.command('generate').addOption(
    ['-c', '--config'], 'The configuration file to load.')
completions.generate(shell = 'fish', auto = False)

Release files for completions 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for completions 0.0.8
File Size Uploaded
completions-0.0.8.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for completions 0.0.8
File Interpreter ABI Platform
completions-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / completions-0.0.8.tar.gz

Download URL completions-0.0.8.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0213dc293cfdd1546201cc4aca0b7d548f924531ed6e86188fff7d39e4ab2bcd
BLAKE2b-256 checksum
How to use checksums
5bd8a51d3cf67886f4b1242c066e2cc2bd6525643120f543394d886616355065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/3.7.3 Linux/2.6.32-754.15.3.el6.x86_64

Release files / completions-0.0.8-py3-none-any.whl

Download URL completions-0.0.8-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1260a3c3c7aa5438f8922fee61d06e8e4bd8120158d53b704f62d1addf794088
BLAKE2b-256 checksum
How to use checksums
3041268fccaf0db73e56f574ae8defc34398a92b8f7a7178b9b4e42fd2365e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/3.7.3 Linux/2.6.32-754.15.3.el6.x86_64

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page