設定Ubuntu環境變數控制Putty視窗標題動態顯示

來源:互聯網
上載者:User

設定Ubuntu環境變數控制Putty視窗標題動態顯示    嗷,賣葛! 這次完了~    關錯伺服器了,,,       :(   經常會犯這樣的錯誤,因為案頭上開著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 startupprograms # PATH=$PATH:$HOME/bin # export PATH   # add following statement to the END offile  ~/.bash_profile # auto add env parameter $PROMPT_COMMANDwhen 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 Xmanagerforward      # 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 !!     :)   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.