如何将 /etc/environment 变量更改应用于 Ubuntu 中的特定 GUI 应用程序

如何将 /etc/environment 变量更改应用于 Ubuntu 中的特定 GUI 应用程序

有没有办法将 /etc/environment 变量中的更改应用于特定的 GUI 应用程序(例如 Ubuntu 中的 IntelliJ),而无需注销/重新启动系统?

答案1

/etc/environment 仅用于设置默认用户环境,其中的值可以被覆盖。只需创建一个脚本,export VAR=....在调用应用程序之前设置相关变量的值:

export VAR=value
command "$@"    # All args to the script are passed verbatim to the command

对于更简单的情况,你也可以使用单行语法

VAR=value command arg1 arg2 ....

使用 VAR 的特定值执行命令。

相关内容