![](/img/trans.png)
[英]Automatically Execute a command when opening a new Integrated Terminal in VSCode IDE
[英]VSCode: Execute command automatically on WSL terminal opening
每次在 Visual Studio Code(Windows 10)上打开 WSL 终端时,我都想自动执行一个命令。
我没有使用远程 WSL 扩展,只是使用此设置的 WSL 终端: "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe"
我尝试使用terminal.integrated.shellArgs.windows
设置失败。
有没有办法做到这一点?
你可以输入settings.json:
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
"terminal.integrated.shellArgs.windows": [
"-e",
"bash",
"--rcfile",
"/path/to/vscode.bashrc"
]
}
在 vscode.bashrc
source $HOME/.bashrc
your-command
settings.json 要求 vscode 运行以下命令:
"C:\WINDOWS\System32\wsl.exe" -e bash --rcfile /path/to/vscode.bashrc
wsl 的-e
选项运行“bash --rcfile /path/to/vscode.bashrc”
--rcfile
for bash 运行 /path/to/vscode.bashrc 而不是 $HOME/.bashrc
有关详细信息,请参阅https://www.gnu.org/software/bash/manual/bash.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.