这是因为 /etc/bash.bashrc 为您的提示设置了一个新值:
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
# but only if not SUDOing and have SUDO_PS1 set; then assume smart user.
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
Run Code Online (Sandbox Code Playgroud)
提示(user@host
事物)的外观由变量控制PS1
。可能你有类似的东西
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Run Code Online (Sandbox Code Playgroud)
在您的~/.bashrc
文件中。奇怪的\[\033[00m\]
等字符用于为提示着色。
\u
是用户名 ( h4ck3r
),\h
是主机名 ( h4ck3rE780
),\w
是当前工作目录(~
表示您的 HOME 目录)。
当你 source 时/etc/bash.bashrc
,变量PS1
被设置为其他值(没有颜色),你会得到一个不同的提示。这很简单。
尝试
PS1='user=\u, host=\h, directory=\w $'
Run Code Online (Sandbox Code Playgroud)
在终端窗口中查看结果。采购/etc/bash.bashrc
没有做任何不同的事情(除了实际参数)。
归档时间: |
|
查看次数: |
1461 次 |
最近记录: |