Skip to content

Instantly share code, notes, and snippets.

@mpicker0
Last active July 20, 2024 19:31
Show Gist options
  • Save mpicker0/a6a3f10e6b9278074f93 to your computer and use it in GitHub Desktop.
Save mpicker0/a6a3f10e6b9278074f93 to your computer and use it in GitHub Desktop.
Configuring IntelliJ's terminal to run Cygwin
# Add to your .bashrc so the terminal starts in the project directory
if [[ ${INTELLIJ} == "true" ]]; then
cd ${OLDPWD}
fi
# Note that this works in IntelliJ 14, but not in 16.
# Change the shell path in IntelliJ's Tools > Terminal to:
# C:\cygwin64\bin\env INTELLIJ=true TERM=cygwin C:\cygwin64\bin\bash.exe --login -i
@echo off
set INTELLIJ=true
set TERM=vt100
set PATH="C:\cygwin64\bin";%PATH%
bash --login -i
REM This works in IntelliJ 16
REM Change the shell path in IntelliJ's Tools > Terminal to:
REM C:\path\to\this\script\run_bash.bat
@Yomiji
Copy link

Yomiji commented Jun 27, 2017

I realize this is a bit of an older solution but I ran into an issue recently where installing chere -i -t mintty caused an issue with intellij setup using this configuration. The terminal will instead begin to start in the /home/user directory. To fix it, I had to comment out the .bashrc lines in this solution for the entire "if" statement including the "cd" statement. I then had to remove the "--login" and "-i" from the bash statement in line 6 of the run_bash.bat script.

@dragankoz
Copy link

Tools -> Terminal ->Application settings ->Shell Path: "c:\cygwin64\bin\sh.exe" -c "/bin/xhere /bin/bash"

@glli
Copy link

glli commented Mar 18, 2018

Tools -> Terminal ->Application settings ->Shell Path: "c:\cygwin64\bin\sh" -lic "cd ${OLDPWD-.}; bash"

@philippeback
Copy link

That last one worked for me in IDEA Ultimate 2018.2

@ConfuciusDa1st
Copy link

Works for me as well 2018.3.4

@SturmB
Copy link

SturmB commented Jul 29, 2019

Likewise, although I am using PhpStorm 2019.1.
I use zsh, so the command for me is "c:\cygwin64\bin\sh" -lic "cd ${OLDPWD-.}; zsh"
Works perfectly!

@cricketbackground
Copy link

Tools -> Terminal ->Application settings ->Shell Path: "c:\cygwin64\bin\sh" -lic "cd ${OLDPWD-.}; bash"

Works like wonder

@DanKaplanSES
Copy link

DanKaplanSES commented Jul 20, 2024

This worked for me in Intellij IDEA 2024:

C:\cygwin64\bin\bash -ilc 'cd -; exec bash'

The reply above me hung indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment