[英]Is there a way to open all files in a directory in the current workspace using the VS Code CLI?
I want to open all files under /var/log/my_program/
in my current open workspace.我想在当前打开的工作区中打开
/var/log/my_program/
下的所有文件。 To be clear, I want to open the files from this directory while keeping the files that are already open in my current workspace open as well.需要明确的是,我想打开这个目录中的文件,同时保持当前工作区中已经打开的文件也保持打开状态。
eg if I have ~/hello-world.html
open, I would like to open /var/log/my_program/error.log
and /var/log/my_program/access.log
in the workspace as well, having a total of 3 files open at the same time in the same window/workspace.例如,如果我打开了
~/hello-world.html
,我也想在工作区中打开/var/log/my_program/error.log
和/var/log/my_program/access.log
,总共有 3 个文件在同一窗口/工作区中同时打开。
if I run code /var/log/my_program/*
it will open up a new window with all of the files open from that directory.如果我运行
code /var/log/my_program/*
它将打开一个新的 window ,其中所有文件都从该目录打开。 ie hello-world.html
will be in one window and error.log
and access.log
will be in a new window即
hello-world.html
将在一个 window 和error.log
和access.log
将在一个新的 window
if I run code -r /var/log/my_program/*
it will overwrite my current workspace with the files from that directory.如果我运行
code -r /var/log/my_program/*
它将用该目录中的文件覆盖我当前的工作区。 ie hello-world.html
will no longer be open in any window, and error.log
and access.log
will be open in my original workspace window.即
hello-world.html
将不再在任何 window 中打开, error.log
和access.log
将在我原来的工作区 window 中打开。
I want to be able to keep the state of my current workspace AND open the files from the /var/log/my_program/
directory.我希望能够保留当前工作区的 state 并从
/var/log/my_program/
目录打开文件。 ie I would like hello-world.html
to stay open in the workspace AND have error.log
and access.log
open as well.即,我希望
hello-world.html
在工作区中保持打开状态,并同时打开error.log
和access.log
。
I would like to add that this is just a simplified example of what I am trying to do.我想补充一点,这只是我正在尝试做的一个简化示例。 I understand it would be easy enough to just open these two files easily in the command line, but the actual files in the dir I want to open could be several and all with timestamps in their names, so I cant easily open them by name
我知道在命令行中轻松打开这两个文件就很容易了,但是我要打开的目录中的实际文件可能有几个,而且它们的名称中都带有时间戳,所以我不能轻松地按名称打开它们
Is this possible?这可能吗? Thanks for any help!
谢谢你的帮助!
EDIT: I am really looking for a solution using the CLI.编辑:我真的在寻找使用 CLI 的解决方案。 I am running a command similar to
rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*
我正在运行类似于
rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*
的命令rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*
rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*
. rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*
。 This is so the dir doesnt get full of old log files, and I can see the new log files opened after I have restarted the process for my_program
这样目录就不会充满旧的日志文件,并且在我重新启动
my_program
的进程后,我可以看到打开的新日志文件
The reasoning for all of this is to make my debugging routine less cumbersome, eg without mouse clicks or gui interaction所有这一切的原因是为了让我的调试程序不那么繁琐,例如无需鼠标点击或 gui 交互
In VS CODE itself there is a keyboard shortcut that might be helpful: ctrl + r
Which will open a drop down of folders.在 VS CODE 中,有一个可能有用的键盘快捷键:
ctrl + r
这将打开一个下拉文件夹。 Once you arrow down/up to the desired folder, you have two options: Click enter
to open the new folder instead of the current workspace, or ctrl + enter
to open a new folder in addition to the current open workspace向下/向上箭头到所需文件夹后,您有两个选项:单击
enter
打开新文件夹而不是当前工作区,或ctrl + enter
打开当前打开工作区之外的新文件夹
If I understand what you are trying to do correctly, you want to use the --add
argument.如果我理解您要正确执行的操作,则您想使用
--add
参数。 You can run code --reuse-window --add <path>
to open the folder at <path>
in the current workspace.您可以运行
code --reuse-window --add <path>
以打开当前工作空间中<path>
处的文件夹。 The shortened version would be code -r -a <path>
.缩短的版本是
code -r -a <path>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.