Adds a dot setup subcommand family (idempotent, re-runnable machine-setup tasks) with a folders task that brings the 8 standard XDG user directories under a fixed short-name convention (Desktop -> .desktop, Documents -> doc, Downloads -> dwn, Music -> mus, Pictures -> pic, Videos -> vid, Templates/Public -> .ignoreme), hardcoded rather than read from ~/.config/user-dirs.dirs -- that file is a separate, manually tracked dotfile whose values can drift or go stale, and the migration must not depend on it being correct. The nested Pictures/Screenshots folder is renamed to pic/screenshots in the same pass. Content left behind in a legacy full-named folder by a fresh XDG-defaults install -- empty or not -- is merged into its short-named replacement. A same-named collision between a legacy folder and its target is never overwritten: it is skipped, reported, and the legacy folder is left in place rather than deleted while something in it could not be merged. --dry-run previews what would move/skip without touching the filesystem. xdg-user-dirs-update runs once afterward to notify running apps/portals.
36 lines
750 B
Fish
36 lines
750 B
Fish
function _dot_setup_usage
|
|
echo "usage: dot setup [<task>]
|
|
|
|
Tasks:
|
|
folders bring the 8 standard XDG user directories under the short-name convention
|
|
help show this message
|
|
|
|
Run 'dot setup <task> help' for details on a specific task.
|
|
|
|
With no task given, runs every setup task."
|
|
end
|
|
|
|
function _dot_setup
|
|
if test "$argv[1]" = help
|
|
_dot_setup_usage
|
|
return 0
|
|
end
|
|
|
|
set -l helper_dir (status dirname)
|
|
source $helper_dir/folders.fish
|
|
|
|
if test -z "$argv[1]"
|
|
_dot_setup_folders
|
|
return $status
|
|
end
|
|
|
|
switch $argv[1]
|
|
case folders
|
|
_dot_setup_folders $argv[2..-1]
|
|
return $status
|
|
case '*'
|
|
_dot_setup_usage
|
|
return 1
|
|
end
|
|
end
|