mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 19:39:15 +00:00
adding mkdocs
This commit is contained in:
54
docs/howto/create-special-files.md
Normal file
54
docs/howto/create-special-files.md
Normal file
@@ -0,0 +1,54 @@
|
||||
One way for creating symlinks (or any other special files) is to use a combination of
|
||||
[actions](usage-actions) and a *fake* dotfile.
|
||||
|
||||
Let's say for example you have a list of directories you want to link
|
||||
from under `~/.original` to `~/symlinks`.
|
||||
```bash
|
||||
$ tree ~/.original
|
||||
/home/user/.original
|
||||
├── dir1
|
||||
├── dir2
|
||||
└── dir3
|
||||
```
|
||||
|
||||
First you would store these directories names in a text file in your `<dotpath>/links.txt`
|
||||
```
|
||||
dir1
|
||||
dir2
|
||||
dir3
|
||||
```
|
||||
|
||||
The config file would contain different elements
|
||||
* a `dynvariables` that will read the above text file
|
||||
* a few `variables` for the source and destination
|
||||
* an action that will create the destination directory and symlink those directories
|
||||
* a *fake* dotfile (with no `src` and no `dst` values) that will be always installed with the above action
|
||||
|
||||
```yaml
|
||||
dynvariables:
|
||||
links_list: "cat {{@@ _dotdrop_dotpath @@}}/links.txt | xargs"
|
||||
...
|
||||
variables:
|
||||
links_dst: "{{@@ env['HOME'] @@}}/.symlinks"
|
||||
links_src: "{{@@ env['HOME'] @@}}/.original"
|
||||
...
|
||||
actions:
|
||||
symlink_them: 'mkdir -p "{1}" && for lnk in {0}; do ln -s "{{@@ links_src @@}}/$lnk" "{1}/$lnk"; done'
|
||||
...
|
||||
fake:
|
||||
src:
|
||||
dst:
|
||||
actions:
|
||||
- symlink_them '{{@@ links_list @@}}' '{{@@ links_dst @@}}'
|
||||
```
|
||||
|
||||
The result would be
|
||||
```bash
|
||||
$ tree ~/.symlinks
|
||||
/home/user/.symlinks
|
||||
├── dir1 -> /home/user/.original/dir1
|
||||
├── dir2 -> /home/user/.original/dir2
|
||||
└── dir3 -> /home/user/.original/dir3
|
||||
```
|
||||
|
||||
For reference, see [issue 243](https://github.com/deadc0de6/dotdrop/issues/243)
|
||||
Reference in New Issue
Block a user