如何使用 Visual Studio Code 编辑 .bash_profile?它给了我一个权限错误

Rya*_*lva 4 bash visual-studio-code

我想使用 VS Code 编辑 .bash_profile,但当我尝试保存时它会出现权限错误。Sublime 通常会提示我管理员登录提示。

这是我当前的工作流程...

  1. 从终端,输入代码 ~/.bash_profile
  2. 在 VS Code 中编辑文件
  3. 命令+S
  4. 权限错误:被拒绝

Dan*_*mms 5

sudo在 4 月份的版本中将在权限下运行 vscode 。最初,您需要启动 VSCode 的新实例,它只能编辑root 拥有的文件,有关该功能的更多详细信息,请参阅https://github.com/Microsoft/vscode/issues/3068 。

但是,我建议您更改其所有权~/.bash_profile,因为您没有理由不拥有该文件:

sudo chown YOUR_USER_NAME ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)