DEV Community

namuan
namuan

Posted on • Originally published at deskriders.dev

1

Handy Bash/Zsh function to generate PlantUML diagrams

In this short clip, we'll look at creating a simple Bash/Zsh function wrapping PlantUML so that we can use it from anywhere.

Requirements:

Download 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 plantuml() {
    NAME=$1
    cat $NAME | java -DPLANTUML_LIMIT_SIZE=8192 -jar $TOOLS_HOME/plantuml/plantuml.jar -pipe > $NAME.png
    open $NAME.png
}

Then you can call this function with the file name.

plantuml sample.png

Once you have it setup, this will convert the provided plantuml file to a PNG image and open it up using the default PNG viewer.

Here it is in action

📝:

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

Tiger Data image

🐯 🚀 Timescale is now TigerData

Building the modern PostgreSQL for the analytical and agentic era.

Read more

Top comments (0)

Dev Diairies image

User Feedback & The Pivot That Saved The Project

🔥 Check out Episode 3 of Dev Diairies, following a successful Hackathon project turned startup.

Watch full video 🎥

👋 Kindness is contagious

Discover fresh viewpoints in this insightful post, supported by our vibrant DEV Community. Every developer’s experience matters—add your thoughts and help us grow together.

A simple “thank you” can uplift the author and spark new discussions—leave yours below!

On DEV, knowledge-sharing connects us and drives innovation. Found this useful? A quick note of appreciation makes a real impact.

Okay