在 Linux 中将软件注册为编辑器

在 Linux 中将软件注册为编辑器

我通过下载 zip 文件成功在 ubuntu 20.04 上安装了 VSCode,无需 root 权限。但是,当我尝试使用以下命令将其设置为默认编辑器时

update-alternatives --set editor /opt/shared/VSCode-linux-x64/code

它报告错误说/opt/shared/VSCode-linux-x64/code尚未注册,因此无法设置。然后我试过了

update-alternatives --install /usr/bin/editor editor /opt/shared/VSCode-linux-x64/code 0

但再次,它报告没有创建的权限/var/lib/dpkg/alternatives/editor.dpkg-tmp

我的问题是如何在没有 root 权限的情况下将二进制文件注册为编辑器。

答案1

update-alternatives需要 root 权限。如果没有 root 权限,您可以EDITOR在您的~/.profile

export EDITOR='/opt/shared/VSCode-linux-x64/code'

Debian Wiki:文本编辑器

相关内容