blob: 7f1874f11cc253632ed037c4aa2ffcbf971e7e10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
Configuration file management
=============================
A simple tool to help share (configuration) files across multiple machines.
Actual files are stored in directories with names roughly matching the `%.+%`
pattern.
The part between the percent signs is the name of an environment variable.
Every file in such a directory gets a symlink in the directory pointed to by
the environment variable.
Directory hierarchies are preserved.
A database of symlinks is maintained in case a shared file is deleted (the
corresponding symlink is then deleted too).
The default database file name is "db.bin", maintained at the top-level
directory with shared files.
This description is obviously confusing; see the complete usage example below.
Usage
-----
Symlinks are managed by `update.sh`.
```
usage: update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run]
```
Pass the `--help` flag to this script to examine its detailed usage
information.
A complete usage example is given below.
In this example, the symlinks to files in "../cfg" must appear in "~/env".
```
> pwd
/cygdrive/d/workspace/personal/config-links
> tree ~/env/
/home/Egor/env
0 directories, 0 files
> tree ../cfg/
../cfg/
└── %ENV%
├── a
│ └── b
│ └── c
│ └── test.txt
└── foo
└── bar
└── baz
6 directories, 2 files
> echo "$ENV"
/home/Egor/env
> ./update.sh --shared-dir ../cfg/
...
> tree ~/env/
/home/Egor/env/
├── a
│ └── b
│ └── c
│ └── test.txt -> /cygdrive/d/workspace/personal/cfg/%ENV%/a/b/c/test.txt
└── foo
└── bar
└── baz -> /cygdrive/d/workspace/personal/cfg/%ENV%/foo/bar/baz
5 directories, 2 files
```
For more realistic usage examples, see
* my [Cygwin environment],
* configuration files for various [Windows apps].
[Cygwin environment]: https://github.com/egor-tensin/cygwin-home
[Windows apps]: https://github.com/egor-tensin/windows-home
Limitations
-----------
Variable names must be alphanumeric.
More precisely, the corresponding directory names must match the
`^%[_[:alpha:]][_[:alnum:]]*%$` regular expression.
Consequently, `ProgramFiles(x86)` (and other weird variable names Windows
allows) are not supported.
License
-------
Distributed under the MIT License.
See [LICENSE.txt] for details.
[LICENSE.txt]: LICENSE.txt
|