如何更改MSYS2上的HOME目录和启动目录?

Cod*_*r88 15 windows gcc mingw-w64 msys2

我安装了MinGW-w64和MSYS2.但是如何在MSYS2中更改HOME目录?因此,当我输入cd $ home或cd~时,它会转到我定义的另一个目录.

我如何编写代码,以便起始目录始终放在.bat文件的位置?

在cmd中我使用了这段代码:

%~d1 cd"%~p1"调用cmd

所以当我在桌面上打开cmd时,它从桌面上的目录开始.

我怎么能用msys2做类似的事情?

dr *_*joo 26

如果您想将Windows主文件夹用作MSYS2的主文件夹,可以编辑/etc/nsswitch.conf并编写:

db_home: windows
Run Code Online (Sandbox Code Playgroud)

  • 由于某种原因,我无法让它为我工作。还有什么我需要做的吗? (2认同)
  • `/etc/nsswitch.conf` 不是 `/etc/nssswitch.conf` (2认同)
  • 这对我有用。我只需要修正答案中的拼写错误。我将进行编辑,但需要更改至少 6 个字符。所以可能还有其他 5 个不相关的字符更改需要我来修复这个答案。 (2认同)
  • 对我来说不起作用,但这确实按照此处的建议执行了“db_home: env windows /C/your-dot-files”[https://conemu.github.io/en/CygwinHome.html] (2认同)

小智 5

Msys2 将使用 windows %HOME% 作为 $HOME 目录。如果您在环境变量中设置 %HOME% (到您需要使用 Msys2 的 windows 目录),它将起作用。


Edd*_*e B 5

我更喜欢只更新/etc/fstab @ fstab

# cat /etc/fstab
# For a description of the file format, see the Users Guide
# https://cygwin.com/cygwin-ug-net/using.html#mount-table

# DO NOT REMOVE NEXT LINE. It remove cygdrive prefix from path
none / cygdrive binary,posix=0,noacl,user 0 0
##################################################################
# Canonicalize the two home directories by mounting the windows  #
# user home with the same path mapping as unix.                  #
##################################################################
none /c/Users/Edward /home/Edward binary,posix=0,noacl,user 0 0
Run Code Online (Sandbox Code Playgroud)