Change the title prompt of the putty window

When using putty, if you open multiple windows, you will find that the title of the window defaults to username@hostname, which is very inconvenient. After checking it online, you can use the following methods to deal with it

Append the following lines of script to the end of the automatic script in ~/.bashrc (corresponding to the root user, which is the /root/.bashrc file).

1, vi /root/.bashrc

2, add the following code to the end:
# Auto add env parameter $PROMPT_COMMAND when use non-Linux tty login by ssh.
if [ "$SSH_CONNECTION" != '' -a "$TERM" != 'linux' ]; then
declare -a HOSTIP
HOSTIP=`echo $SSH_CONNECTION |awk '{print $3}'`
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@$HOSTIP:[${HOSTNAME%%.*}]:${PWD/#$HOME/~} \007"'
be

Save and log out and log back in.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326704200&siteId=291194637