MSYS2 home folder: show ~

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

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

$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:

HOME=/c/Users/$USER

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.

Tags:

Bash

Msys

Msys2