MSYS2 home folder: show ~

bashmsysmsys2

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

HOME=$USERPROFILE

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?

Best Answer

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.*'"
Related Question