micro
micro copied to clipboard
Request: improve conformance with the XDG Base Directory Specification
micro appears to create the file ~/.config/micro/buffers/history, which is not a configuration file. Data generated from the use of an app should be put under ${XDG_DATA_HOME:-~/.local/share}, so it seems like the buffers directory should live at ${XDG_DATA_HOME:-~/.local/share/micro/buffers}. Would you mind updating micro to use that path?
Many thanks for micro, it's awesome. 😄
Commit hash: cfcb2e4 OS: Fedora 33 Terminal: Konsole/bash
This would be great, especially with config/dotfile management systems. With the current behaviour, it's impossible to just track ~/.config/micro/, one has to individually track each config files (settings.json, bindings.json, colorschemes/, etc).
There is already an option to use a custom directory for backups, so this could be implemented similarly for the other things.
Also ~/.config/micro/backups should probably be on ~/.cache/micro/backups instead
Either of data home (.local/share) or state home (.local/state) would seem more appropriate for the backups, especially state since it is defined in the spec at the place for command history, undo history, etc
The current version of the spec is here
Also
~/.config/micro/backupsshould probably be on~/.cache/micro/backupsinstead
The ./backup/* directory is configurable (backupdir). However, it does belong in the $XDG_CACHE_HOME directory rather than $XDG_CONFIG_HOME as-is the current default.
The ./buffers/history file belongs in the $XDG_STATE_HOME/micro/ directory.
The ./buffers/* directory belongs in the $XDG_CACHE_HOME/micro/ directory. (It, arguably, belongs in $XDG_STATE_HOME/micro/ when the savecursor option is enabled (off by default). However, overall it’s closer to cache data than state data.)
#3 Migration strategy
Option A:
- Check if the
lastmigrationoption in the insettings.jsonfile.- If not present or matches a version number lower than the current version number:
- Move the
${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/historyfile to${XDG_STATE_HOME:-$HOME/.local/state}/micro/history. (Skip if the source file doesn’t already exist.) - Move the
${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/directory to${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.) - Move the
${XDG_CONFIG_HOME:-$HOME/.config}/micro/backups/directory to${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.) - Add
"lastmigration": $current_version_numberto the settings file.
- Move the
- If present and equal to the current or a higher version number, then abort.
- If not present or matches a version number lower than the current version number:
Option B:
Just leave the old files in their current location and begin using the new locations. You’ll still likely get 99.8 % user-satisfaction.
Alternative approaches
- Leave the
./buffersand./backupdirectories inside$XDG_CONFIG_HOME. When these folders are created (no migration strategy), mark them as cachy/trashy directories. Automatically add aCACHEDIR.TAGfile into each directory. Also, set the extended attributescom.apple.metadata:com_apple_backup_excludeItemwith a value of[empty](MacOS) andxdg.robots.backupwith a value offalse(Linux) on each directory. Lots of backup and search utilities will know to ignore them by default. There’s nothing equivalent on Windows. - Add
buffersdirandhistoryfileconfiguration options but leave the current defaults (or take the opportunity to adjust their defaults with the implementation of these options).