How to execute an external tool and insert output to current file?

Answered

Currently, when you execute an external tool, the output is put in console.
Can I somehow put the output to current file, instead of console?
just like how this command works in vim:

:read !pwd

Thank you!
Leo Jay

11 comments
Comment actions Permalink

There's no such way currently. You'd have to copy the text from the console to the file, or make your external tool write to that file directly.

0
Comment actions Permalink

Necro-Bump to 2017.

Has a way to do this been developed yet?  I really would like the same ability as the OP.  I have a utility that creates useful output for me to insert directly into the file, and copy/pasting from a console window makes it more than a little clumsy.

2
Comment actions Permalink

Note: Answered elsewhere in this forum.  It doesn't exist yet.  :-/  Seems like an obvious addition.

1
Comment actions Permalink

I have the same question: why has not this been added? Seems obvious, that you don't just want to run a command and stare at the output. Sometimes you what the output to be back in the editor.

E.g. I took this script https://gist.github.com/gbl08ma/6115095 & was going to convert the URL's inline, but I have to do the copy/pasting. Should I file a ticket?

0
Comment actions Permalink

The feature request is available at https://youtrack.jetbrains.com/issue/IDEA-76371 . Feel free to vote.

0
Comment actions Permalink

Thank you, Serge Baranov. Seems I am t he 13th to vote in 9 years. I am not holding my breath. :( Do you need help?

0
Comment actions Permalink

This part of IntelliJ IDEA is open source, you can either submit a pull request or create a plug-in.

0
Comment actions Permalink

thank you, Serge Baranov. Could you point me to the place where this code resides? Showing the area where to change the code would also be highly appreciated.

0
Comment actions Permalink

Hi there,

I'm late to the party, but there is a simple way.

 

My use case:

"I need to generate an ULID(unique ID) and paste it at the cursor".

So I created a PHP script on my filesystem, without the extension. I called it 'ulidgen'. This script generates an ULID and returns it to the commandline.

First:

- Then I put it in a directory that is in my $PATH. In my case /usr/local/bin

- Then made it executable, like so chmod +x /usr/local/bin/ulid

- Then I created another executable file: touch /usr/local/bin/ulid && chmod +x /usr/local/bin/ulid 

- This file contains bash scripting. In that file I execute the php file and copy the output to my clipboard: ulidgen | pbcopy

I am on OSX, so I am not sure what a similar tool would be on your operating system, but pipe the output of your script to that command.

Then:

- Open phpstorm. 

- Create a new External tool which executes the bash script

- Create a Macro and record:  1. Execute the external tool(now the value is in your clipboard),  2. Paste(Cmd+V)

Now you have something that prints the commandline output to clipboard and pastes it at the cursor. You can then add this macro to your Main Toolbar and add an icon or whatever. 

Bonus:

As a bonus, you could accept arguments to your external tools, like $SelectedStartLine$ and $SelectedEndLine$. This way, I could run the macro for every selected line. 

0
Comment actions Permalink

I need this as well. I made a comment on the ticket and +1'd it.

0

Please sign in to leave a comment.