【发布时间】:2019-12-09 13:12:02
【问题描述】:
我想在使用 WSL2 的 vscode 中使用 oh-my-bash 之类的东西。不过根据docs:
在 WSL 中启动 VS Code Remote 时,不会运行任何 shell 启动脚本。这样做是为了避免针对 shell 调整的启动脚本出现问题。如果您想运行其他命令或修改环境,可以在设置脚本
~/.vscode-server/server-env-setup(内部人员:~/.vscode-server-insiders/server-env-setup)中完成。如果存在,则在启动服务器之前处理脚本。
我添加了~/.vscode-server/server-env-setup,根据日志找到并执行了它,但我的 linux 技能非常基础,我不知道如何安装我的配置文件。我试过了
bash ~/.profile
...但这似乎没有任何作用。我也试过了
#!/bin/bash
source ~/.profile
这给了我一个错误/mnt/c/Users/cber/.vscode/extensions/ms-vscode-remote.remote-wsl-0.40.3/scripts/wslServer.sh: 3: /home/cber/.vscode-server/server-env-setup: source: not found
更新
下面回答了如何获取配置文件的问题,但是我让powerline-go 在 WSL2 上的 vs-code 中工作的问题仍然存在,但我将它移到了new question 以关闭这个。
【问题讨论】:
-
bash ~/.profile将在新的子 shell 中执行您的.profile文件,然后退出,有效地丢弃所做的修改。您要查找的关键字是source ~/.profile -
@Aserre,我也试过
source ~./profile,这给了我一个错误/mnt/c/Users/cber/.vscode/extensions/ms-vscode-remote.remote-wsl-0.40.3/scripts/wslServer.sh: 3: /home/cber/.vscode-server/server-env-setup: source: not found。进行了一些搜索并找到了this,所以我尝试将#!/bin/bash添加为第一行,但在使用源代码时我仍然遇到同样的错误。 -
你能显示你的
/home/cber/.vscode-server/server-env-setup文件的内容吗?你能告诉我们当你把readlink /proc/$$/exe放在第一行时会发生什么吗? -
@Aserre,该文件目前看起来像
bash #!/bin/bash source ~/.profile...如果我将其更改为bash readlink /proc/$$/exe source ~/.profile...它输出/bin/dash
标签: bash visual-studio-code windows-subsystem-for-linux