Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Upcoming (TBD)
==============

Features
---------
* Allow shorter timeout lengths after pressing Esc, for vi-mode.


1.60.0 (2026/03/05)
==============

Expand Down
4 changes: 4 additions & 0 deletions mycli/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ def _(event: KeyPressEvent) -> None:
if mycli.key_bindings == "vi":
event.app.editing_mode = EditingMode.EMACS
mycli.key_bindings = "emacs"
event.app.ttimeoutlen = mycli.emacs_ttimeoutlen
else:
event.app.editing_mode = EditingMode.VI
mycli.key_bindings = "vi"
event.app.ttimeoutlen = mycli.vi_ttimeoutlen

@kb.add('escape', '[', 'S')
def _(event: KeyPressEvent) -> None:
Expand All @@ -114,9 +116,11 @@ def _(event: KeyPressEvent) -> None:
if mycli.key_bindings == 'vi':
event.app.editing_mode = EditingMode.EMACS
mycli.key_bindings = 'emacs'
event.app.ttimeoutlen = mycli.emacs_ttimeoutlen
else:
event.app.editing_mode = EditingMode.VI
mycli.key_bindings = 'vi'
event.app.ttimeoutlen = mycli.vi_ttimeoutlen

@kb.add("tab")
def _(event: KeyPressEvent) -> None:
Expand Down
7 changes: 7 additions & 0 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def __init__(
self.config_without_user_options = read_config_files(config_files, ignore_user_options=True)
self.multi_line = c["main"].as_bool("multi_line")
self.key_bindings = c["main"]["key_bindings"]
self.emacs_ttimeoutlen = c['keys'].as_float('emacs_ttimeoutlen')
self.vi_ttimeoutlen = c['keys'].as_float('vi_ttimeoutlen')
special.set_timing_enabled(c["main"].as_bool("timing"))
special.set_show_favorite_query(c["main"].as_bool("show_favorite_query"))
self.beep_after_seconds = float(c["main"]["beep_after_seconds"] or 0)
Expand Down Expand Up @@ -1311,6 +1313,11 @@ def one_iteration(text: str | None = None) -> None:
search_ignore_case=True,
)

if self.key_bindings == 'vi':
self.prompt_app.app.ttimeoutlen = self.vi_ttimeoutlen
else:
self.prompt_app.app.ttimeoutlen = self.emacs_ttimeoutlen

try:
while True:
one_iteration()
Expand Down
8 changes: 8 additions & 0 deletions mycli/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ control_d = exit
# possible values: auto, fzf, reverse_isearch
control_r = auto

# How long to wait for an Escape key sequence in vi mode.
# 0.5 seconds is the prompt_toolkit default, but vi users may find that too long.
# Shorter values mean that "Escape" alone is recognized more quickly.
vi_ttimeoutlen = 0.1

# How long to wait for an Escape key sequence in Emacs mode.
emacs_ttimeoutlen = 0.5

# Custom colors for the completion menu, toolbar, etc, with actual support
# depending on the terminal, and the property being set.
# Colors: #ffffff, bg:#ffffff, border:#ffffff.
Expand Down
8 changes: 8 additions & 0 deletions test/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ control_d = exit
# possible values: auto, fzf, reverse_isearch
control_r = auto

# How long to wait for an Escape key sequence in vi mode.
# 0.5 seconds is the prompt_toolkit default, but vi users may find that too long.
# Shorter values mean that "Escape" alone is recognized more quickly.
vi_ttimeoutlen = 0.1

# How long to wait for an Escape key sequence in Emacs mode.
emacs_ttimeoutlen = 0.5

# Custom colors for the completion menu, toolbar, etc, with actual support
# depending on the terminal, and the property being set.
# Colors: #ffffff, bg:#ffffff, border:#ffffff.
Expand Down