Putty下实现可区分的显示动态Title标题窗口效果 [UbuntuSRV]

设置UbuntuSRV环境变量控制Putty窗口标题动态显示

2013-5-13     

 

 

 

     嗷,卖葛! 这次完了~    关错服务器了,,,

 

          :(   经常会犯这样的错误,因为桌面上开着N多个Putty远程连接,它们都长成一个样子,一不小心就会弄错! 有什么好办法能让我更好地区分它们呢?

 

              下面给出好的解决方案

 

  (以下场景执行Putty工具,使用root用户远程登录,SSH主机是 Ubuntu Server ) 

 

● 使用不带任何参数的 cd 命令,进入到 ~ 目录下面

 

●  由于 Ubuntu Server 13 的 ~/ 下没有.bash_profile , 我们先用 touch .bash_profile 创建一个全新的

 

●  用 vi 编辑之,输入以下内容

  ---------------------------------------

# .bash_profile 

# Get the aliases and functions 
if [ -f ~/.bashrc ]; then 
        . ~/.bashrc 
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH 
unset USERNAME

   # add following statement to the END of file  ~/.bash_profile
   # auto add env parameter $PROMPT_COMMAND when use non-Linux tty login by ssh.

   if [ "$SSH_CONNECTION" != '' ]; then 
      export HOSTIP=`echo $SSH_CONNECTION |awk '{print $3}' |awk -F: '{if ($1 == "") print $4; else print $1}'` 
      export PROMPT_COMMAND='echo -ne "\033]0;${USER}@'$HOSTIP':[${HOSTNAME%%.*}]:${PWD/#$HOME/~}  \007"' 
      env |grep PROMPT_COMMAND

      # Set the DISPLAY env var for Xmanager forward
      # export DISPLAY=`echo $SSH_CONNECTION |awk '{print $1}' |awk -F: '{if ($1 == "") print $4; else print $1}'`:0.0
   fi 

 ---------------------------------------

 

 

● 上面的脚本第一二句会执行一些环境参数设置的脚本 ~/.bashrc,经研究,由于 Ubuntu 下的默认设置脚本某些参数会与我们想要的效果冲突,所以要编辑并屏蔽掉部分内容。

 

     用 vi 编辑 ~/.bashrc 将下面的两段代码给注释屏蔽掉(将第一行最前加注释符号 # )

 

 

---------------------------------------

第一段:

# set a fancy prompt (non-color, unless weknow we "want" color)

case "$TERM" in

   xterm-color) color_prompt=yes;;

esac

 

---- 注释后 -------

# case "$TERM" in

#   xterm-color) color_prompt=yes;;

# esac

 

 

第二段:

# If this is an xterm set the title touser@host:dir

case "$TERM" in

xterm*|rxvt*)

   PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

   ;;

*)

   ;;

esac

 

---------------------------------------

   下面给出配置完毕后登录时自动显示相关信息的效果图


 

              enjoy !!     :) 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值