VS Code终端中是否有用于当前文件或文件夹的变量?

wtj*_*nes 6 powershell visual-studio-code

在终端窗格中时,我想通过环境变量或PowerShell变量(首选)引用活动编辑器选项卡的文件或文件夹。像这样:

ii $vsActivePath

要么

ii $vsActiveFile

这可能吗?

Ste*_*son 2

不确定这是否正是您正在寻找的,但您可以访问 VS Code 中的各种变量,例如:

${workspaceRoot} the path of the folder opened in VS Code
${workspaceRootFolderName} the name of the folder opened in VS Code without any slashes (/)
${file} the current opened file
Run Code Online (Sandbox Code Playgroud)

完整的详细信息可以在这里找到

  • 如何在终端中访问它? (4认同)