Search code examples
bashintellij-ideawebstormgolandcmder

cmder terminal integration into IntelliJ / WebStorm / GoLand with aliases


I would like to use the cmder shell inside IntelliJ / GoLand / WebStorm and so on.
Additionally, I want to use bash instead of the default cmd.

This can be achieved by changing the settings at Settings > Tools > Terminal:

For the Shell path, configure

cmd.exe /c  "path\to\my\cmder\vendor\git-for-windows\bin\bash.exe"

This works as expected: When opening a terminal window, cmder starts bash.
However, there is one issue with this: aliases are not working.

In a normal cmder bash-window, I can use aliases like ll. Here, I can't. I found the aliases to be defined in cmder\vendor\git-for-windows\etc\profile.d\aliases.sh

Edit: When I use the following shell path:

cmd.exe /c  "path\to\my\cmder\vendor\git-for-windows\bin\bash.exe" --login -i

... the alias works. But when opening the console, I always get the following error message:

Creating user startup file: /config/user_profile.sh
cp: cannot stat '/vendor/user_profile.sh.default': No such file or directory

Changing the "Start directory" to the cmder folder does not solve the issue.

How can I get them running inside my IDE?


Solution

  • I found a solution: you need to configure your terminal like this:

    cmd.exe /c  ""%CMDER_ROOT%\vendor\git-for-windows\bin\bash.exe" --login -i"
    

    In addition to that, in "Environment variables", define the cmder-path:

    CMDER_ROOT=C:\path\to\your\cmder
    

    (You can also do this in the terminal settings - you don't need to set a system-wide environment variable)

    If you want a different default-shell, use the exact same parameters as the cmder task you want. You can see them in cmder by pressing Win+Alt+P, and then going to Startup -> Tasks.

    Details:

    • --login -i is needed to load things like alias configurations
    • The environment variable CMDER_ROOT is needed to get rid of the path error stated in the question. It's not possible to replace it with the actual path.
    • Double-quotes are needed due to the environment-variable expansion