Answers:
您需要PS1在您的环境中更改变量。PS1负责您的命令提示符的外观和其包含的信息。
永久变更
以下是.bashrcUbuntu 10.04 LTS 中默认文件的摘录:
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
这使命令提示符看起来像这样: username@hostname:~/directory$
如果更改此设置并删除的@\h一部分PS1,则将在命令提示符中删除主机名部分:
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
结果: username:~/directory$
临时变更
覆盖PS1当前bash会话:
export PS1="\u:\w\$ "
资源:
查看man bash并寻找PS1。
要将提示减少为用户名,可以将其添加到您的~/.bashrc:
PS1='\u $'
一些“高级”自定义参见:Bash Shell PS1:10个使您的Linux提示的示例,例如Angelina Jolie