Mike Christianson
Mike Christianson

Categories

Perhaps most people using Cygwin don’t realize this, but they actually have two home directories. One is their Windows home directory (%USERPROFILE%) and the other is their Cygwin home directory (~).

Several months ago I became frustrated with repeated navigation from one to the other, so I began using a symbolic link. In ~ I created a link to %USERPROFILE% with ln -s "$USERPROFILE" home. Thus, any time I wanted to change to my Windows home directory I would simply cd ~/home.

It worked, but that dichotomy remained… Then, it occurred to me: why couldn’t ~ and %USERPROFILE% be the same?

Luckily, they can! In fact, the Cygwin documentation on alternate home roots shows exactly how. Using mkpasswd, one or all home directories may be set to any arbitrary path; to change all home directories to the Windows home directory:

mkpasswd -c -p "$(cygpath -H)" > /etc/passwd

Pretty neat. See the Cygwin documentation on alternate home roots for more information.