英文:
How can I trigger previous commands from the VS Code task terminal?
问题
在下面的问题中,nx恰好是启动任务终端的插件,但我的问题适用于在VS Code中运行的任何任务命令。
当我通过nx插件运行nx任务时,它会启动一个特殊类型的集成终端来运行任务命令。
然而,当我想要重新运行该任务命令时,我无法从终端中执行,因为它是一种特殊类型的终端。这非常令人沮丧,因为我必须回到nx插件,以便重新运行命令,而不是直接从终端视图中执行。
如何重新运行刚刚从终端运行的任务命令?
我在这里附上了一个带有注释的截屏,以显示终端的外观:
英文:
In my question below, nx just happens to be the plugin launching the task terminal, but my question applies to any task command that is run in a special terminal in VS Code.
When I run an nx task via the nx plugin, it launches a special type of integrated terminal that runs the task command.
However, when I want to re-run that task command, I can't do it from the terminal since it is a special type of terminal. This is very frustrating because I have to jump back to the nx plugin in order to rerun the command instead of doing it directly from the terminal view.
How can I rerun the task command that was just run from the terminal?
I'm attaching an annotated screenshot here to show what the terminal looks like:
答案1
得分: 1
以下是翻译好的内容:
从重新运行上次任务#25310的解决方法:
-
您可以绑定一个键盘快捷键到该任务,以便通过键盘轻松访问(来源)。例如:
{ "key": "ctrl+h", // TODO 选择一个键 "command": "workbench.action.tasks.runTask", "args": "foo" // 任务名称 }
-
使用命令面板中的
任务:重新运行上次任务
命令(来源),并可选择将该命令绑定到键盘快捷键以便更容易通过键盘访问。
您可能对这个功能请求问题感兴趣:在运行任务的右键菜单中添加重新启动任务按钮。#182248。不幸的是,它没有得到足够的社区支持,没有及时添加到待办事项中。
请注意,如果任务是shell/process类型的任务(是的,我知道这个问题不是关于shell/process类型的任务),如果您启用了shell集成,应该会有一个重新运行命令的按钮(还请参考https://github.com/microsoft/vscode/issues/153451,其中添加了此功能的测试)。
供您参考/学习的目的,此信息是通过搜索“github vscode issues button rerun task
”而找到的。
英文:
Workarounds from Re-run Last Task
#25310:
-
You can bind a keyboard shortcut to the task to make it easy to access via keyboard (source). Ex.
>json
> {
> "key": "ctrl+h", // TODO pick a key
> "command": "workbench.action.tasks.runTask",
> "args": "foo" // the task name
> }
> -
Use the
Tasks: Rerun Last Task
command in the command palette (source), and optionally bind that command to a keyboard shortcut to make it easier to access via keyboard.
You may be interested in this feature-request issue ticket: Add a restart task button into the right-click menu of running task. #182248. Unfortunately, it didn't get enough community support in time to get added to the backlog.
Note that if the task is a shell/process-type task (yes- I know this question is not about shell/process-type tasks), if you have shell integration on, there should be a button to re-run the command (see also https://github.com/microsoft/vscode/issues/153451, which added testing for this feature).
For your reference / learning purposes, this info was found by googling "github vscode issues button rerun task
".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论