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 modifyingUSERPROFILE
orHOMEPATH
, you can:Override the
HOME
variable in your shell session:Run
export HOME=/your/custom/path
in bash. This changes~
temporarily for the current session.Permanently configure
HOME
in your bash profile:Add
export HOME=/your/custom/path
to~/.bash_profile
or~/.bashrc
. This ensures~
points to your desired directory every time you star…