Is it possible to use prompt-toolkit to implement these modern CLI tools ??
See original GitHub issuePrompt-toolkit supports prompt ui and fullscreen ui. But there is another partial fullscreen
ui, I don’t know how to implement it with prompt-toolkit.
FZF:
When I input:
cd `find . -type d | fzf --height 30% --reverse`
fzf will use stderr to render it’s ui and write the result to stdout:
As you see, with --height 30%
parameter, fzf will not occupy the fullscreen and will resue only a region of current screen to display it’s ui widget. When I press enter and accept a path. fzf will clear the region it used, and restore the cursor position for me:
Then cd command get the output from fzf and take it as an argument.
Deer
Deer is a ranger like zsh plugin, it can be used as a file picker:
When I input cd <alt+k>
, deer will display it’s widgets under current line:
After picking a path, deer will close (clear it’s ui) and restore cursor position and paste it’s result:
Question
Both fzf
and deer
are widely used command line tools today, they are not traditional prompt program and still not traditional fullscreen application.
I really want to know is it possible to use prompt_toolkit to implement sth like fzf or deer ??
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top GitHub Comments
I want to implement a new fzf, I have a better algorithm, can I use prompt_toolkit for TUI ?? Any example ??
I use IPython and have figured out a simple way to implement this (EDIT: it seems that you want this to be built into prompt toolkit instead of using an external program? I’m not sure this will help with that, but maybe can offer some building blocks). I bet this can be used with purely prompt toolkit since IPython is built using prompt toolkit. Here is the code:
And some screenshots:
and after hitting enter it pops back into the current line:
The
ip.pt_app
object is a<class 'prompt_toolkit.shortcuts.prompt.PromptSession'>
object, so I’m assuming if you have access to that you can implement this in any prompt toolkit app