简体   繁体   中英

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?

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

Steps

1. create environment variable under Advanced System Settings, System Properties, Environment Variables, System Variables with name-value: CMDER_ROOT=C:\path\to\your\cmder

2. create cmder_shell.bat file in cmder folder u mentioned in step 1. with content: '@cmd.exe /k %0..\vendor\init.bat'

3. in shell path write: cmd.exe /c ""%CMDER_ROOT%\cmder_shell.bat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM