How to change HOME directory and start directory on MSYS2?

Coder88 picture Coder88 · Nov 26, 2015 · Viewed 19.1k times · Source

I have installed MinGW-w64 and MSYS2. But how do I change the HOME directory in MSYS2? So that when I type cd $home or cd ~ it goes to another directory that I defined.

And how do I write a code so that the starting directory is always where the .bat file is placed on?

In cmd I used this code:

%~d1 cd "%~p1" call cmd

so when I open cmd on my desktop, it starts from the directory on desktop.

How can I do a similar thing with msys2?

Answer

dr ganjoo picture dr ganjoo · Jun 4, 2017

If you would like to use your windows home folder as the home folder for MSYS2, you can edit /etc/nsswitch.conf and write:

db_home: windows