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

How do I edit .bash_profile with Visual Studio Code? It gives me a permission error

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

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

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

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

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

sudo chown YOUR_USER_NAME ~/.bash_profile