Tip for creating tiddlers externally (BobWiki on Linux)

85 views
Skip to first unread message

Dave

unread,
Nov 9, 2018, 12:38:53 PM11/9/18
to TiddlyWiki
I have my BobWiki tiddlers folder synced across several computers, but don't have BobWiki (or nodejs version) installed on all of them, but you can quickly write a note for your TW instance with a bash script.

The minimal thing you need to include in a tid file (mytiddler.tid) is the line "title: mytiddler" at the beginning of the file.  

One problem with that however, is that if its created that way it won't appear on your recent tiddlers list as there's no "created:" or "modified:" date


Here's the tip that took me a while to figure out:

* you have to use a date format that is exactly 17 digits long, like this: 20181109012343614, and it has to be GMT as well, so here's how to do it on a linux system:

longdate=$(date -u "+%Y%m%d%H%M%5N")



i.e. longdate is the variable you use to later put into your tid file, like this:
sed -i "2icreated: ${longdate}" """$fullname"""
sed -i "2imodified: ${longdate}" """$fullname"""


the "sed -i 2i" part says insert this string as the second line of the file (I'd previously written "title: mytiddler" as the first line), and $fullname is the path to the file.  I use triple quotes because I usually include spaces in the tiddler names



I don't know how many other people would find this useful, but you never know...
- Dave



Mark S.

unread,
Nov 9, 2018, 1:19:26 PM11/9/18
to TiddlyWiki
It wouldn't just apply to Bob -- anywhere that you want to create tids on the fly (including tids to import into a standalone later). It might even work in the Git Bash shell (but I'm not set up to test that right now).

It appears that for your code to work, the tid file already needs to have several blank lines after the title? Or at least one. Otherwise it can't find position #2 to insert? Or at least that's how it seemed to work for me when I tried it.

It would be great packaged as a user command (e.g. maketid.sh "My tiddler title" "Remember to do important things later")

Thanks!
-- Mark

Dave

unread,
Nov 9, 2018, 2:57:15 PM11/9/18
to TiddlyWiki
That's a good point about the second line.  You're right, it only works if there's at least 2 lines if you use that code.  I switched it to 
sed -i "1icreated: ${longdate}" """$fullname"""

and it still works because the title is already in place in the file, and even if there's only the one line, the initial "tags" like title, created, modified, tags all automagically get resorted by the TW mechanisms anyway (i.e. the "created; bla bla" line would now be first and the "title" line second (which would be maintained anyway seeing as it ends up alphabetized))


Right now the script I use is a little gui dialog (bash script) triggered by a keyboard combination.  It makes use of the fabulous linux dialog program called Yad (short for "Yet another dialog").  If TW didn't exist I'd probably have dived all in with my notes in that.  If anyone is interested I'll post my script, but there are a few tricky dependencies for yad; I'm not sure if anyone here would be using it currently...

bimlas

unread,
Nov 9, 2018, 4:45:00 PM11/9/18
to TiddlyWiki
Why do not you make a template / abbreviation in your favorite text editor? For example, in Vim, I can imagine that you can add the real date to this with a minimal effort. The advantage over the Bash script is that it works everywhere where the editor is (Win / Mac / Linux).

Dave

unread,
Nov 9, 2018, 6:04:08 PM11/9/18
to TiddlyWiki
Because with mine it works even if no windows of any kind are open :)
Reply all
Reply to author
Forward
0 new messages