改变Mac OS (Catalina) zsh的prompt | change the display prompt of zsh on Mac OS (Catalina)

Catalina默认的shell从bash改成了zsh. Prompt的显示是由一个叫PS1的参数控制的

az@my-mbp ~ % echo $PS1
%n@%m %1~ %#

%n是账号, %m是机器名, %1~应该是当前directory, %#就是最后那个%

以下为修改一下机器名

%PS1='%n@learning %1~ %# '
az@learning code %

以上是临时改变的方法, 如果想一劳永逸的话, 就需要以下命令

sudo scutil --set HostName name-you-want

参考这个帖子 https://apple.stackexchange.com/questions/66611/how-to-change-computer-name-so-terminal-displays-it-in-mac-os-x-mountain-lion

Leave a Reply

Your email address will not be published. Required fields are marked *