How can I programmatically determine the current Cygwin user's home directory in Windows format (e.g. C:\cygwin\home\user) so I can read from it outside of Cygwin Bash?
Using Cygwin The installation directory (by default, c:\cygwin) is the root of the Unix-like file system, which contains bin, etc, home, tmp, and usr directories as would be found on a GNU/Linux or other Unix system.
In a new installation of Cygwin, your home directory will be in C:/cygwin/home/<user>/ , and can be accessed by the usual ~ shortcut. Although this works just fine, it's often useful to use the utilities provided by Cygwin in your local Windows user area C:/Users/<user> .
From the Start menu, select Parameters > Control Panel > System. Select the Advanced tab and click Environment variables. Edit the PATH environment variable to add the Cygwin installation directory, for example c:\cygwin\bin; and click OK.
In Windows, after you have installed Cygwin, you can launch a Cygwin64 Terminal: Associated with the state of the terminal is a working directory, or in the parlance of Windows, a current directory. Specifically, by default when you open a Cygwin64 Terminal, the working directory is /home/your-user-id.
You can use cygpath
:
cygpath -w ~
Example output:
C:\Users\dhaley
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With