XDG_*_DIR 用户目录变量应该在哪里/如何设置?

ani*_*ick 4 xdg xdg-user-dirs

我指的是:https ://specations.freedesktop.org/basedir-spec/basedir-spec-latest.html

我的目录中有以下文件.config

~/.config/user-dirs.dirs:

# ...
XDG_DOWNLOAD_DIR="$HOME/downloads"
# ... there are only comments in this file, except the line above ...
Run Code Online (Sandbox Code Playgroud)

(我猜这个文件需要从某个地方获取?但是在哪里以及如何获取?)

~/.config/user-dirs.conf:

enabled=False
Run Code Online (Sandbox Code Playgroud)

(这个文件似乎是防止xdg-user-dirs-update覆盖所必需的~/.config/user-dirs.dirs。)

但是,$XDG_DOWNLOAD_DIR当我运行 shell 时并未设置。

XDG * DIR 用户目录变量应该在哪里/如何设置?

我是否应该获取~/.config/user-dirs.dirs由我的登录 shell 获取的文件之一(例如,在 中.bash_profile)?

Yun*_*nus 6

这样设置

xdg-user-dirs-update --set DOWNLOADS ${HOME}/Downloads;
Run Code Online (Sandbox Code Playgroud)

更新所有 xdg 目录

xdg-user-dirs-update;

source ${HOME}/.config/user-dirs.dirs;
Run Code Online (Sandbox Code Playgroud)

  • 正如您希望在 .bashrc 中用于终端会话(交互式 shell)或/和内部脚本一样,是的,您应该在所有情况下获取它!或者通过这种方式获取特定的 var `xdg-user-dir DOWNLOADS` (2认同)