Как интерактивно запустить все команды в файле в zsh?

В sysfs такой настройки нет. Патч не был принят в основную ветку. Вам понадобится ядро ​​с установленным патчем.

https://lore.kernel.org/lkml/20131122154505.3e686fcfc584534d555399e5@linux-foundation.org/

Well the patch is certainly simple and straightforward enough and seems like it will be useful. The main (and large!) downside is that it adds to the user interface so we'll have to maintain this feature and its functionality for ever.

Given this, my concern is that while potentially useful, the feature might not be sufficiently useful to justify its inclusion. So we'll end up addressing these issues by other means, then we're left maintaining this obsolete legacy feature.

So I'm thinking that unless someone can show that this is good and complete and sufficient for a "large enough" set of issues, I'll take a pass on the patch.

1
01.12.2020, 23:16
1 ответ
run_carefully() {
  # Take the first arg as a file name, read the file and split it on newlines.
  local cmd; for cmd in ${(f)"$(<$1)"}; do
    # Let the user edit (or delete) the command, before evaluating it.
    vared cmd
    eval "$cmd"
  done
}

В качестве альтернативы мы могли бы позволить пользователю редактировать весь список команд, прежде чем запускать их все сразу:

run_all_carefully() {
  # Take the first arg as a file name and read the file.
  local list="$(<$1)"

  # Let the user edit the list of commands, before evaluating it.
  vared list
  eval "$list"
}

Обратите внимание, что в обоих случаях Enter принимает все редактирование, тогда как AltEnter вставляет новую строку без выхода из редактора. Во втором случае, когда все команды редактируются одновременно, вы можете настроить свою собственную раскладку клавиатуры (, переданную vared с опцией -M), где вы поменяете местами эти две.

Документация:

1
18.03.2021, 22:45

Теги

Похожие вопросы