I've just installed MSYS2, and to have it use my Windows user folder as $HOME, I put this in /etc/bash.bashrc:


And that works fine when I just run cd, except the prompt doesn't show ~ anymore as the current path when I'm there. Another problem is that

cd ~

takes me to my home dir, but pressing tab after ~ doesn't expand it with the contents of my home directory; intead I get a list of my computer's users prefixed by ~, and trying to access one of those makes it try to cd to /home/(username).

How can I get ~ to play nice with a home directory that doesn't reside in /home?

  • 1
    What if you type ~/ and then Tab? (It shouldn't expand with the contents of your home directory if you type ~ and then Tab; it sounds like it's doing the right thing.) Sep 10, 2014 at 21:02
  • oh, I didn't know that. ~/ and tab doesn't expand at all.
    – tacospice
    Sep 10, 2014 at 21:17
  • How about ~/ta and then Tab, where you have a file in your home directory whose name begins with ta? Sep 10, 2014 at 21:19
  • Same there, doesn't expand.
    – tacospice
    Sep 10, 2014 at 21:50
  • is your username tacospice? what if you type ~tac<tab>... does that expand to a full "~tacospice"? To expand that, put it in an 'echo'. This reminds me of the issue of whether or not bach should expand variables when doing prompt completion. Some think yes, some think not... I think it became an obscure option. Might be similar for ~, but don't think it is usually expanded. What does "echo ~" print out?
    – Astara
    Sep 10, 2014 at 23:03

3 Answers 3


The correct way to do this is to put this into /etc/nssswitch.conf :

db_home: windows

See here for docs.

Also to make my homedir ls output more readable, I put this in ~/.bashrc :

alias ls="ls -h --color=auto --hide='ntuser.*' --hide='NTUSER.*'"
  • In my corporate environment, this put it on a network drive for me, not the local C:\Users, which is what I wanted.
    – dsz
    Jan 22, 2018 at 21:05
  • In that case, you might be able to configure that line to db_home: /c/Users/%U to override the home path. Ref: kflu.github.io/2017/07/18/2017-07-18-msys2
    – martian111
    Feb 1, 2021 at 11:00

Edit /etc/fstab to mount C:\Users as /home and voila! For example, append the following at the end of fstab:

C:/Users /home ntfs binary,noacl,auto 1 1
  • After reading about the format referenced at Cygwin(cygwin.com/cygwin-ug-net/using.html#mount-table), I am curious about the choices on the third column here. binary is fine, auto is ignored so can be omitted. What's the advantage of noacl over acl? It seems cygwin is able to construct POSIX permissions from NTFS ones. Is it just to keep in line with default cygdrive settings?
    – Yufan Lou
    Mar 23, 2016 at 8:48
  • Well, that was a while ago when I had to write some code in a Win64 environment; honestly, I can't recall the reason :-)
    – BahmanM
    Mar 23, 2016 at 15:42
  • 2
    Upon further reading, apparently the conversion done with acl is not good. I guess it's good enough to use binary,noacl.
    – Yufan Lou
    Mar 28, 2016 at 11:47
  • 1
    @FRIdSUN acl is bad if you have mixed cygwin (or msys)/windows uses of files and directories. Msys by default mounts drives noacl, cygwin acl This is, presumably, because the cygwin crew, mistakenly, assume that people stay in the cygwin environment all the time and do not use Windows tools in the same directories where they use cygwin. cygwin manipulates the access control lists in non-standard ways in order to emulate POSIX permissions on files (there is no 1:1 relation to NTFS file attributes). Bottom line is, for typical mixed use mount noacl. Sep 5, 2017 at 10:23

$USERPROFILE points to the user's home folder in Windows format, but obviously MSYS would expect a UNIX style path. I'd read the suggestion in another post, possibly on here, which is why I tried it.

For some reason, cd:ing to a Windows path in MSYS's bash will bring you to the correct mounted location of that folder, but then you will no longer be in the path specified by $HOME, which I believe is why the suggestion works, but still doesn't substitute the path for ~ in the prompt.

After that situtation dawned on me (thanks in part to Astara), I came up with this instead:


in /etc/bash.bashrc, or whichever bashrc file applies, in case you're not using MSYS2.

Of course, this requires your users folder to be C:\Users, as is the case on at least Windows 7 and 8.

  • You may still be able to make $USERPROFILE work. Try this: HOME=$(cd "$USERPROFILE" && pwd).
    – jpmc26
    Apr 28, 2016 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.