美文网首页
bash 相关

bash 相关

作者: saronic | 来源:发表于2018-03-23 07:59 被阅读9次

修改 bash 的提示符

askubuntu.com原文
Currently it is:
michael@Castle2012-Ubuntu-laptop01:~/Dropnot/webs/rails_v3/linker/spec/controllers$
want to:michael:controllers$

To change it for the current terminal instance only

Just enter PS1='\u:\W\$ ' and press enter.

To change it "permanently"

In your ~/.bashrc, find the following section:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Remove the @\h, and replace the \w with an uppercase \W, so that it becomes:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
fi

Save, exit, close terminal and start another to see the result.

相关文章

网友评论

      本文标题:bash 相关

      本文链接:https://www.haomeiwen.com/subject/iortcftx.html