Skip to main content

Pure-python fzf-inspired element picker

Project description

pzp

Pure-python fzf-inspired element picker

Build Status PyPI version PyPI Downloads Code style: black Known Vulnerabilities Documentation

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 option. Also, with the height argument you can limit the window height.

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

asciicast

You can choose between the following layout using the layout 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 argument allows you to bind one or more keys to one action. You can use it to customize key bindings or implementing custom behaviors.

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 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

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

pzp-0.0.15.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

pzp-0.0.15-py2.py3-none-any.whl (21.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pzp-0.0.15.tar.gz.

File metadata

  • Download URL: pzp-0.0.15.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.8.3 requests/2.28.1 setuptools/65.5.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.9.15

File hashes

Hashes for pzp-0.0.15.tar.gz
Algorithm Hash digest
SHA256 0d27f517e1d7574d67e3c090a379db041c5289b1adfa4ce889c5c09039302cbf
MD5 bd70a9a0f91bd1ec80c2b53f64ea48fa
BLAKE2b-256 3f4609a4ffa27eaeacd3f0bc9717d3e57ba04b3e26f99db2d3dc19627c7e3a18

See more details on using hashes here.

File details

Details for the file pzp-0.0.15-py2.py3-none-any.whl.

File metadata

  • Download URL: pzp-0.0.15-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.8.3 requests/2.28.1 setuptools/65.5.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.9.15

File hashes

Hashes for pzp-0.0.15-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 70c39c19b2b16185c49dbd7936cf834d8c1f874a660a25fb65a01f8c32245b1f
MD5 d426c3af3e253a4e19fca813a4c9e336
BLAKE2b-256 f4a9c8a9e61cfc410f1cd4f259c98e63ad62958b889469bdebf37fa4c8671f0d

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