[英]Debian .bashrc: prompt PS1
Let's say I'm on a fresh install of Debian, Jessie (or Wheezy). 假设我正在重新安装Debian,Jessie(或Wheezy)。 As a regular user, I've got the prompt defined in the
/etc/bash.bashrc
file, eventually override by the one in my /home/foobar/.bashrc
作为普通用户,我已经在
/etc/bash.bashrc
文件中定义了提示,最终被我的/home/foobar/.bashrc
的提示覆盖
Ok, cool, so I've got something like that: foobar@myserver:~$
Now, I'm trying to understand the code below: 好的,很酷,所以我得到了类似的东西:
foobar@myserver:~$
现在,我试图理解下面的代码:
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
As you can see, the PS1 variable (= the prompt) seems to be overrided again (cause yeah I'm in a xterm
). 如您所见,PS1变量(=提示符)似乎再次被覆盖(因为是的,我在
xterm
)。 But I can't get why we have another $PS1
on the end of the line! 但是我不明白为什么我们在行尾还有另一个
$PS1
!
In order to get this, I've put 3 letters a
b
c
in this line : 为了得到这个,我在此行中放了3个字母
a
b
c
:
PS1="a\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]b$PS1 c"
And now, I have the strange prompt below: 现在,我在下面看到奇怪的提示:
abfoobar@myserver:~$ c
So it seems that the almost entire line is not use, everything between the brakets. 因此,似乎几乎整个生产线都没有使用,所有的东西都没有使用。
PuTTY
; PuTTY
运行此xterm; in ubuntu, this line is quite different PROMPT_COMMAND='echo -ne "\\033]0;${USER}@${HOSTNAME}: ${PWD}\\007"'
PROMPT_COMMAND='echo -ne "\\033]0;${USER}@${HOSTNAME}: ${PWD}\\007"'
the part between \\[
\\]
seems to be an escape sequence which is handled by terminal : ESC ]
which is named OSC
for Operating System Commands in following link xterm escape sequence \\[
\\]
之间的部分似乎是一个转义序列,由终端: ESC ]
处理,在以下链接xterm转义序列中,该名称为OSC
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
Ps = 0 -> Change Icon Name and Window Title to Pt.
It is to change xterm window title. 这是要更改xterm窗口标题。
As the window title contains the current working directory setting the prompt allows to update the title when changing directory after cd command. 由于窗口标题包含当前工作目录设置,因此在使用cd命令更改目录后,提示允许更新标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.