tmux-resurrect icon indicating copy to clipboard operation
tmux-resurrect copied to clipboard

Allow XDG standards on save-dir.

Open dansdantas opened this issue 5 years ago • 6 comments

Pretty much the title. I just want to use $XDG_DATA_HOME/tmux/resurrect as my save directory.

Thanks for your hard work.

dansdantas avatar May 28 '20 11:05 dansdantas

You can do set -g @resurrect-dir "$XDG_DATA_HOME/tmux/resurrect". Note the double quotes.

The doc is misleading about this. This will work assuming that XDG_DATA_HOME is exported in the environment when your tmux configuration is loaded.

sgleizes avatar May 28 '20 23:05 sgleizes

I think this should be re-opened. Being able to set set -g @resurrect-dir "$XDG_DATA_HOME/tmux/resurrect" isn't really supporting the XDG standard.

  • Each user must find this themself and configure accordingly.
  • As commented by @sgleizes, the doc says one cannot use arbitrary shell variables, so using that configuration is basically "undefined behaviour".
  • Implementing the XDG spec means that "if $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used." (how would users do that without tmux-resurrect support?)

My config is now set-option -g @resurrect-dir "~/.local/share/tmux/resurrect", but I wish I didn't have to do that.

bjornfor avatar Dec 16 '20 19:12 bjornfor

Agreed. This should be the order priority:

  • @resurrect-dir tmux var
  • TMUX_PLUGIN_MANAGER_PATH (from tpm is present) + /resurrect/
  • XDG_DATA_HOME (if present) + ~~/resurrect/~~ /tmux/resurrect/
  • $HOME/.tmux/resurrect

bruno- avatar Dec 17 '20 13:12 bruno-

XDG_DATA_HOME (if present) + /resurrect/

Nitpick, but perhaps use one of these instead of /resurrect/?

  • /tmux/resurrect/
  • /tmux-resurrect/

Oh, and more importantly think if XDG_DATA_HOME is unset, the default directory ~/.local/share should be used instead (ref. the spec). That would mean that $HOME/.tmux/resurrect is only used if it already exists, for backwards compatibility.

bjornfor avatar Dec 17 '20 18:12 bjornfor

@bjornfor Exactly! In bash, this would be as simple as using

${XDG_DATA_HOME:-$HOME/.local/share}

to use the default value for the data directory if the envvar is not set.

+1 for being XDG compliant without the need for configuration. Tmux is XDG compliant since v3.1.

erikw avatar Jan 06 '22 11:01 erikw

Also, why would we default to ~/.tmux/resurrect (or ~/.tmux-resurrect), instead of defaulting to ~/.local/share/...? The latter feels like behavior that is more aligned with the spirit of the XDG specification.

sudoforge avatar Jul 20 '22 14:07 sudoforge