[GH-ISSUE #720] [v3] Regression: Support non-alphabetic custom keybinds #973

Closed
opened 2026-03-15 11:11:26 +03:00 by kerem · 3 comments
Owner

Originally created by @thisago on GitHub (Feb 1, 2026).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/720

Pre-submission checks

  • I have searched existing issues and this bug has not been reported yet
  • This is a bug report for asciinema CLI (not player or server)

Bug Description

Hello, thanks for the great tool, I really appreciate the efforts on it.

Previous version (v2) I could set keybinds like ^\ (example in my dotfiles), but now the key seems to require a alphabetic char, and neither numbers work (ie, ^0)
github.com/asciinema/asciinema@dabc40cf8e/src/config.rs (L268)

Steps to Reproduce

^\

$ sed -iE 's/^prefix_key = .*$/prefix_key = "^\\\\"/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = "^\\"
$ asciinema rec /tmp/a.cast --overwrite
Error: invalid key definition '^\'
[ble: exit 1]

C-\

$ sed -iE 's/^prefix_key = .*$/prefix_key = "C-\\\\"/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = "C-\\"
$ asciinema rec /tmp/a.cast --overwrite
Error: invalid key definition 'C-\'
[ble: exit 1]

0x1c github.com/asciinema/asciinema@dabc40cf8e/src/session.rs (L338)

$ sed -iE 's/^prefix_key = .*$/prefix_key = 0x1c/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = 0x1c
$ asciinema rec /tmp/a.cast --overwrite
Error: invalid key definition '28'
[ble: exit 1]

^]

$ sed -iE 's/^prefix_key = .*$/prefix_key = "^]"/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = "^]"
$ asciinema rec /tmp/a.cast --overwrite
Error: invalid key definition '^]'
[ble: exit 1]

^w (works, alphabetic)

$ sed -iE 's/^prefix_key = .*$/prefix_key = "^w"/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = "^w"
$ asciinema rec /tmp/a.cast --overwrite
::: asciinema session started
::: Recording to /tmp/a.cast
::: Press <ctrl+d> or type 'exit' to end
$ [ble: exit]
::: asciinema session ended
::: Recorded to /tmp/a.cast

^0

$ sed -iE 's/^prefix_key = .*$/prefix_key = "^0"/' ~/.config/asciinema/config.toml
$ grep prefix_key ~/.config/asciinema/config.toml
prefix_key = "^0"
$ asciinema rec /tmp/a.cast --overwrite
Error: invalid key definition '^0'
[ble: exit 1]

Expected Behavior

As version 2, be able to define in config:

prefix_key = "^\\"

Operating System

Fedora 42

asciinema CLI Version

asciinema 3.0.1

Installation Method

Package manager (apt, yum, brew, etc.)

$ guix show asciinema
name: asciinema
version: 3.0.1
outputs:
+ out: everything
systems: x86_64-linux
dependencies: python-minimal@3.11.14 rust-ring@0.17.8
location: gnu/packages/terminals.scm:235:2
homepage: https://asciinema.org
license: GPL 3
synopsis: Terminal session recorder
description: Use asciinema to record and share your terminal sessions, the right way.  Forget
+ screen recording apps and blurry video.  Enjoy a lightweight, purely text-based approach to
+ terminal recording.

Terminal Information

$ bash --version
GNU bash, version 5.3.9(1)-release (x86_64-pc-linux-gnu)

$ konsole --version
konsole 25.08.3

$ ble --version
ble.sh, version 0.4.0-devel3+0.4 (noarch)

Additional Context

I'm not familiar with Rust but played with the following changes but it crashes on some keybinds:

diff --git a/src/config.rs b/src/config.rs
index 8b26a83..ed4d3f5 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -265,7 +265,7 @@ fn parse_key<S: AsRef<str>>(key: S) -> Result<Key> {
         }

         2 => {
-            if chars[0] == '^' && chars[1].is_ascii_alphabetic() {
+            if chars[0] == '^' {
                 let key = vec![chars[1].to_ascii_uppercase() as u8 - 0x40];

                 return Ok(Some(key));
@@ -273,10 +273,7 @@ fn parse_key<S: AsRef<str>>(key: S) -> Result<Key> {
         }

         3 => {
-            if chars[0].eq_ignore_ascii_case(&'C')
-                && ['+', '-'].contains(&chars[1])
-                && chars[2].is_ascii_alphabetic()
-            {
+            if chars[0].eq_ignore_ascii_case(&'C') && ['+', '-'].contains(&chars[1]) {
                 let key = vec![chars[2].to_ascii_uppercase() as u8 - 0x40];

                 return Ok(Some(key));

With "^0" or 0x1c as prefix_key, crashes:

$ ./target/debug/asciinema rec /tmp/a.cast --overwrite

thread 'main' (354150) panicked at src/config.rs:269:32:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Originally created by @thisago on GitHub (Feb 1, 2026). Original GitHub issue: https://github.com/asciinema/asciinema/issues/720 ### Pre-submission checks - [x] I have searched existing issues and this bug has not been reported yet - [x] This is a bug report for asciinema CLI (not player or server) ### Bug Description Hello, thanks for the great tool, I really appreciate the efforts on it. Previous version (v2) I could set keybinds like `^\` ([example in my dotfiles](https://github.com/thisago/dotfiles/blob/4975c02bc72e911775ba567bb6dbfd6b727078fd/private_dot_config/asciinema/config#L35)), but now the key seems to require a alphabetic char, and neither numbers work (ie, `^0`) https://github.com/asciinema/asciinema/blob/dabc40cf8e97c4041af4bb360c6f37d393e96ebf/src/config.rs#L268 ### Steps to Reproduce `^\` ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = "^\\\\"/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = "^\\" $ asciinema rec /tmp/a.cast --overwrite Error: invalid key definition '^\' [ble: exit 1] ``` `C-\` ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = "C-\\\\"/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = "C-\\" $ asciinema rec /tmp/a.cast --overwrite Error: invalid key definition 'C-\' [ble: exit 1] ``` `0x1c` https://github.com/asciinema/asciinema/blob/dabc40cf8e97c4041af4bb360c6f37d393e96ebf/src/session.rs#L338 ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = 0x1c/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = 0x1c $ asciinema rec /tmp/a.cast --overwrite Error: invalid key definition '28' [ble: exit 1] ``` `^]` ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = "^]"/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = "^]" $ asciinema rec /tmp/a.cast --overwrite Error: invalid key definition '^]' [ble: exit 1] ``` `^w` (works, alphabetic) ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = "^w"/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = "^w" $ asciinema rec /tmp/a.cast --overwrite ::: asciinema session started ::: Recording to /tmp/a.cast ::: Press <ctrl+d> or type 'exit' to end $ [ble: exit] ::: asciinema session ended ::: Recorded to /tmp/a.cast ``` `^0` ```sh $ sed -iE 's/^prefix_key = .*$/prefix_key = "^0"/' ~/.config/asciinema/config.toml $ grep prefix_key ~/.config/asciinema/config.toml prefix_key = "^0" $ asciinema rec /tmp/a.cast --overwrite Error: invalid key definition '^0' [ble: exit 1] ``` ### Expected Behavior As version 2, be able to define in config: ```toml prefix_key = "^\\" ``` ### Operating System Fedora 42 ### asciinema CLI Version asciinema 3.0.1 ### Installation Method Package manager (apt, yum, brew, etc.) ``` sh $ guix show asciinema name: asciinema version: 3.0.1 outputs: + out: everything systems: x86_64-linux dependencies: python-minimal@3.11.14 rust-ring@0.17.8 location: gnu/packages/terminals.scm:235:2 homepage: https://asciinema.org license: GPL 3 synopsis: Terminal session recorder description: Use asciinema to record and share your terminal sessions, the right way. Forget + screen recording apps and blurry video. Enjoy a lightweight, purely text-based approach to + terminal recording. ``` ### Terminal Information ```sh $ bash --version GNU bash, version 5.3.9(1)-release (x86_64-pc-linux-gnu) $ konsole --version konsole 25.08.3 $ ble --version ble.sh, version 0.4.0-devel3+0.4 (noarch) ``` ### Additional Context I'm not familiar with Rust but played with the following changes but it crashes on some keybinds: ``` diff diff --git a/src/config.rs b/src/config.rs index 8b26a83..ed4d3f5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -265,7 +265,7 @@ fn parse_key<S: AsRef<str>>(key: S) -> Result<Key> { } 2 => { - if chars[0] == '^' && chars[1].is_ascii_alphabetic() { + if chars[0] == '^' { let key = vec![chars[1].to_ascii_uppercase() as u8 - 0x40]; return Ok(Some(key)); @@ -273,10 +273,7 @@ fn parse_key<S: AsRef<str>>(key: S) -> Result<Key> { } 3 => { - if chars[0].eq_ignore_ascii_case(&'C') - && ['+', '-'].contains(&chars[1]) - && chars[2].is_ascii_alphabetic() - { + if chars[0].eq_ignore_ascii_case(&'C') && ['+', '-'].contains(&chars[1]) { let key = vec![chars[2].to_ascii_uppercase() as u8 - 0x40]; return Ok(Some(key)); ``` With `"^0"` or `0x1c` as `prefix_key`, crashes: ``` sh $ ./target/debug/asciinema rec /tmp/a.cast --overwrite thread 'main' (354150) panicked at src/config.rs:269:32: attempt to subtract with overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ```
kerem closed this issue 2026-03-15 11:11:31 +03:00
Author
Owner

@notableclutter commented on GitHub (Feb 5, 2026):

I just spent the last half hour trying to configure ctrl+f10, ctrl+f11, ctrl+f12 to be my asciinema keys (long story of alacritty on windows -> asciinema -> tmux -> emacs):

[recording]
prefix_key = "C-<f12>"
add_marker_key = "C-<f10>"
pause_key = "C-<f11>"

Any chance of supporting some syntax for this?

<!-- gh-comment-id:3852391255 --> @notableclutter commented on GitHub (Feb 5, 2026): I just spent the last half hour trying to configure ctrl+f10, ctrl+f11, ctrl+f12 to be my asciinema keys (long story of alacritty on windows -> asciinema -> tmux -> emacs): ```yoml [recording] prefix_key = "C-<f12>" add_marker_key = "C-<f10>" pause_key = "C-<f11>" ``` Any chance of supporting some syntax for this?
Author
Owner

@notableclutter commented on GitHub (Feb 5, 2026):

With some help from our future overlords I have a patch branch to seems like it's doing what I need it to do.

my config.toml for commit 8f3f873
[session]
prefix_key = "C-<f12>"      
add_marker_key = "C-<f10>"  # press C-<f12> C-<f10> for to add marker
pause_key = "C-<f11>"       # press C-<f12> C-<f11> to pause
<!-- gh-comment-id:3852958125 --> @notableclutter commented on GitHub (Feb 5, 2026): With some help from our future overlords I have [a patch branch](https://github.com/notableclutter/asciinema/tree/special-chars) to seems like it's doing what I need it to do. <details> <summary> my config.toml for commit 8f3f873</summary> ```toml [session] prefix_key = "C-<f12>" add_marker_key = "C-<f10>" # press C-<f12> C-<f10> for to add marker pause_key = "C-<f11>" # press C-<f12> C-<f11> to pause ``` </details>
Author
Owner

@ku1ik commented on GitHub (Mar 1, 2026):

The regression has been fixed in v3.2.0.

Re extending the syntax - let's have a separate discussion (on GH discussions or discourse), as it requires more thought.

<!-- gh-comment-id:3980301918 --> @ku1ik commented on GitHub (Mar 1, 2026): The regression has been fixed in v3.2.0. Re extending the syntax - let's have a separate discussion (on GH discussions or discourse), as it requires more thought.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#973
No description provided.