mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-07 05:20:43 +00:00
adding mkdocs
This commit is contained in:
31
docs/howto/append.md
Normal file
31
docs/howto/append.md
Normal file
@@ -0,0 +1,31 @@
|
||||
Sometimes it might be useful to be able to append some text to a
|
||||
file. Dotdrop is able to do that with the help of
|
||||
[actions](https://github.com/deadc0de6/dotdrop/wiki/usage-actions)
|
||||
and a temporary file.
|
||||
|
||||
Below is a config example to append to a file:
|
||||
```yaml
|
||||
dynvariables:
|
||||
tmpfile: mktemp
|
||||
variables:
|
||||
somefile_final: ~/.somefile
|
||||
dotfiles:
|
||||
f_somefile:
|
||||
dst: "{{@@ tmpfile @@}}"
|
||||
src: somefile
|
||||
actions:
|
||||
- strip "{{@@ somefile_final @@}}"
|
||||
- append "{{@@ tmpfile @@}}" "{{@@ somefile_final @@}}"
|
||||
actions:
|
||||
pre:
|
||||
strip: "sed -i '/^# my pattern$/,$d' {0}"
|
||||
post:
|
||||
append: "cat {0} >> {1}; rm -f {0}"
|
||||
```
|
||||
During installation, the `strip` action is executed before the installation and strips everything from the pattern `# my pattern` to the end of the file. Then the dotfile `somefile` is installed in a temporary location (here `tmpfile`) and finally the post action `append` will append the content of the `tmpfile` to the final dotfile pointed by `somefile_final`
|
||||
|
||||
Obviously the dotfile in the dotpath should start with a unique pattern (here `# my pattern`):
|
||||
```
|
||||
# my pattern
|
||||
this is the end
|
||||
```
|
||||
Reference in New Issue
Block a user