mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 22:04:44 +00:00
1.5 KiB
1.5 KiB
Create files on install
One way for creating symlinks (or any other special files) is to use a combination of 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.
$ 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
dynvariablesthat will read the above text file - a few
variablesfor the source and destination - an action that will create the destination directory and symlink those directories
- a fake dotfile (with no
srcand nodstvalues) that will be always installed with the above action
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
$ 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