普通用户是这样的修改的,在/etc/profile
末尾加入,
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
source 一下就可以,
ethson@macbookpro:/private/etc$ cat profile
但是如果我 sudo su 后,就会进入 root 用户,一般的linux系统都会把上面的用户名@主机名:路径
颜色全部置为白,那么之前我设置的PS1就失效了。我搜索了下ubuntu上的做法,它是修改/root/.bashrc
里的,于是我在这个文件里也插入一行,
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
source 一下也生效了。
但我在mac上找不到/root/
这个目录,搜索了一圈无计可施,刚入mac党,希望有老司机指点一下,谢谢。
已搞定,参考这里:https://github.com/EthsonLiu/...