作为问题标题所述,我在终端中看到
name@name-macbook-air
。我想要隐藏这个信息。我尝试了以下方法。export PS1="\W \$" // Does not work even after restarting iterm
// this works but it always put $ but I want full path too but no username and computer name
echo "export PS1='$ '" >> ~/.bash_profile
. ~/.bash_profile
// This only put '\W' but no directory path
echo "export PS1='\W \$ '" >> ~/.bash_profile
. ~/.bash_profile
我该如何隐藏name@name-macbook-air的名称?
更新
当我执行echo $PS1
命令时,我会得到以下输出:
%{%f%b%k%}$(build_prompt)
我正在使用 oh-my-zsh。
~/.zshrc
中加入以下这行代码:DEFAULT_USER=name
,这样就可以显示name
而不是name@name-macbook-air
,其中name == whoami
。 - Daniel R. Livingston