TL;DR
This is how I’ve set up multiple instances of the Joplin Terminal Application that features Vim
real-time markdown previews.
[edit]: removed references to symlinking the Joplin database. See: discussion
Disclaimer:
- This document might be naive: This is my first week using Joplin.
- Hi, I wasn’t sure where to put this information so please redirect me if needed.
- I primarily use terminals and CLIs in my workflow (I use the mouse as little as possible).
- Recently I mentioned a possible HTML export method on Export to HTML · Issue #1167 that eluded to a workflow use case. This post is a follow up to how I’ve configured the various tools involved.
- There is another thread that discusses this topic: Can I run a second instance of Joplin?
- I realize that changes in the Joplin framework may change -and possibly render this information useless.
- Make sure you have a verified incremental backup system in place before attempting the sugestionons herein.
Summary:
Features of this workflow and tool configuration:
- 2+ instances of Joplin Terminal App (Joplin CLI) on the same system
- Shared
resources
directories - Real-time web browser preview (with note images/resources) of notes that are edited through Vim editor.
- This is much simpler than it seems -and mostly transparent
- Faster Sync times do to shared
resource
folder among instances
Tools used:
- Joplin Terminal Application
- Vim editor (NeoVim would work too)
- Linux
Cron
- Some, very little,
Bash
shell script
Limitations:
- Previews can’t follow links that lead to other notes.
- I consider this is considered a bit of a Hack.
- These hacks may be incompatible with future versions of Joplin.
- Editing the same file in multiple Joplin instances will cause a conflict -which is normal.
Managing Multiple instances of Joplin on the Same System
Joplin Terminal Application User Instances
-
.bashrc
/.profile
uses an alias to run CLI’s from different profiles-
command:
joplin
starts one CLI instance in the default profile location -
command:
joplin2
starts a second CLI instance with a separate profile- the
.bashrc
alias looks like this:
# second instance of Joplin - i only need 2 user instances alias joplin2="joplin --profile $HOME/.config/joplin-2nd"
- the
-
CLI Profile Configuration
- The default instance profile is not altered
- with 1 exception -see below
- Each additional instance profile retains it’s own directory with:
-
tmp/
directory log-database.txt
log.txt
database.sqlite
-
- Additional instance profiles use symlinks to access data in the default instance profile
-
keymap.json
, andresources
are symlinked to the default instance profile
~/.config/joplin-2nd ├── database.sqlite ├── keymap.json -> ../joplin/keymap.json ├── log-database.txt ├── log.txt ├── resources -> ../joplin/resources └── tmp
-
Vim Preview Details -and cron job with script
How it works:
The Vim markdown-preview
plugin uses references in the current working directory of the file being edited to serve on a web page. By symlinking the resource
folder within the tmp
directory the ‘markdown-preview’ plugin service has access to the files of the resources. This also has the advantage of less file copying for resources
content between instances.
Configuration:
-
Install and test the vim plugin for markdown previews:
-
Create a script that will create a link in the default profile
tmp
directory back to the default profileresources
directory- The default profile directory structure will end up looking like this:
~/.config/joplin ├── database.sqlite ├── keymap.json ├── log-database.txt ├── log.txt ├── resources │ └── <...long list of files> └── tmp └── resources -> ~/.config/joplin/resources
- The script will look like this:
#!/usr/bin/env bash # script name: joplin_resource-link.sh # Cheezy script that creates a link as needed. # This should probably be done with a watch service instead. # cron entry # * * * * * /home/karl/mbin/joplin_resource-link.sh RESOURCES_LINK="$HOME/.config/joplin/tmp/resources" RESOURCES_DIR="$HOME/.config/joplin/resources" #run every 5 seconds with a cron trigger set for every minute for i in {1..12}; do if [ ! -L "$RESOURCES_LINK" ];then ln -s "$RESOURCES_DIR" "$RESOURCES_LINK" fi sleep 5 done
-
Create a
cron
entry to launch the script every minute- use
crontab -e
* * * * * /home/karl/mbin/joplin_resource-link.sh
- use
-
Repeat steps 2 and 3 for each CLI instance (if desired)
- Adjust the script for the paths of each instance.
# example from the script: RESOURCES_LINK="$HOME/.config/joplin/tmp/resources" # would become: RESOURCES_LINK="$HOME/.config/joplin-2nd/tmp/resources"
That’s it. Hope this is useful/helpful.