how to create a custom external command to execute a bash alias
Hi,
I am trying to create a custom command to place in the toolbar that execute a bash alias in the system
I have tried with:
setting just the "aliasname" that I executed successfully in the command line in the section concerning the program:

but no luck.
And setting /bin/bash as the program and setting the alias as argument does not work neither:

Has anyone experience with this?
Thanks in advance
Please sign in to leave a comment.
Hi there,
Not a Linux/Mac user and therefore do not have much bash experience.
1. AFAIK your alias is known inside the shell process only. And when you use an External Tool, the IDE creates a process directly and not "hey OS, execute this command in the default shell for me"... Therefore the alias is an unknown command at this step.
2. Can bash execute parameters as a command? What is the syntax?
For example on Windows using cmd.exe as a shell, you would need to execute cmd.exe with /C "phpunit filename" params to have a console and execute phpunit filename command inside...
3. Why not making a shell script (that executes the alias or whatever command you want) and execute that script? This kind of idea:
myscript.sh
Hi Andriy thanks for your help.
Yes, I was thinking the same that you, but I was thinking that maybe someone has more experienced with bash and alias here.
Anycase finally I get it working with the script way as you said. More work.... but ... it is working now:
The configuration:
The File:
notice that the script should execute commands in not interactive way, so, in this case, docker-compose exec should place "-T"
Thanks!!
Some other options that you may want to check out.
1. The bundled Shell Script plugin allows executing custom script (or a script text) via Run/Debug Configuration. This would be a project-specific entity though.
2. You can use the actual built-in Terminal, have an alias defined in your shell and execute it manually (if alias is short it should be no issues typing it)
3. Command Line Tools -- it can work with a custom tool as well. Kind of alternative to the Terminal in #2. https://www.jetbrains.com/help/phpstorm/php-specific-command-line-tools.html
When I try to execute an alias command from a Run/Debug configuration, I get this error:
This is the full output:
This is the content of dev.sh:
Any ideas in how to allow alias commands to be executed?
I finally found the way to execute alias commands in Run/Debug configuration on Mac. Basically, I had to create a script in package.json as shown:
The flag -i was the solution to execute alias commands.
The template configuration used was from an NPM template.