zechris / asciinema-rec_script

Record 💭 comments and ❯ commands from from shell scripts in addition to their output.
https://github.com/asciinema/asciinema#rec-filename
GNU General Public License v3.0
27 stars 4 forks source link

[SUGGESTION] shebang and agg support #61

Closed ademariag closed 1 year ago

ademariag commented 1 year ago

Hello,

what a cute little script, thank you for this.

Just to let you know that I have made a couple of changes in my copy.

  1. I am adding the script as shebang on my scripts :) so that it looks like
#!/usr/local/bin/asciinema-rec_script

## Date maths

# The `date` command can be used to retrieve the:
#  * *day of the week* using the `%l` option
day_of_the_week=$(date +%l)

#  * *hour of the day* using the `%u` option
hour=$(date +%u)
  1. I have also added support for generating gifs using agg
asciinema_rec "$script" --title "${title:-${script##*/}}" "${args[@]}"
agg ${screencast} ${screencast%.cast}.gif 
zechris commented 1 year ago

Nice one @ademariag!

  1. probably better to use #!/usr/bin/env asciinema-rec_script as the shebang.

  2. ahhh i didn't know about agg - it looks great!

  3. any chance you could figure out the next (no doubt hugely popular) step and get the screencast gif creation to work in a github hosted container which hooks up to a github action?

ademariag commented 1 year ago

Thank you @zechris ,

1) yes, of course, thank you

2) only watch out because it doesn't support the terminal icons you print

3) ...I see what you are doing there 🤣 ... will see.

What I would like to see, is for something that reads a Markup page.

The different headers could become sections, where you would normally clear the screen.

You would solve the multi line commands because you would find the

blocks

potentially opening to also run other things, like Python scripts.

This all would be very helpful to also make it easier to generate tutorials on the likes of udemy

zechris commented 1 year ago

Thanks @ademariag,

  1. i wonder if agg (or a container it could run in) could get an update ... although I'm not so fussed about the icons, so maybe we should just change them.

  2. yer i gave it a lengthy shot, but got tripped up by some annoying permission issue then gave up

  3. "reading a Markup page" ... ahh I think I get what you're getting at... and yer I had to make a workaround for multi-line commands.

The advantage of how it is now is that an .sh script can be interpreted and run directly by the shell or it can be fed in as input to asciinema-rec_script, allowing boring old scripts like demo-date_maths to spring into life as a screencast without any need for a rewrite.

... but yer - I guess the question is how useful is that compared to other ideas like your Markup page. (which could potentially support running eg. python scripts as well.) ... I dunno ... perhaps there's room for both ideas?

ademariag commented 1 year ago

Hey, also check out https://github.com/maaslalani/slides.

This is what I was after. If we could combine the 2 projects it would be amazing. Basically a way to create tutorial, slideshows that can be easily be turned into a gif recording

zechris commented 1 year ago

Wow - that looks brilliant! It might be easier though, to run slides in some kind of scripted mode, then just make a screen recording of that. (Or if it doesn't / can't be extended to have a scripted mode, then just use something else to pipe into it a sequence of key strokes at given times.)

Which kinda makes me think more that this project should stay just as a simple way to augment boring bash scripts into more interesting screen recordings.

Haha - again though - if someone could figure out how to automate the creation of these screen recordings in a github action - that would be the most useful thing.

ademariag commented 1 year ago

Hey,

there is also this https://github.com/charmbracelet/vhs/tree/main/examples/slides which runs in scripted mode, which also supports actions https://github.com/charmbracelet/vhs-action/tree/main

By all mean I don't mean to change the directions of this project, just sharing alternative to serve as inspiration. Thank you so much for your project!