keymap a custom command line script

I just want to bind a script I've written to a keyboard shortcut. I'm currently confused as to how to do this in PhpStorm, even after reading the manual. And can I do this on a per project basis?

For example:

php ~/Documents/projects/tools/rsyncProject.php

5 comments
Comment actions Permalink

Hi Tylor,

You can achieve this with help of External Tools:
1) "File | Settings | External Tools" -- create the command there
2) Once done -- test if it works. You can access to these entries in multiple places, like via Editor context menu, Menu | Tools etc (depends what you have set when created such entry)
3) Once happy -- "File | Settings | Keymap --> External Tools" and assign the desired shortcut there.

This works on global level, but you can run project specific version of the script if you use macro when creating such External Tool entry (as a part of the script path, for example, so the tool will always use the local script -- relative to the project path)

0
Comment actions Permalink

thanks for thorough answer, Andriy, we really appreciate your help here and in project tracker.

I can think of one more - a per-project one - way of achieving similar functionality: adding a one letter alias for this command to Settings|Command line tools. Execution will require a keyboard stroke: ctrl-shift-x, Alias letter, enter.

//sent from my phone.

0
Comment actions Permalink

Thanks guys. I appreciate it.

I did try what Andriy suggested before, but I was having problems getting the script to run. I ended up making it a bash executable script and it is working. I was under the mistaken impression that I could actually put my command line invocation in the program field: 'php /path/to/script.php'. I also tried to make it an php executable file but that didn't seem to work as well. So my workaround is to create a bash executable file that has the 'php /path/to/script.php' in it. I don't know, maybe I'm missing something.

The other thing that was slightly confusing to me was that when editing the group name it seemed to mysteriously work and not work. Sometimes it would save the group name change and sometimes it wouldn't.

0
Comment actions Permalink
I was under the mistaken impression that I could actually put my command line invocation in the program field: 'php /path/to/script.php'.

So .. have you actually tried to split your command into appropriate field, or you stopped at the bash script approach?
Program: php
Parameters: /path/to/script.php

If you have not tried -- can you try it again?

0
Comment actions Permalink

Ah I see, yes that works with one modification. I had to specify the path to my php binary. It could be because I've created an alias to an alternative php binary in my .bashrc and .bash_profile. Either way I got it working. Thanks!

0

Please sign in to leave a comment.