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

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.

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.

Related

How can I use a git bash terminal profile in Visual Studio 2019?

Visual Studio 2019 has recently added a new (much-needed) terminal feature in its 16.6 version.
It's really great, but I'm having a hard time integrating git bash in the profiles.
I've tried a few variations of arguments and whatnot of the following profile:
But whenever I try selecting that profile, the terminal shortly displays a blank screen, then opens the default PowerShell terminal.
What am I doing wrong and how can I configure the profile correctly?
In case you haven't figured it out already: You need to add argument -i (to make the shell interactive), and I also recommend --login (to make the shell read default profile configuration files).
Try adding the following in the Arguments field:
--login -i
I used C:\Program Files\Git\bin\bash.exe as the Shell Location, and it worked fine.
Solution I am using while waiting for a better one:
Shell Location: C:\WINDOWS\system32\cmd.exe
Arguments: /k ""%VSAPPIDDIR%..\Tools\VsDevCmd.bat" & bash"
Essentially, I am launching cmd and running the "bash" command at launch, effectively nesting the bash terminal within cmd.
My Workaround:
What you no one mentioned in all of these replies is that you need the shell not the executable different things...
Shell Location: C:\Program Files\Git\bin\sh.exe
Arguments: (If you have any preferences add here, it works without)
And...
Walah!

External commands not available in gvim on windows

When starting a gvim session on windows 7, it appears that globally available commands like autopep8 or pylint cannot be executed. I.e. the command :!pylint opens up a console windows saying 'pylint' is not recognized as an internal or external command.
However, I can execute these commands from cmd.exe by just typing the respective names.
This is because I have added the path C:\Program Files (x86)\Python 3.5\Scripts; to the System Path environment variable. For some reason this is not picked up by the shell behind gvim.
The weird thing is that typing :echo $PATH shows a list or folders which includes C:\Program Files (x86)\Python 3.5\Scripts;.
I should also note that this problem does not occur when starting normal vim in a terminal like cmd.exe or git bash.
Any hints on what might be going wrong?

Setup git in Intellij terminal

I want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git.
So, can anyone tell me how can I use the git command in the Intellij terminal.
Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash
File
Settings
(Enter 'Terminal' in search)
Change Shell path to:
"C:\Program Files\Git\bin\sh.exe" --login -i
or
"C:\Program Files\Git\bin\bash.exe"
If you have another directory for installed git change it respectively.
In the IDEA settings make sure that your terminal path leads to "usr/bin" instead of "/bin".
As a result you will see pretty rich console output:
For me, it works also but only the path of Git Bash has changed in Windows :
"C:\Users\REPLACE_THIS_BY_YOUR_USER\AppData\Local\Programs\Git\bin\sh.exe" --login -i
The full path is not needed anymore (windows), I just replaced cmd.exe to sh.exe and bingo was his name O
Settings > Tools > Terminal > Shell path > sh.exe
In my case, the Git Bash through IntelliJ had TERM=xterm-256color.
Regular Git Bash had TERM=xterm
To fix the garbled characters issue in IntelliJ Idea,
Go to "File | Settings | Tools | Terminal"
Environment Variables: TERM=cygwin
In IntelliJ Terminal, Shell Path I was using was already:
C:\Users\<userId>\programs\Git\bin\bash.exe --login -i
You don't need to reinstall anything. Go to:
File
Settings
Search for terminal
in shell path type: "C:\Program Files\Git\bin\sh.exe" --login -i (or another directory where you installed Git)
This worked for me:
IntelliJ:
File->Settings->Version Control->Git:
On the right side, Path to Git executable:
"C:\Program Files\Git\bin\git.exe"

Adding cmdline (win7) as an Eclipse console view

I've seen it in linux. There's a console you can open that is just a shell. I want the same thing in windows only with either cmd, or with git bash. (MINGW32). I tried googling it but just got flooded with articles about egit and normal git bash.
If you have msysgit, you can use it from a regular cmd session:
Launch c:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-cmd.bat, and you can type in that cmd windows regular git commands.
For a bash session: c:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-bash.bat.
Note that you need to modify those bat:
git-cmd.bat: add a rem before the setlocal command, and before the start at the end.
git-bash.bat: add a rem before the setlocal command.
So you can add to your Eclipse an external tool which will open a cmd in your console:
Except, instead of calling C:\windows\system32\cmd.exe (in the "Location" field from the picture above), you could call directly: C:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-bash.bat.
By 'msysgit', I refer to whatever name you gave to the uncompresdsed portable version of "Git For Windows": download it there.
And then you could type git command within the Eclipse console (including a bash session)!
After testing, the color codes get in the way, even if git works:
git-cmd.bat:
git-bash.bat:

How do I launch a Git Bash window with particular working directory using a script?

How can I launch a new Git Bash window with a specified working directory using a script (either Bash or Windows batch)?
My goal is to launch multiple Git Bash windows from a single script, each set to a different working directory. This way I can quickly get to work after booting the computer instead of having to open Git Bash windows and navigating each one to the correct working directory.
I am not asking how to change the default working directory, like this question does, but to launch one or more terminal windows with different working directories from a script.
Another option is to create a shortcut with the following properties:
Target should be:
"%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
Start in is the folder you wish your Git Bash prompt to launch into.
Try the --cd= option. Assuming your GIT Bash resides in C:\Program Files\Git it would be:
"C:\Program Files\Git\git-bash.exe" --cd="e:\SomeFolder"
If used inside registry key, folder parameter can be provided with %1:
"C:\Program Files\Git\git-bash.exe" --cd="%1"
Git Bash uses cmd.exe for its terminal plus extentions from MSYS/MinGW which are provided by sh.exe, a sort of cmd.exe wrapper. In Windows you launch a new terminal using the start command.
Thus a shell script which launches a new Git Bash terminal with a specific working directory is:
(cd C:/path/to/dir1 && start sh --login) &
(cd D:/path/to/dir2 && start sh --login) &
An equivalent Windows batch script is:
C:
cd \path\to\dir1
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
D:
cd \path\to\dir2
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
To get the same font and window size as the Git Bash launched from the start menu, it is easiest to copy the start menu shortcut settings to the command console defaults (to change defaults, open cmd.exe, left-click the upper left icon, and select Defaults).
Let yet add up to the answer from #Drew Noakes:
Target:
"C:\Program Files\Git\git-bash.exe" --cd=C:\GitRepo
The cd param should be one of the options how to specify the working directory.
Also notice, that I have not any --login param there: Instead, I use another extra app, dedicated just for SSH keys: Pageant (PuTTY authentication agent).
Start in:
C:\GitRepo
The same possible way, as #Drew Noakes mentioned/shown here sooner, I use it too.
Shortcut key:
Ctrl + Alt + B
Such shortcuts are another less known feature in Windows. But there is a restriction: To let the shortcut take effect, it must be placed somewhere on the User's subdirectory: The Desktop is fine.
If you do not want it visible, yet still activatable, place this .lnk file i.e. to the quick launch folder, as that dir is purposed for such shortcuts. (no matter whether displayed on the desktop) #76080 #3619355
"\Application Data\Microsoft\Internet Explorer\Quick Launch\"
In addition, Win10 gives you an option to open git bash from your working directory by right-clicking on your folder and selecting GitBash here.
Windows 10
This is basically #lengxuehx's answer, but updated for Win 10, and it assumes your bash installation is from Git Bash for Windows from git's official downloads.
cmd /c (start /b "%cd%" "C:\Program Files\GitW\git-bash.exe") && exit
I ended up using this after I lost my context-menu items for Git Bash as my command to run from the registry settings. In case you're curious about that, I did this:
Create a new key called Bash in the shell key at HKEY_CLASSES_ROOT\Directory\Background\shell
Add a string value to Icon (not a new key!) that is the full path to your git-bash.exe, including the git-bash.exe part. You might need to wrap this in quotes.
Edit the default value of Bash to the text you want to use in the context menu
Add a sub-key to Bash called command
Modify command's default value to cmd /c (start /b "%cd%" "C:\Program Files\GitW\git-bash.exe") && exit
Then you should be able to close the registry and start using Git Bash from anywhere that's a real directory. For example, This PC is not a real directory.
This is the command which can be executed directly in Run dialog box (shortcut is win+R) and also works well saved as a .bat script:
cmd /c (start /d "/path/to/dir" bash --login) && exit
I'm not familiar with Git Bash but assuming that it is a git shell (such as git-sh) residing in /path/to/my/gitshell and your favorite terminal program is called `myterm' you can script the following:
(cd dir1; myterm -e /path/to/my/gitshell) &
(cd dir2; myterm -e /path/to/my/gitshell) &
...
Note that the parameter -e for execution may be named differently with your favorite terminal program.
Using Windows Explorer, navigate to any directory you want, type "cmd" in the address bar it will open Windows command prompt in that directory.
Along the same lines, if you have the git directory in your path, you can type "git-bash" in the address bar and a Git Shell will open in that directory.
If using Windows OS :
Right click on git terminal > Properties
Properties>Under shortcut tab>Start in:
add your folder target path like below image

Resources