Edit yaml objects in array with yq. Speed up Terminalizer's terminal cast (record)

此生再无相见时 提交于 2019-12-11 06:17:04

问题


The goal: Speed up Terminalizer's terminal cast (record)

I have a record of terminal created with Terminalizer. cast.yaml:

# The configurations that used for the recording, feel free to edit them
config:
  # do not touch it

# Records, feel free to edit them
records:
  - delay: 841
    content: "\e]1337;RemoteHost=kyb@kyb-nuc\a\e]1337;CurrentDir=/home/kyb/devel/git-rev-label\a\e]1337;ShellIntegrationVersion=7;shell=fish\a"
  - delay: 19
    content: "\e]1337;RemoteHost=kyb@kyb-nuc\a\e]1337;CurrentDir=/home/kyb/devel/git-rev-label\a\e]0;fish /home/kyb/devel/git-rev-label\a\e[30m\e(B\e[m"
  - delay: 6
    content: "\e[?2004h"
  - delay: 28
    content: "\e]0;fish /home/kyb/devel/git-rev-label\a\e[30m\e(B\e[m\e[2m⏎\e(B\e[m                                                                                                                                                        \r⏎ \r\e[K\e]133;D;0\a\e]133;A\a\e[44m\e[30m ~/d/git-rev-label \e[42m\e[34m \e[42m\e[30m demo  \e[30m\e(B\e[m\e[32m \e[30m\e(B\e[m\e]133;B\a\e[K"
  - delay: 1202
    content: "#\b\e[38;2;231;197;71m#\e[30m\e(B\e[m"
  - delay: 134
    content: "\e[38;2;231;197;71m#\e[30m\e(B\e[m"
  - delay: 489
    content: "\e[38;2;231;197;71m \e[30m\e(B\e[m"
  - delay: 318

I want to speed up payback without passing --speed-factor to terminalizer play. To do so delays should be decreased.

So, I need to create yq-expression to make delays lower

.records.delay=.records.delay/3

but this expression won't work. Please help to write proper one.


回答1:


.records is an array, so you could use this filter:

.records |= map(.delay /= 3)

Or you might prefer:

.records[].delay |= (. /= 3)


来源:https://stackoverflow.com/questions/57626741/edit-yaml-objects-in-array-with-yq-speed-up-terminalizers-terminal-cast-recor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!