Xshell Forum

hostname displayed in tab name automatically

Last post: Friday, September 21, 2018 9:46 PM by Support, 3 reply

 
Thursday, May 26, 2016 3:43 PM - Chris

hostname displayed in tab name automatically

 
Hello,

I'm using the home/school version of the XShell application and I've seen a few forum threads here and there regarding this topic that have not shown any updates in some time.

I wanted to know if the ability to have the tabs auto-update the hostname of the server that I am logged in to will be made available (again?)?

The majority of the work I do is through access servers into labs and test environments and it's easy to lose track of which server I am remoted into from or to home as well as at school.

It is pretty easy to accidentally paste scripting, commands, or code into the wrong ssh session and I don't want to break anything if I can avoid it.

I'm using the 2016 version of XShell 5 Build 0977

Thank you,

Chris

Program Ver. : Xshell 5
Tuesday, May 31, 2016 3:36 PM - Support

Re: hostname displayed in tab name automatically

 
The prompt command function of linux may be helpful for this case. By using the Prompt Command, the terminal emulator can display any string in its title bar. In Xshell, it can be shown in the title bare and in the tab name.

1. Change the tab option to Show Terminal Title from the tab's context menu.
2. Configure your PROMPT_COMMAND variable as desired.

e.g. export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}"; echo -ne "\007"'

Certain shells do not support this feature.

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog
Tuesday, September 11, 2018 8:38 AM - Kayleigh Hazell

Re: hostname displayed in tab name automatically

 
Hi there,

I'm trying to find step by step instructions for this ?
I can enter that code into a session but how can I get it to persist every time I open a tab?
Screenshots would be extraordinarily useful,

Thank you,
Friday, September 21, 2018 9:46 PM - Support

Re: hostname displayed in tab name automatically

 
We responded to your issue directly via email, but we'll post it here as well in case anyone else needs the information.

To have Terminal titles change automatically, 3 steps things are required:

1. You're using the bash shell. (If you're using another shell, please let us know.)

2. Xshell's tab option should be 'Show Terminal Title'. Right click the tab and select the option.

3. Use the 'PROMPT_COMMAND' variable of BASH.
This variable acts right after a command commits. Using this variable, terminal titles can be changed automatically right after some command. Xshell changes terminal title when the following code comes from the server:
'\033]0;...\007'
You can write in whatever you want between '\033]0;' and '\007'

Many terminal users want their terminal title to reflect the current path. In this case, you can make the PROMPT_COMMAND like this:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'


If you put the above command in your shell startup scripts, such as .bashrc or .bash_profile, Xshell's terminal can take effect upon each login.

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog