79812971

Date: 2025-11-08 04:27:18
Score: 0.5
Natty:
Report link

To open a Cygwin terminal with 'the same' $PWD (more precisely, with $PWD_Cygwin = $(cygpath $PWD_Windows) as in Windows (e.g. your PowerShell terminal), simply do

C:\cygwin64\bin\mintty.exe -
cd "$(cygpath -u "$OLDPWD")"

in your Windows terminal/script/etc. The logic of the code follows from the fact that, upon initialisation (C:\cygwin64\bin\mintty.exe - ), Cygwin saves the old Windows $PWD as the Cygwin variable $OLDPWD (whilst setting its $PWD variable as /home/sh).

As an aside, we note the importance of starting Cygwin as a login shell: https://stackoverflow.com/a/43300782/31298396.

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Grass