-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
199b3df
commit 5be8097
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function asciicast_ezgif_durations -a file | ||
set -l times (string match -rg "^\[([\d.]*)" <$file) | ||
|
||
set -l durations # Durations in hundredths of seconds | ||
|
||
set -l prev_time $times[1] | ||
for time in $times[2..] | ||
set -a durations (math --scale=0 "($time - $prev_time) * 100") | ||
set prev_time $time | ||
end | ||
|
||
set -l file_text (cat $file) | ||
for duration in $durations | ||
string replace -r "^\[[\d.]*" $duration $file_text[1] | ||
set -e file_text[1] | ||
end >$file | ||
end |