隐藏 Git Bash 的用户名和计算机名 for Windows 10

Hide username and computer name from Git Bash for Windows 10

有没有办法从 Git Bash 中删除 Window 10 的用户名和计算机名称?

我已经检查过了:https://github.com/Maximus5/ConEmu/issues/199

但不明白该怎么做。

按照以下步骤操作:

  1. 转到 C:\Program Files\Git\etc\profile.d\ 文件夹
  2. 在您喜欢的文本编辑器中找到并打开 git-prompt.sh 文件
  3. 转到行号15
  4. 将整行替换为PS1="$PS1"''
  5. 就是这样。 Start/Restart Git Bash 你应该会看到用户名和计算机名不见了。

注意: 您还可以通过注释掉行号 16[=31] 来隐藏恼人的 MINGW64 文本=] 和 17 相同的文件。要注释掉这些行,只需在行首添加 # 即可。而已。现在 start/restart Git Bash 它应该消失了。

更好的方法!!

按照@Saabbir 提到的步骤进行操作,有一个大的变化:

#  comment out the wrapping if-else block
if test -f ~/.config/git/git-prompt.sh
then
    . ~/.config/git/git-prompt.sh
else
  #  leave the content uncommented
  ...
fi

保存文件,git-prompt.sh 使用 另存为(在您的编辑器中)在此路径 C:\Users\{current_windows_user}\.config\git


解释: 您可以在第 8 行看到它检查 ~/.config/git 上的同一个文件。所以最好更新配置文件而不是实际的设置文件。