5
1
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?
ps: Reputation too low, so I couldn't tag it msys2
1What 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.) – G-Man Says 'Reinstate Monica' – 2014-09-10T21:02:02.060oh, I didn't know that. ~/ and tab doesn't expand at all. – tacospice – 2014-09-10T21:17:41.113
How about
~/ta
and then Tab, where you have a file in your home directory whose name begins withta
? – G-Man Says 'Reinstate Monica' – 2014-09-10T21:19:26.953Same there, doesn't expand. – tacospice – 2014-09-10T21:50:48.180
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 – 2014-09-10T23:03:30.680
Ahh! That brought me to the answer. Naturally, $USERPROFILE contains the path to the home directory in Windows format, and for some reason, MSYS2's cd still accepts Windows style paths, but then brings me to the mounted location. So I was essentially doing "cd C:\Users<user>" and then getting redirected to /c/Users/<user>. Setting $HOME with the proper path makes everything work normally (~ in the prompt, ~/ expansion). Feel free to post it in the form of an answer and I'll accept it. – tacospice – 2014-09-11T00:59:51.957
A working value for $HOME is HOME=/c/Users/$USER in bashrc (at least on Windows 8). – tacospice – 2014-09-11T01:02:38.180