jxie0755
jxie0755

Reputation: 1742

How to setup Intellij idea terminal path with cmder but initiated with git bash.exe?

So I have installed both Cmder and Git bash, and my Cmder is setup in a way that to run git bash.exe inside.

Currently my Intellij idea's path for terminal is set to:

C:\Program Files\Git\bin\bash.exe, which works fine for bash.exe

However, one disadvantage for directly using bash.exe is that it will not automatically convert a windows directory, for example: D:\Documents\Adobe, when I copy this after cd, it will be:

cd D:\Documents\Adobe instead of:

cd /d/Documents/Adobe which I will get in cmder.

I have looked up online, people shared about how to incorporate cmder in idea's terminal by using the path:

"cmd.exe" /k ""%CMDER_ROOT%\vendor\init.bat""

However, that is only using cmder as a coating for cmd.exe, not bash.exe as I want.

I have tried to replace with:

"C:\Program Files\Git\bin\bash.exe" /k ""%CMDER_ROOT%\vendor\init.bat"", it was not working.

also tried:

"C:\Program Files\Git\bin\sh.exe" --login -i /k ""%CMDER_ROOT%\vendor\init.bat""

and:

"C:\Program Files\Git\bin\sh.exe" /k ""%CMDER_ROOT%\vendor\init.bat""

All failed.

Any sugestons? Thanks! Or if someone can show me how to change git bash.exe so that it can automatically translate the windows directory to Linux type, that would also work.

Upvotes: 1

Views: 2691

Answers (1)

WesternGun
WesternGun

Reputation: 12787

I don't think you can run git-bash in cmder AND from Intellij IDEA terminal.

I tried this: creating a task for git-bash in Cmder and try to use cmder.exe /TASK xxx in Intellij. I have the task, but it seems that Intellij does not support args after an executable in Terminal settings, so /TASK xxx is not parsable.

Then I changed path in Terminal settings to a BAT file, but terminal seems not support running it; I see terminal flashes and closes. Maybe only executable is allowed. Branch info is shown at the right of current path. I think it is convenient.

So, you have two options:

  • change terminal to git-bash.exe and get used to slash as path separator(and that is much saner than back slashes, trust me)
  • just configure Intellj Terminal to open cmder, with default task like this: cmd /k ""%ConEmuDir%\..\init.bat" ". This will open cmder in the current folder, and you also have git support. That is, stop using mingw64 and only ConEmu + clink. You have color support, Windows backslashes and so on. And you also can mix Win commands with bash syntax(with "Shell integration" ticked). This is what I am doing right now. Branch info is shown, lambda symbol as well. It is already perfect.

enter image description here

Upvotes: 1

Related Questions