DEV Community

Cover image for Bash Command Prettifier: The Solution to Formatting Tedious, Long Commands
Luc Gagan
Luc Gagan

Posted on

Bash Command Prettifier: The Solution to Formatting Tedious, Long Commands

Hello fellow DevOps enthusiasts and command-line warriors!

If you're anything like me, you value clarity and readability in your documentation. But there's a common nuisance we all face: those lengthy, unbroken bash commands. You know the ones I'm talking about. The ones that scroll endlessly, making you lose track of parameters, especially when copying them from tutorials or platforms like GCP.

The Problem:

Let me paint a picture:

GCP throws at you:

gcloud beta container --project "rayrun" node-pools create "test-runners-1" --cluster "rayrun" --zone "us-central1-c" --machine-type "e2-medium" --image-type "COS_CONTAINERD" --disk-type "pd-balanced" --disk-size "100" --metadata disable-legacy-endpoints=true --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --num-nodes "3" --enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0
Enter fullscreen mode Exit fullscreen mode

And with a sigh, you reformat it to:

gcloud beta container \
  --project "rayrun" \
  node-pools create "test-runners-1" \
  --cluster "rayrun" \
  --zone "us-central1-c" \
  --machine-type "e2-medium" \
  --image-type "COS_CONTAINERD" \
  --disk-type "pd-balanced" \
  --disk-size "100" \
  --metadata disable-legacy-endpoints=true \
  --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \
  --num-nodes "3" \
  --enable-autoupgrade \
  --enable-autorepair \
  --max-surge-upgrade 1 \
  --max-unavailable-upgrade 0
Enter fullscreen mode Exit fullscreen mode

If you are wondering, the example is taken directly from Google Cloud Platform documentation.

I found myself sinking more time into reformatting these lines than I'd like to admit. And I knew there had to be a better way.

Introducing the Bash Command Prettifier:

This is where the Bash Command Prettifier comes into play. I designed this tool to tackle this exact issue head-on. The aim? To convert tedious, single-line commands into a neatly organized, multi-line format that's both pleasant to the eye and perfect for documentation.

Simply input your marathon-length bash command, and voila! Out comes a formatted, doc-friendly version.

🌟 Find the open-source code here: Bash Command Prettifier on GitHub

Here is an online demo: https://ray.run/tools/bash-command-formatter

In Conclusion:

In our fast-paced DevOps world, every second counts. Little efficiencies can make all the difference in productivity and mental well-being. My hope is that the Bash Command Prettifier serves you well and shaves precious minutes off your documentation tasks.

I'd love to hear your feedback or any suggestions for improvement. Wishing you clear and readable bash commands! Until next time. πŸš€

Top comments (0)