pzp


Namepzp JSON
Version 0.0.24 PyPI version JSON
download
home_pagehttp://github.com/andreax79/pzp
SummaryPure-python fzf-inspired element picker
upload_time2024-06-25 09:34:07
maintainerNone
docs_urlNone
authorAndrea Bonomi
requires_python>=3.6
licenseMIT
keywords fzf picker cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pzp
==============

Pure-python fzf-inspired element picker

[![Build Status](https://github.com/andreax79/pzp/workflows/Tests/badge.svg)](https://github.com/andreax79/pzp/actions)
[![PyPI version](https://badge.fury.io/py/pzp.svg)](https://badge.fury.io/py/pzp)
[![PyPI](https://img.shields.io/pypi/pyversions/pzp.svg)](https://pypi.org/project/pzp)
[![Downloads](https://pepy.tech/badge/pzp/month)](https://pepy.tech/project/pzp)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Known Vulnerabilities](https://snyk-widget.herokuapp.com/badge/pip/pzp/badge.svg)](https://snyk.io/test/github/andreax79/pzp)
[![Documentation](https://readthedocs.org/projects/pzp/badge/?version=latest)](https://pzp.readthedocs.io/en/latest/)

Requirements
-----------
* Python 3.6+

Install
-------

```
pip install pzp
```

Usage
-----

```
from pzp import pzp
pzp(['a', 'b', 'c'])
```


### Layout

The finder by default starts in fullscreen mode. You can make it start below the
cursor with [`fullscreen=False`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.
Also, with the [`height`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument you can limit the window height.

```python
pzp(candidates=range(0, 1000), fullscreen=False, height=20)
```

[![asciicast](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ.svg)](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ?autoplay=1)

You can choose between the following layout using the [`layout`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.

* **default** Display from the bottom of the screen
* **reverse** Display from the top of the screen
* **reverse-list** Display from the top of the screen, prompt at the bottom

### Search syntax

The finder starts in "extended-search mode" where you can type in multiple search
terms delimited by spaces. e.g. `^music .mp3$ sbtrkt !fire`

| Token        | Match type                 | Description                          |
| ------------ | -------------------------- | ------------------------------------ |
| `t1 t2`      | tokens-match               | Items that include `t1` and `t2`     |
| `'star wars` | line-match (not-splitted)  | Items that include `star wars`       |
| `^music`     | prefix-exact-match         | Items that start with `music`        |
| `.py$`       | suffix-exact-match         | Items that end with `.py`            |
| `!fire`      | inverse-exact-match        | Items that do not include `fire`     |
| `!^music`    | inverse-prefix-exact-match | Items that do not start with `music` |
| `!.py$`      | inverse-suffix-exact-match | Items that do not end with `.py`     |

### Key/Event Bindings

[`keys_binding`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to bind one or more keys to one action.
You can use it to customize key bindings or implementing custom behaviors.

```python
try:
    item = pzp(
        candidates=candidates,
        keys_binding={
            "custom-action": ["ctrl-o"],
            "exclamation": ["!"]
        },
    )
    print(item)
except CustomAction as action:
    print(action.action)
    print(action.selected_item)
```

#### Available Keys

| Key                   | Synonyms type         |
| --------------------- | --------------------- |
| space                 |                       |
| tab                   |                       |
| btab                  | shift-tab             |
| enter                 |                       |
| esc                   |                       |
| insert                |                       |
| del                   |                       |
| bspace                | bs                    |
| up                    |                       |
| down                  |                       |
| left                  |                       |
| right                 |                       |
| home                  |                       |
| end                   |                       |
| pgdn                  | page-down             |
| pgup                  | page-up               |
| f1 - f12              |                       |
| ctrl-/                |                       |
| ctrl-\                |                       |
| ctrl-]                |                       |
| ctrl-^                |                       |
| ctrl-a - ctrl-z       |                       |
| any single character  |                       |

#### Available Actions

A key can be bound to one of following actions or to a custom action.

| *Action**                 | *Default binding*                     |
| ------------------------- | ------------------------------------- |
| **accept**                | *enter*                               |
| **abort**                 | *ctrl-c*  *ctrl-g*  *ctrl-q*  *esc*   |
| **beginning-of-line**     | *ctrl-a*  *home*                      |
| **backward-char**         | *ctrl-b* *left*                       |
| **forward-char**          | *ctrl-f*  *right*                     |
| **end-of-line**           | *ctrl-e*  *end*                       |
| **backward-delete-char**  | *ctrl-h*  *bspace*                    |
| **delete-char**           | *del*                                 |
| **up**                    | *ctrl-k*  *ctrl-p*  *up*              |
| **down**                  | *ctrl-j*  *ctrl-n*  *down*            |
| **page-down**             | *pgdn*                                |
| **page-up**               | *pgup*                                |
| **ignore**                |                                       |

### Lazy Mode

[`lazy`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to enable the lazy mode.
If the Lazy mode is enabled, starts the finder only if the candidates are more than one.
If there is only one match returns the only match, if there is no match returns None.

Licence
-------
MIT

Links
-----

* [fzf](https://github.com/junegunn/fzf)
* [ANSI Escape Sequences](https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797)
* [pyte, python terminal emulator](https://github.com/selectel/pyte)
* [Grip, GitHub Readme Instant Preview](https://github.com/joeyespo/grip)
* [Black, The Uncompromising Code Formatter](https://github.com/psf/black)
* [mkdocstrings, Automatic documentation from sources](https://github.com/mkdocstrings/mkdocstrings)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/andreax79/pzp",
    "name": "pzp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "fzf, picker, cli",
    "author": "Andrea Bonomi",
    "author_email": "andrea.bonomi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/76/4d/7485b21a13b19373c4f807bf7d92c4db8e8d72f5eab729ac870b79d20fd3/pzp-0.0.24.tar.gz",
    "platform": "any",
    "description": "pzp\n==============\n\nPure-python fzf-inspired element picker\n\n[![Build Status](https://github.com/andreax79/pzp/workflows/Tests/badge.svg)](https://github.com/andreax79/pzp/actions)\n[![PyPI version](https://badge.fury.io/py/pzp.svg)](https://badge.fury.io/py/pzp)\n[![PyPI](https://img.shields.io/pypi/pyversions/pzp.svg)](https://pypi.org/project/pzp)\n[![Downloads](https://pepy.tech/badge/pzp/month)](https://pepy.tech/project/pzp)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Known Vulnerabilities](https://snyk-widget.herokuapp.com/badge/pip/pzp/badge.svg)](https://snyk.io/test/github/andreax79/pzp)\n[![Documentation](https://readthedocs.org/projects/pzp/badge/?version=latest)](https://pzp.readthedocs.io/en/latest/)\n\nRequirements\n-----------\n* Python 3.6+\n\nInstall\n-------\n\n```\npip install pzp\n```\n\nUsage\n-----\n\n```\nfrom pzp import pzp\npzp(['a', 'b', 'c'])\n```\n\n\n### Layout\n\nThe finder by default starts in fullscreen mode. You can make it start below the\ncursor with [`fullscreen=False`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.\nAlso, with the [`height`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument you can limit the window height.\n\n```python\npzp(candidates=range(0, 1000), fullscreen=False, height=20)\n```\n\n[![asciicast](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ.svg)](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ?autoplay=1)\n\nYou can choose between the following layout using the [`layout`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.\n\n* **default** Display from the bottom of the screen\n* **reverse** Display from the top of the screen\n* **reverse-list** Display from the top of the screen, prompt at the bottom\n\n### Search syntax\n\nThe finder starts in \"extended-search mode\" where you can type in multiple search\nterms delimited by spaces. e.g. `^music .mp3$ sbtrkt !fire`\n\n| Token        | Match type                 | Description                          |\n| ------------ | -------------------------- | ------------------------------------ |\n| `t1 t2`      | tokens-match               | Items that include `t1` and `t2`     |\n| `'star wars` | line-match (not-splitted)  | Items that include `star wars`       |\n| `^music`     | prefix-exact-match         | Items that start with `music`        |\n| `.py$`       | suffix-exact-match         | Items that end with `.py`            |\n| `!fire`      | inverse-exact-match        | Items that do not include `fire`     |\n| `!^music`    | inverse-prefix-exact-match | Items that do not start with `music` |\n| `!.py$`      | inverse-suffix-exact-match | Items that do not end with `.py`     |\n\n### Key/Event Bindings\n\n[`keys_binding`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to bind one or more keys to one action.\nYou can use it to customize key bindings or implementing custom behaviors.\n\n```python\ntry:\n    item = pzp(\n        candidates=candidates,\n        keys_binding={\n            \"custom-action\": [\"ctrl-o\"],\n            \"exclamation\": [\"!\"]\n        },\n    )\n    print(item)\nexcept CustomAction as action:\n    print(action.action)\n    print(action.selected_item)\n```\n\n#### Available Keys\n\n| Key                   | Synonyms type         |\n| --------------------- | --------------------- |\n| space                 |                       |\n| tab                   |                       |\n| btab                  | shift-tab             |\n| enter                 |                       |\n| esc                   |                       |\n| insert                |                       |\n| del                   |                       |\n| bspace                | bs                    |\n| up                    |                       |\n| down                  |                       |\n| left                  |                       |\n| right                 |                       |\n| home                  |                       |\n| end                   |                       |\n| pgdn                  | page-down             |\n| pgup                  | page-up               |\n| f1 - f12              |                       |\n| ctrl-/                |                       |\n| ctrl-\\                |                       |\n| ctrl-]                |                       |\n| ctrl-^                |                       |\n| ctrl-a - ctrl-z       |                       |\n| any single character  |                       |\n\n#### Available Actions\n\nA key can be bound to one of following actions or to a custom action.\n\n| *Action**                 | *Default binding*                     |\n| ------------------------- | ------------------------------------- |\n| **accept**                | *enter*                               |\n| **abort**                 | *ctrl-c*  *ctrl-g*  *ctrl-q*  *esc*   |\n| **beginning-of-line**     | *ctrl-a*  *home*                      |\n| **backward-char**         | *ctrl-b* *left*                       |\n| **forward-char**          | *ctrl-f*  *right*                     |\n| **end-of-line**           | *ctrl-e*  *end*                       |\n| **backward-delete-char**  | *ctrl-h*  *bspace*                    |\n| **delete-char**           | *del*                                 |\n| **up**                    | *ctrl-k*  *ctrl-p*  *up*              |\n| **down**                  | *ctrl-j*  *ctrl-n*  *down*            |\n| **page-down**             | *pgdn*                                |\n| **page-up**               | *pgup*                                |\n| **ignore**                |                                       |\n\n### Lazy Mode\n\n[`lazy`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to enable the lazy mode.\nIf the Lazy mode is enabled, starts the finder only if the candidates are more than one.\nIf there is only one match returns the only match, if there is no match returns None.\n\nLicence\n-------\nMIT\n\nLinks\n-----\n\n* [fzf](https://github.com/junegunn/fzf)\n* [ANSI Escape Sequences](https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797)\n* [pyte, python terminal emulator](https://github.com/selectel/pyte)\n* [Grip, GitHub Readme Instant Preview](https://github.com/joeyespo/grip)\n* [Black, The Uncompromising Code Formatter](https://github.com/psf/black)\n* [mkdocstrings, Automatic documentation from sources](https://github.com/mkdocstrings/mkdocstrings)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pure-python fzf-inspired element picker",
    "version": "0.0.24",
    "project_urls": {
        "Bug Tracker": "http://github.com/andreax79/pzp/issues",
        "Documentation": "https://pzp.readthedocs.io/en/latest/",
        "Homepage": "http://github.com/andreax79/pzp",
        "Source Code": "http://github.com/andreax79/pzp"
    },
    "split_keywords": [
        "fzf",
        " picker",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7697cbed226c6d28d25b5dda97b4b31bc16446f21cb1293fca913c186032d581",
                "md5": "c907a544ccabe4b71879ae1b61ca5014",
                "sha256": "80edf2442216ac023ed4969827552d7c35a81e60829621bd9d10115254e7fb09"
            },
            "downloads": -1,
            "filename": "pzp-0.0.24-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c907a544ccabe4b71879ae1b61ca5014",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 24681,
            "upload_time": "2024-06-25T09:34:06",
            "upload_time_iso_8601": "2024-06-25T09:34:06.008614Z",
            "url": "https://files.pythonhosted.org/packages/76/97/cbed226c6d28d25b5dda97b4b31bc16446f21cb1293fca913c186032d581/pzp-0.0.24-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "764d7485b21a13b19373c4f807bf7d92c4db8e8d72f5eab729ac870b79d20fd3",
                "md5": "31419c17f286190c3e65739f042e5163",
                "sha256": "d7a48a1fe2200372bb724b21e6162c88c2935a73cd3ae150dd4622c8cf3aaac1"
            },
            "downloads": -1,
            "filename": "pzp-0.0.24.tar.gz",
            "has_sig": false,
            "md5_digest": "31419c17f286190c3e65739f042e5163",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 23889,
            "upload_time": "2024-06-25T09:34:07",
            "upload_time_iso_8601": "2024-06-25T09:34:07.199247Z",
            "url": "https://files.pythonhosted.org/packages/76/4d/7485b21a13b19373c4f807bf7d92c4db8e8d72f5eab729ac870b79d20fd3/pzp-0.0.24.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-25 09:34:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "andreax79",
    "github_project": "pzp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pzp"
}
        
Elapsed time: 0.33257s