1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 19:44:45 +00:00
Files
dotdrop/docs/howto/create-special-files.md
2020-09-13 22:46:37 +02:00

1.5 KiB

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 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
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