jurchiks
jurchiks

Reputation: 1433

PhpStorm - execute multiple commands with one button

I execute 3 commands very frequently - git checkout master & git pull upstream master & git push. Currently, when doing this through UI, it takes 2 clicks for checkout, 5 clicks for pull from upstream, 2 clicks for push. I have tried figuring out how to put this line under a UI button, but can't find a solution.

Some places suggest trying something with Tools > Settings > External Tools, but that does not allow executing multiple commands at once; it requires you to specify the full path to the executable (git in this case), and that breaks at the first join.

Another potential solution was Command Line Tools, but it has the exact same problem as External Tools, not to mention it can't be put under a button.

Is there a way to do what I want? I'm 100% sure that many other people would find this useful, since this is a very common thing to do in any forked GIT project.

Upvotes: 2

Views: 922

Answers (3)

Markus Zeller
Markus Zeller

Reputation: 9153

In my case I could not add a script, but I still wanted to execute multiple commands at once. So I came up with Tools > Settings > External Tools and used bash as a program and separated the commands with a ;. The bash itself receives the command with the argument -c and a string in double quotes.

Program: bash
Arguments: -c "echo 1; echo 2; echo 3"

Upvotes: 1

wormi4ok
wormi4ok

Reputation: 632

You can try a Compound configuration and add several bash commands.

Run/Debug configuration

Doing so you will be able to run commands with one click.

Run Compound command

Upvotes: 4

Stephen
Stephen

Reputation: 4249

Why not use Tools > Settings > External Tools and just write a script?

#!/bin/bash
git checkout master & git pull upstream master & git push

(or a batch file if on windows)

Then just execute the one script.

Upvotes: 5

Related Questions