[Linux] Using selective YAML fields in header file for all your DB's at once #412
rohanbatraio
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
With 256 databases seems to have taken advantage of the plugin =0 in the future we will improve the integration between the different tables |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
NOTE -> I am not sharing the exact code, rather i am indicating what is my solution. Sharing the code is not possible as every vault is made different and i am proposing HOW you can do it , not LET SCRIPT DO IT. All of the code is partial and left for the user to understand and execute, don't just run any script of github. That can have malicious effect.
i have about 256 databases of different subjects, and i want to add a header template so in theory i have to find a specific file inside these databases, say file-1 is chosen in every database. By making this choice i had a problem that i don't need all the YAML like date created modified to show up in my table. So here i am sharing the solution i followed in this case.
Environment Linux
metaphor sops -> means database and they are the same thing
I used bash command to find all the sops that are scattered around the vault, you can easily use find utility for that.
Going forward i grabbed "source_form_result:" of each of the sop which will come handy later. Now i created a single empty markdown file with exact YAML that i want in all my sops. I gave that file a name starting from 0000, don't worry this file is a temporary file and would be discarded once our work is done. now remember we scraped all the tags now i would use those tags in this temporary file so that this file would show first in the header template.
In this way you can achieve selective YAML fields
Any alternative way / faster way is most welcome, do let me know.
edit -> IT IS NOT an ideal choice if you really love your tags, and if you are tag primary user please skip this solution as this may have messy effects on your structure of sops. We are appending about 256 tags in a single document and automating and correcting which tag belong to which is not an easy task but i am proposing some solutions.
before updating renaming the YAML entry of tag of original sops to tags-bkp and then using this script and then replacing tags with tags-backup is the only possible solution i can think of right now. Will keep this discussion updated.
edit-2 --> FOR ALL TAG USERS
run this to get all tags that are used with the phrase sop in the starting.
my tag structure sop/tags/tags/tags
for i in $(find . -type f -name "*.md") ; do cat $i | grep "tag: sop" | sed "s/tag: / /"; done | uniq > temp/tmp
then use echo to append all those YAML keys you need.
INT=1 ; for i in $(cat temp/tmp) ; do echo "---" ; echo "tag :" ; echo - $i ; ((INT++)) ; done
after you decide your echo syntax should be like this
echo "yaml" >> temp/000$INT.md
In that way the files would be shown per tag wise in the header template, and would not override your tags like i did which lead to 255 tags added.
in this way you still have all of your links preserved and you would achieve what i achieved with messy tags in my database folder. Don't worry i had a backup hehe 😆
Beta Was this translation helpful? Give feedback.
All reactions