我使用特定的服务器通过SSH连接到所有服务器。 当我连接到SSH网关服务器时,它完美地在PuTTY标题栏中显示chronoz @ sshgw,当我连接到CentOS服务器时,此服务器显示为root @ server01。 使用不同的标题栏在PuTTY窗口之间切换是非常容易的。
不幸的是,当我login到Debian服务器时,标题栏不会改变。 它仍然说chronoz @ sshgw,而我实际login到root @ debianserver01。
我怎样才能改变这个? 这将大大提高我的生产力。
我花了一段时间才弄明白,但答案如下。
这是CentOS上的默认行为,而不是Debian中的行为,因为相关的代码已经在位于/etc/bash.bashrc的bashrc文件中编辑出来了。
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. # If this is an xterm set the title to user@host:dir #case "$TERM" in #xterm*|rxvt*) #PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' #;; #*) #;; #esac
当注释掉时,在PuTTY标题栏中完美显示administrator @ hostname:〜。 〜是用户的主文件夹,并将不断更新到当前工作目录。
administrator@debian: /home root@debian: /etc root@debian: ~ (means you are in /root, your own home-directory)