5

I often find myself wanting to make a quick graph to illustrate dependencies or a process. dot is nice for doing this, however it would be much more convenient if I could generate the rendered graph straight to my clipboard instead of generating a temporary file.

Ideally, I'd like something like

echo "graph {a--b; b--c;}" | dot -Tpng | xclip

This command as-written doesn't quite work - the copied data won't paste into applications that normally accept pasted images.

Is there any trick to get dot to produce output that would be pastable into applications?

As a tangent, and perhaps to address the knowledge gap at the root of my problem, what makes images "pastable" to begin with? What is the difference between my command above and, say, right-clicking on an image in a web browser and choosing Copy Image?

Tara
  • 153

2 Answers2

6

Close. You need to tell xclip the type of data, and most programs want the XA_CLIPBOARD for the usual ctrl-v pasting:

echo "graph {a--b; b--c;}" | dot -Tpng | xclip -selection clipboard -t image/png

A simple shell function might be a good idea to wrap all this.

By the way, if you're pasting into inkscape (probably also in quite a few things like web editors), SVG might be a better choice than PNG, dot -Tsvg | xclip -selection clipboard -t image/svg.

-1

generate a colored pictorial diagram for structural path model using Table 4.14 Structural Path Model Results Path β Coefficient t-value p-value Decision TED → TAC 0.184 4.57 0.000 Supported TIN → TAC 0.162 3.91 0.000 Supported TEN → TAC 0.205 5.23 0.000 Supported DTP → TAC 0.149 3.42 0.001 Supported DIL → TAC 0.121 2.87 0.004 Supported TED × DIL → TAC 0.076 2.41 0.016 Supported TIN × DIL → TAC 0.059 1.97 0.049 Supported TEN × DIL → TAC 0.083 2.88 0.004 Supported DTP × DIL → TAC 0.072 2.54 0.011 Supported