car*_*arl 2 bash visual-studio-code windows-subsystem-for-linux
我想在使用 WSL2 的 vscode 中使用类似oh-my-bash 的东西。但是根据文档:
在 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
Run Code Online (Sandbox Code Playgroud)
……但这似乎没有任何作用。我也尝试过
#!/bin/bash
source ~/.profile
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误/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
更新
下面回答了如何获取配置文件的问题,但我在 WSL2 上的 vs-code 中使用powerline-go 的问题仍然存在,但我将其移至一个新问题以结束此问题。
为了将您的设置保留在当前 shell 中,您需要获取配置而不是仅仅执行它(有关更多详细信息,请参阅此链接)。
问题是 vscode 使用dash加载您的配置文件而不是bash.
然而,source是一个bash关键字,并且不能被 理解dash。因此,您必须使用更可移植的语法 ,.才能使其与dash.
尝试用以下内容替换您的文件(不需要#!/bin/bash):
# if the profile file exists, we source it
if [ -f ~/.profile ]
then
. ~/.profile
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2206 次 |
| 最近记录: |