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?
请先登录再写评论。
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.
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.
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 :)
Have you tried external tools: https://www.jetbrains.com/help/idea/settings-tools-external-tools.html ?
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.
Please raise a feature request.