Refresh prompt from custom key binding
See original GitHub issueI am trying to oweride ctrl+d with custom command, calling command works but after presing c-d prompt and bottom toolbar are same. (commands.exit() changes prompt and bottom toolbar but) They change only if I pres enter, how can I redraw prompt and bottom toolbar from custom binding?
here is example code
def shell():
"""Repl shell"""
print("Welcome")
prompt = PromptSession(
history=FileHistory(os.path.join(os.path.expanduser("~"), ".history.txt"))
)
commands = Commands()
bindings = KeyBindings()
@bindings.add("c-d")
def _(event):
def print_exit():
print(commands.exit())
run_in_terminal(print_exit)
while True:
try:
user_input = prompt.prompt(
commands.prompt,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True,
key_bindings=bindings,
bottom_toolbar=commands.bottom,
)
if not user_input:
continue
except (EOFError, KeyboardInterrupt):
break
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Visual Studio Code Key Bindings
Here you will find the complete list of key bindings for Visual Studio Code and how to change them.
Read more >Enable the list refresh prompt - ServiceNow Docs
Receive a prompt to refresh a list when a list item has changed. A prompt indicates when to refresh the list, and after...
Read more >Reload of tmux config not unbinding keys (bind-key is ...
If I reload my tmux config (from within tmux) the keybindings I once had loaded will remain loaded. The only way (I know...
Read more >Tutorial: prompt_toolkit custom keybindings - Xonsh
The prompt_toolkit shell has a registry for handling custom keybindings. You may not like the default keybindings in xonsh, or you may want...
Read more >How to "bind -x" keyboard shortcut and refresh prompt
redraw-current-line is a command in readline, you don't install it. Bash uses the readline library and that's it, the command is already ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the following should do it:
I too would very much appreciate a concrete example of updating the prompt from a custom key binding!