DEV Community

namuan
namuan

Posted on • Originally published at deskriders.dev

1

Bash/Zsh function to export SVG diagrams using PlantUML

In this short clip, we'll look at creating a simple Bash/Zsh function to export SVG diagrams using PlantUML.

Requirements:

Place it where you can easily refer to it.

nmn$ ls -l $TOOLS_HOME/plantuml/plantuml.jar
-rw-r--r--@ 1 nmn  staff  7985304  9 Nov  2019 /Users/nmn/tools/plantuml/plantuml.jar

Next, we'll create a function and put that in bash/zsh profile so that it can be loaded automatically on each session.

function plantsvg() {
    NAME="$1"
    cat ${NAME} | java -DPLANTUML_LIMIT_SIZE=8192 -jar $TOOLS_HOME/plantuml/plantuml.jar -tsvg -pipe > ${NAME}.svg
    open -a Firefox.app ${NAME}.svg
}

Once you have it setup, this will export the provided plantuml file to an SVG image and open it up using Firefox.
You can change the application used to open this SVG by replacing Firefox.app with the another application.

Here it is in action

📝:

👉 Tested on MacOS but should work on earlier versions and all flavours of Linux

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay