Description: |
A tool that synchronizes hierarchies of symlinks. |
Latest Version: |
2013 |
Architecture: |
|
Arch Repositories: |
|
AUR ID: |
|
Arch Forum ID: |
|
Tags: |
synclinks is a tool for synchronizing a hierarchy of symlinks. It's a bit like a limited version of rsync that creates synclinks instead of copying the files.
synclinks foo bar
This will traverse the directory "foo" and create a symlink at the same relative path in "bar" for every file that it finds. For example, given "foo" with
foo/bar.txt
foo/baz/whatever.txt
synlinks will create
bar/bar.txt -> foo/bar.txt
bar/baz/whatever.txt -> foo/baz/whatever.txt
synclinks -u foo bar
The update option will make synclinks traverse "bar" first and copy any files in bar to "foo". It will then continue as above. This ensures that any files created in "bar" (i.e. completely new files or replaced symlinks) will be moved to "foo", so that "foo" continues to contain all of the real files.
File lists are where the real functionality of synclinks lies. A file list is a plaintext file with a relative path on each line, for example:
a.txt
b.txt
d.txt
img
Running
synclinks -f /path/to/file foo bar
would then create
bar/a.txt -> foo/a.txt
bar/b.txt -> foo/b.txt
bar/d.txt -> foo/d.txt
bar/img -> foo/img
In this case, if "foo" contains e.g. c.txt, it will not be symlinked in "bar". This allows you to expose a subset of the files in "foo". Furthermore, the paths in the file list may be directories (e.g. "img" in this case) and they do not need to exist when synlinks is run.1
Including the upgrade option when using a file list will move both files and directories back to the source directory.
I wrote this as part of a solution to manage clutter in my home directory. Some applications create files that I want to keep but most just clutter up my home directory with crap. With synclinks, I can keep the files that I want in a given location and then use filelists to symlink those into a temporary home directory in which I run applications. When I'm done, I use the update option to copy back any changes in my chosen files to the source files that I have in a different directory. After that I can just discard the entire temporary home directory.
I'm sure that there are other uses for this though.
$ synclinks --help
Usage: synclinks [OPTION...] <source dir> <dest dir>
Create symlinks in <dest dir> to paths in <source dir>. The paths may be
specified as relative paths to <source dir> in a file list list with the -f
option, otherwise the entire directory hierarchy is mirrored and all
non-directory items are symlinked.
-a Always create links even when the target does not
exist. This is only useful for links that will
point to files, because the target file will be
created when writing to the link. If you use this
option when linking directories, then make sure
that empty directories are created in <source dir>
before using the links in <dest dir>. Otherwise,
skip this option and let your applications create
directories in <dest dir>, then run synclinks with
the update option to copy them to <source dir>
before linking them.
-b <backup dir> Set a backup directory path for updated files.
File name extensions will be added to indicate the
original location of the files. If this path is
not set then the files will be saved in their
original directory. This currently only works with
file lists.
-d Dry run. Print messages without creating or
removing any files. This currently only works with
file lists.
-f <file list> Read paths from <file list>. This is the main
functionality of synclinks. <file list> is a
plaintext file with paths on separate lines. Each
path is a relative path to a file or directory in
<source dir> and will be used to create a
corresponding symlink in <dest dir>. For example,
the line "foo" will create a symlink at "<dest
dir>/foo" that points to "<source dir>/foo".
-u Update files in <source dir> to match files in
<dest dir>. This is useful if new files have been
added to the file list or if an application has
removed a symlink and created a regular file in
<dest dir>. This currently only works with file
lists.
-v Verbose mode. This currently only works with file
lists.
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
-a, has been added to emulate the previous behavior.You should create directories first though so that the symlinks will work as expected. Writing to a symlink that points to a missing file will create the file. Trying to create files in a missing directory through a symlink will not create the directory.↩