Set Ubuntu environment variable control Putty window title dynamic display

Source: Internet
Author: User
Set the Ubuntu environment variable to control the title of the Putty window! This time is over ~ Turn off the wrong server,: (this is often the case because there are multiple Putty remote connections on the desktop, they all look like one, an error will occur if you are not careful !... Information & nbsp set Ubuntu environment variable control Putty window title dynamic display ghost, sold GE! This time is over ~ Turn off the wrong server, and: (This mistake is often made because N or more Putty remote connections are opened on the desktop, and they all look like one, so they will be wrong if they are not careful! Is there any good way for me to better distinguish them? The following provides a good solution (the Putty tool is executed in the following scenarios, and the root user is remotely logged on. The SSH host is Ubuntu Server) ● use the cd command without any parameters to enter ~ Directory ● due to Ubuntu Server 13 ~ /There is no. bash_profile. first use touch. bash_profile to create a brand new ● use vi to edit it. enter the following content ----------------------------------- #. 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 --------------------------------------- ● The first two sentences of the above script will execute scripts for setting environment parameters ~ /. Bashrc. after research, because some parameters of the script set by default in Ubuntu will conflict with the expected effect, we need to edit and block part of the content. Edit with vi ~ /. Bashrc shields the following two sections of code from comments (adds the annotator # to the beginning of the first line) ------------------------------------- the first section: # set a fancy prompt (non-color, unless weknow we "want" color) case "$ TERM" in xterm-color) color_prompt = yes; esac ---- Post-annotation ------- # case "$ TERM" in # xterm-color) color_prompt = yes; # esac Section 2: # If this is an xterm set the title touser @ host: dir case "$ TERM" in xterm * | rxvt *) PS1 = "\ [\ e] 0; $ {debian_chroot: + ($ debia N_chroot)} \ u @ \ h: \ w \ a \] $ PS1 ";;*);; esac --------------------------------------- enjoy is automatically displayed upon logon after configuration is complete !! :)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.