synclinks

2022-07-15 12:40 UTC
  • Xyne

Metadata

Description: A tool that synchronizes hierarchies of symlinks.
Latest Version: 2017.8
Source Code: src/
Architecture:
  • i686
  • x86_64
Dependencies:
  • glibc
Arch Repositories:
  • [xyne-i686]
  • [xyne-x86_64]
AUR Page: synclinks
Arch Forum Thread: 137161
Tags:

About

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.

Examples

Basic

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

Basic with update option.

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

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.

What is this good for?

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.

CHANGELOG

2016-04-19

  • Added option to limit links to existing source files when no file list is given.
  • Added option for creating relative symlinks.
  • Fixed more bugs.
  • Added basic unit tests.

2016-04-18

  • Refactored to support globbing in file lists.
  • Dry run and verbose options now work without a file list.
  • Documented with Doxygen.

2012-03-28

  • By default symlinks to missing paths are no longer created. This should avoid problems with directories.
  • A new option, -a, has been added to emulate the previous behavior.

2012-06-04

  • Fixed bug that required two runs to created missing directories.

TODO

TODO

  • create daemon mode using inotify events (see maown)

  1. 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.↩︎

Contact
echo xyne.archlinux.org | sed 's/\./@/'
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0