Skip to content
Mat M edited this page Dec 17, 2020 · 7 revisions

DRAFT

All that define rcm behavior

May be included in man pages one day ?

RCM defaults

RCRC config file

The file is not mandatory, but always searched for.

  • If RCRC variable is set, use the contents as target location for rcrc file.
  • Else target location is $HOME/.rcrc

If file does not exist at target, consider no file exists.

dotfiles location

Locations checked, in order :

  • The ones specified with -d option on commandline
  • The ones specified in RCRC file
  • The last location check is the default, currently $HOME/.dotfiles
  • mkrc
    • Currently, in mkrc, we get the first defined path, even if it doesn't exist. It will be created if not available (and if permissions allow it).
    • In fix_mkrc_doc_206 branch, we stop at the first existing directory, and abort if none found
  • rcup, rcdn and lsrc have the same behavior
    • Currently, if a -d option is given, it overrides the values in RCRC
    • The default value is appended to the list.

mkrc

mkrc registers files in your dotfiles directory. The first in the list is used (check §"dotfiles location" above)

Workflow

  • Get specific options (includes reading rcrc file)
  • Identify all files to handle (wildcards from commandline)
    • Automatically exclude files which are a symlink or located in a symlinked directory below $HOME
  • Loop to
    • create the path
    • move the file there (without dot)
    • install back with rcup

appendix

  • FIXME: mkrc builds all args for -S and -u => Move to one loop on files, and generate shorter commands to update, pushing symlink and undotted params to install_args

rcup

rcup updates $HOME with files from your dotfiles directories. FILES arguments are files relative to $DOTFILES_DIR

worfklow

  • Get specific options (includes reading RCRC file)
  • Trigger pre up hooks
  • Use lsrc to list all files (origin and dest)
  • Loop on all files
    • if file exists, try to replace it
    • else link it
  • Trigger post up hooks

appendix

Add sample usage of hooks

rcdn

rcdn removes installed dotfiles from your $HOME. It doesn't remove any files from the dotfiles directory

The Copied files are removed if they were added to the COPY_ALWAYS variable, either on commandline or in RCRC

workflow

  • Get specific options (includes reading RCRC file)
  • Trigger pre down hooks
  • Use lsrc to list all files (origin and dest)
  • Loop on all files
    • walk back the path from file to $HOME
      • if symlink exists, remove it
      • if file exists and is in "COPY_ALWAYS", remove it
  • Trigger post down hooks

appendix

Suggest a -C option to enforce a copied file to be removed without requiring the COPY_ALWAYS

Add sample usage of hooks

lsrc

lsrc lists all dotfiles, at origin and destination, for all dotfiles directories found.

It is actually this program which computes how a file will be delivered.

workflow

  • Get specific options (includes reading RCRC file)
  • Loop on all dotfiles directories (first found file takes precedence)
    • if there is a host folder, walk into it and process files
    • if there is a tag folder, walk into it and process files
    • process standard files

File processing is:

  • if current file doesn't exist, simply skip it
  • if current file is excluded, skip it
    • a file is excluded if its basename or its full path inside dotfiles directory match an exclusion
  • if current file is a folder and is not in the SYMLINK_DIRS list
    • recurse into it and loop back to File processing
  • else (current file is not excluded or is a to-be-symlinked dir)
    • build destination absolute path
    • compute origin absolute path
    • add sigil if required
    • if destination wasn't already handled, display the pair origin:destination
      • already handled, by a host-* dir, a tag-* dir, or a previous dotfiles directory

appendix

Check if test exists for commit a7c2b6bed845b8512e878c992e07841ea9b88462