Explorer To Cygwin – Open In Folder

replace the Cygwin.bay under c:\cygwin\ with this content,

@echo off
::force UTF-8 support
chcp 65001

if "%1"=="" (
) else (

  call C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
  goto EXIT

  rem  remove [\'\"] from first arg
  set CURRENT=%~1
  rem  backward2forward slash
  rem  remove ":" after the drive letter
  set CURRENT=%CURRENT::/=/%
  rem  adds prefix (used in cygwin as dummy drive-mounts)
  set CURRENT=/cygdrive/%CURRENT%
  rem  ------------------------------------------------------------
  call C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico c:\cygwin\bin\bash.exe -l -c "cd \"%CURRENT%\" ; exec bash" -
  goto EXIT


or download the following file instead: Cygwin.bat (here is the original file: Cygwin.bat.bak)

if you’ll pass a folder path as argument to the batch (no checks.. q&d..) it will open cygwin in this path, in any other case, just open cygwin in home-directory (standard run..)


place a shortcut in your SENDTO folder,
and then right-click a folder and select the shortcut from the sendto-menu

or better yet, download the following reg file: open_in_cygwin.reg and double click it,

Windows Registry Editor Version 5.00

@="Open In Cy&gwin"

@="\"C:\\cygwin\\Cygwin.bat\" \"%1\""

it will add a new context-menu item for each folder:

download and run the following file to uninstall the context-menu item: open_in_cygwin_uninstall.reg

Windows Registry Editor Version 5.00


July 29th, 2017 – Update.

Here is a slightly modified version of the “start cygwin from a folder”, that runs few checks before the actual execute stage, it wraps things with ", and very carefully handles long and short paths, passing paths correctly to cygwin terminal application, also, it does not uses hard-coded paths, so if your cygwin folder placed somewhere else it will work just fine for you :]

@echo off
::              set code-page for UTF-8 charset.
chcp 65001

::              normalise to fully qualified path. short path (8.3) is used for testing the path.
set FOLDER=%~s1
for /f %%a in ("%FOLDER%") do ( set "FOLDER=%%~fsa" )

::              verify existing folder.
if ["%FOLDER%"]==[""]         ( goto RUN_STANDARD   )
if not exist %FOLDER%         ( goto RUN_STANDARD   )
if not exist %FOLDER%\NUL     ( goto RUN_STANDARD   )



::             prefer long-path.
  set FOLDER=%~1
  echo Starting Cygwin From ^[%FOLDER%^] ...
::             convert to cygwin-compatible path (forward-slash, removing drive's ":" and /cygdrive/ as root)
  set FOLDER=%FOLDER:\=/%
  set FOLDER=%FOLDER::/=/%
  set FOLDER=/cygdrive/%FOLDER%
  call "%~dp0bin\mintty.exe" "-i" "/Cygwin-Terminal.ico" %~dp0bin\bash.exe -l -c "cd \"%FOLDER%\"; exec bash" - 2>nul >nul
  goto EXIT

  echo Starting Cygwin From Home...
  call "%~dp0bin\mintty.exe" "-i" "/Cygwin-Terminal.ico" "-"   2>nul >nul
  goto EXIT