How to change the ~ default home directory? | 如何更改 ~ 缺省的主目录? #2993
-
|
Under bash, when I execute the bash 下当我执行 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
English Response:
This approach avoids altering system-wide Windows environment variables like Chinese Response (中文回复):
此方法不会修改系统级的 Windows 环境变量(如 |
Beta Was this translation helpful? Give feedback.
English Response:
In a Unix-like shell (e.g., bash), the
~(tilde) symbol is a shortcut for the current user’s home directory, which typically maps to$HOME. In Git-for-Windows, this defaults to your Windows user profile directory (e.g.,C:\Users\YourUsername). If you wantcd ~to point to a different directory without modifyingUSERPROFILEorHOMEPATH, you can:Override the
HOMEvariable in your shell session:Run
export HOME=/your/custom/pathin bash. This changes~temporarily for the current session.Permanently configure
HOMEin your bash profile:Add
export HOME=/your/custom/pathto~/.bash_profileor~/.bashrc. This ensures~points to your desired directory every time you star…