Are variables for the current file available in the Run Anything dialog?

已回答

In the Run Anything dialog, can I refer to the current file with a variable of some sort?

1

What are you trying to run?

If you want to execute some command line tool consider configuring an external tools to run it - it supports different macro variables, including currently focused file.

0
Avatar
Permanently deleted user

I am running a command line tool.  I actually discovered that I could just do

$ command MyFile.java

and it did the right thing.  So either the command is executed with the current file's location as the working directory, or it is doing a search for MyFile.java in the project.  Either way it suits my needs.

0

I would be interested in this.

 

Andrey Dernov: While I know there are macros, it'd be very nice to be able to do something like "<command> $FILE" via the Run Anything shortcut.

For example, I have a bunch of linux scripts in wsl, such as `gen_ts_function_spec` - this takes a "name" as it's first argument, and generates a "<name>.spec.ts" file containing a top level describe.

It would be super useful to be able to do ctrl + ctrl -> "wsl gen_Ts_function_spec $FILE$", and have "$FILE$" replaced w/ the file I have open or selected in the tree.

The thing w/ macros is that I have to configure them - settings them all up manually for every little script is a pain, where as Run Anything remembers my previous custom commands, and is super fast to use.

 

Let me know if you'd like me to make a YouTrack issue for this :)

1

Yes, I have, and they suffer from the same problem as macros:

> The thing w/ macros is that I have to configure them - settings them all up manually for every little script is a pain, where as Run Anything remembers my previous custom commands, and is super fast to use.

I think it defeats the point of "Run Anything" for it to be so constrained. While I don't expect a massive array of features re magic variables, personally I think the ability to reference the currently active file would be a great easy addition for this feature, as it makes it a lot easier to run custom commands.

 

0

Please raise a feature request.

0

请先登录再写评论。