[GH-ISSUE #680] [Feature Request] add cast name to final message and JSON header #349

Closed
opened 2026-02-25 20:33:23 +03:00 by kerem · 13 comments
Owner

Originally created by @tacman on GitHub (May 27, 2025).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/680

By the time I've finished recording, I sometimes forget the cast name. Can you add it to the final message?

Before:

exit
::: asciinema session ended

After:

exit
::: asciinema session ended, casts/do-something-cool.cast saved with 45 lines
Originally created by @tacman on GitHub (May 27, 2025). Original GitHub issue: https://github.com/asciinema/asciinema/issues/680 By the time I've finished recording, I sometimes forget the cast name. Can you add it to the final message? Before: ``` exit ::: asciinema session ended ``` After: ``` exit ::: asciinema session ended, casts/do-something-cool.cast saved with 45 lines ```
kerem closed this issue 2026-02-25 20:33:23 +03:00
Author
Owner

@Cyb3rC3lt commented on GitHub (Jun 4, 2025):

I'd like to second this idea please. For someone who pauses their VM and may have days to weeks of console lines scrolling back to see what cast I am currently recording to would be great. I personally don't need the number of lines but the cast location would be ideal.

<!-- gh-comment-id:2939100206 --> @Cyb3rC3lt commented on GitHub (Jun 4, 2025): I'd like to second this idea please. For someone who pauses their VM and may have days to weeks of console lines scrolling back to see what cast I am currently recording to would be great. I personally don't need the number of lines but the cast location would be ideal.
Author
Owner

@moritzdietz commented on GitHub (Jun 4, 2025):

Maybe something along the lines of this?!

diff --git i/src/cmd/session.rs w/src/cmd/session.rs
index a47f8a3..2c12ab1 100644
--- i/src/cmd/session.rs
+++ w/src/cmd/session.rs
@@ -184,7 +184,12 @@ impl cli::Session {
             debug!("shutdown complete");
         });

-        status::info!("asciinema session ended");
+        if let Some(path) = self.output_file.as_ref() {
+            status::info!("Recorded to {}", path);
+            status::info!("asciinema session ended");
+        } else {
+            status::info!("asciinema session ended");
+        }

         if !self.return_ || exit_status == 0 {
             Ok(ExitCode::from(0))

This prints the same info like when you begin a recording.

❯ ./target/release/asciinema rec ../asdasdas --overwrite
::: asciinema session started
::: Recording to ../asdasdas
::: Press <ctrl+d> or type 'exit' to end

and then

::: Recorded to ../asdasdas
::: asciinema session ended
<!-- gh-comment-id:2941136760 --> @moritzdietz commented on GitHub (Jun 4, 2025): Maybe something along the lines of this?! ``` diff --git i/src/cmd/session.rs w/src/cmd/session.rs index a47f8a3..2c12ab1 100644 --- i/src/cmd/session.rs +++ w/src/cmd/session.rs @@ -184,7 +184,12 @@ impl cli::Session { debug!("shutdown complete"); }); - status::info!("asciinema session ended"); + if let Some(path) = self.output_file.as_ref() { + status::info!("Recorded to {}", path); + status::info!("asciinema session ended"); + } else { + status::info!("asciinema session ended"); + } if !self.return_ || exit_status == 0 { Ok(ExitCode::from(0)) ``` This prints the same info like when you begin a recording. ``` ❯ ./target/release/asciinema rec ../asdasdas --overwrite ::: asciinema session started ::: Recording to ../asdasdas ::: Press <ctrl+d> or type 'exit' to end ``` and then ``` ::: Recorded to ../asdasdas ::: asciinema session ended ```
Author
Owner

@moritzdietz commented on GitHub (Jun 6, 2025):

But out of curiosity, wouldn't you also just be able to press up on your arrow key to see the latest run command from your shell history which would be the recording command itself?

<!-- gh-comment-id:2948494689 --> @moritzdietz commented on GitHub (Jun 6, 2025): But out of curiosity, wouldn't you also just be able to press up on your arrow key to see the latest run command from your shell history which would be the recording command itself?
Author
Owner

@Cyb3rC3lt commented on GitHub (Jun 6, 2025):

My run command is kicked off by my shell on starting automatically so wouldn't be there. Plus when it dies due to ssh connection breaking it there could be a few in my console as I restart it by doing "source .zshrc"

<!-- gh-comment-id:2948507942 --> @Cyb3rC3lt commented on GitHub (Jun 6, 2025): My run command is kicked off by my shell on starting automatically so wouldn't be there. Plus when it dies due to ssh connection breaking it there could be a few in my console as I restart it by doing "source .zshrc"
Author
Owner

@tacman commented on GitHub (Jun 6, 2025):

I'd like the filename in the header record as well.

As I'm recording, I have a tool that takes screenshots of the website. The idea is that while playing back the .cast, I can load the image of the website when it hits a marker.

I'd like to put the screenshots in the same directory as the cast.

asciinema rec /tmp/$(date '+%Y-%m-%d-%H-%M-%S')-$$.cast
git clone my-cool-project && cd my-cool-project
composer install && bin/console doctrine:fixtures:load -n
symfony server:start -d
bin/console ciine:screenshot https://127.0.0.1:8000/ --caption="Home page after install"
bin/console app:switch-theme formal
bin/console ciine:screenshot https://127.0.0.1:8000/ --caption="Home page with 'formal' theme"
[ctrl-D]
bin/console ciine:merge #merges the .cast and screenshot files 

I could get the directory of the current cast if it was written to the first line (the header JSON). The example is weak because #679 hasn't been released yet, but when it does, I want to be able to keep all my screenshots (and audio/voice-overs) together with the cast(s).

Obviously, the "up" arrow isn't applicable in this case.

<!-- gh-comment-id:2949004609 --> @tacman commented on GitHub (Jun 6, 2025): I'd like the filename in the header record as well. As I'm recording, I have a tool that takes screenshots of the website. The idea is that while playing back the .cast, I can load the image of the website when it hits a marker. I'd like to put the screenshots in the same directory as the cast. ```bash asciinema rec /tmp/$(date '+%Y-%m-%d-%H-%M-%S')-$$.cast git clone my-cool-project && cd my-cool-project composer install && bin/console doctrine:fixtures:load -n symfony server:start -d bin/console ciine:screenshot https://127.0.0.1:8000/ --caption="Home page after install" bin/console app:switch-theme formal bin/console ciine:screenshot https://127.0.0.1:8000/ --caption="Home page with 'formal' theme" [ctrl-D] bin/console ciine:merge #merges the .cast and screenshot files ``` I could get the directory of the current cast if it was written to the first line (the header JSON). The example is weak because #679 hasn't been released yet, but when it does, I want to be able to keep all my screenshots (and audio/voice-overs) together with the cast(s). Obviously, the "up" arrow isn't applicable in this case.
Author
Owner

@moritzdietz commented on GitHub (Jun 6, 2025):

I'd like the filename in the header record as well.

I would suggest to use an environment variable you can set already without the need to alter the code.

You can use the option --rec-env and pass your own environment variable with whatever you want.

--rec-env <VARS>           Comma-separated list of env vars to capture [default: SHELL]
$ export FOO="bar"
$ asciinema rec --rec-env FOO "${FOO}.cast"

# < do your thing >

Then you can see the var in the header:

$ jq -s '.[0]' bar.cast
{
  "version": 3,
  "term": {
    "cols": 195,
    "rows": 53,
    "type": "tmux-256color",
    "version": "tmux next-3.6"
  },
  "timestamp": 1749218069,
  "env": {
    "FOO": "bar"
  }
}
<!-- gh-comment-id:2949357517 --> @moritzdietz commented on GitHub (Jun 6, 2025): > I'd like the filename in the header record as well. I would suggest to use an environment variable you can set already without the need to alter the code. You can use the option `--rec-env` and pass your own environment variable with whatever you want. ``` --rec-env <VARS> Comma-separated list of env vars to capture [default: SHELL] ``` ```Bash $ export FOO="bar" $ asciinema rec --rec-env FOO "${FOO}.cast" # < do your thing > ``` Then you can see the var in the header: ```Bash $ jq -s '.[0]' bar.cast { "version": 3, "term": { "cols": 195, "rows": 53, "type": "tmux-256color", "version": "tmux next-3.6" }, "timestamp": 1749218069, "env": { "FOO": "bar" } } ```
Author
Owner

@tacman commented on GitHub (Jun 6, 2025):

very cool, thanks.

So I guess I could also add the filename to the env vars.

export CAST="casts/ls.cast"
ciine rec --rec-env CAST $CAST
ls/<ctrl-d>
jq -s '.[0]' $CAST
{
  "version": 3,
  "term": {
    "cols": 152,
    "rows": 36,
    "type": "xterm-256color",
    "version": "VTE(7600)",
    "theme": {
      "fg": "#171421",
      "bg": "#ffffff",
      "palette": "#000000:#cd0000:#00cd00:#cdcd00:#0000ee:#cd00cd:#00cdcd:#e5e5e5:#7f7f7f:#ff0000:#00ff00:#ffff00:#5c5cff:#ff00ff:#00ffff:#ffffff"
    }
  },
  "timestamp": 1749218787,
  "idle_time_limit": 0.75,
  "env": {
    "CAST": "casts/ls.cast"
  }
}

That will definitely work for me, thanks!

<!-- gh-comment-id:2949384209 --> @tacman commented on GitHub (Jun 6, 2025): very cool, thanks. So I guess I could also add the filename to the env vars. ```bash export CAST="casts/ls.cast" ciine rec --rec-env CAST $CAST ls/<ctrl-d> jq -s '.[0]' $CAST { "version": 3, "term": { "cols": 152, "rows": 36, "type": "xterm-256color", "version": "VTE(7600)", "theme": { "fg": "#171421", "bg": "#ffffff", "palette": "#000000:#cd0000:#00cd00:#cdcd00:#0000ee:#cd00cd:#00cdcd:#e5e5e5:#7f7f7f:#ff0000:#00ff00:#ffff00:#5c5cff:#ff00ff:#00ffff:#ffffff" } }, "timestamp": 1749218787, "idle_time_limit": 0.75, "env": { "CAST": "casts/ls.cast" } } ``` That will definitely work for me, thanks!
Author
Owner

@moritzdietz commented on GitHub (Jun 6, 2025):

Cool! Glad this helped 🙂 If this does solve your question then I would suggest also closing this issue to help keep the issue tracker clean.

<!-- gh-comment-id:2949395340 --> @moritzdietz commented on GitHub (Jun 6, 2025): Cool! Glad this helped 🙂 If this does solve your question then I would suggest also closing this issue to help keep the issue tracker clean.
Author
Owner

@tacman commented on GitHub (Jun 6, 2025):

It helped for the JSON header, but it looks like you've added some code already to display the filename at the of the cast, so I do hope that's included in the next release.

<!-- gh-comment-id:2949401649 --> @tacman commented on GitHub (Jun 6, 2025): It helped for the JSON header, but it looks like you've added some code already to display the filename at the of the cast, so I do hope that's included in the next release.
Author
Owner

@moritzdietz commented on GitHub (Jun 6, 2025):

Depends on whether the ku1ik accepts my PR. If not, which is totally ok as he's the maintainer, you can just patch it in for yourself if you want to have that information for your own build.

<!-- gh-comment-id:2949452588 --> @moritzdietz commented on GitHub (Jun 6, 2025): Depends on whether the ku1ik accepts my PR. If not, which is totally ok as he's the maintainer, you can just patch it in for yourself if you want to have that information for your own build.
Author
Owner

@Cyb3rC3lt commented on GitHub (Jun 8, 2025):

Will this also work if the session isn't ended gracefully @moritzdietz? Like I might have 6 terminals running and when I pause my VM it kills my recording so when I restart the next day having a notification saying the recording has ended would be useful as a reminder to restart it.

Here is me starting a session and pausing my VM at the red line. I then come back after unpausing an issue a 2nd date command to see if the recording is ongoing.

Image

But when I replay the recording I can see it doesnt pick up the 2nd date command as the recording is dead.

Image

I wonder in general should I be pausing all the asscinema recording manually with Ctrl + \ before pausing my VM actually (Edit: just tried this and it doesn't even like it after unpausing and won't continue after resuming a VM). But as an assistance your notification would help too. I could even potentially append the next recording to the recording text in your notification.

<!-- gh-comment-id:2953777489 --> @Cyb3rC3lt commented on GitHub (Jun 8, 2025): Will this also work if the session isn't ended gracefully @moritzdietz? Like I might have 6 terminals running and when I pause my VM it kills my recording so when I restart the next day having a notification saying the recording has ended would be useful as a reminder to restart it. Here is me starting a session and pausing my VM at the red line. I then come back after unpausing an issue a 2nd date command to see if the recording is ongoing. ![Image](https://github.com/user-attachments/assets/27eb3e02-43a3-4639-b3c5-2f34ce5197a1) But when I replay the recording I can see it doesnt pick up the 2nd date command as the recording is dead. ![Image](https://github.com/user-attachments/assets/e4e45f91-2461-431f-af74-afc530ed5b7f) I wonder in general should I be pausing all the asscinema recording manually with Ctrl + \ before pausing my VM actually (Edit: just tried this and it doesn't even like it after unpausing and won't continue after resuming a VM). But as an assistance your notification would help too. I could even potentially append the next recording to the recording text in your notification.
Author
Owner

@moritzdietz commented on GitHub (Jun 8, 2025):

I feel like this is better handled in the forum as this seems to be more troubleshooting the ways you use asciinema itself

<!-- gh-comment-id:2953783921 --> @moritzdietz commented on GitHub (Jun 8, 2025): I feel like this is better handled in the forum as this seems to be more troubleshooting the ways you use asciinema itself
Author
Owner

@ku1ik commented on GitHub (Jun 11, 2025):

I do hope that's included in the next release.

For sure it will be there in the next release, which will come likely next week, and hopefully will be the final RC before the big 3.0 release.

<!-- gh-comment-id:2963376092 --> @ku1ik commented on GitHub (Jun 11, 2025): > I do hope that's included in the next release. For sure it will be there in the next release, which will come likely next week, and hopefully will be the final RC before the big 3.0 release.
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#349
No description provided.