To keep track of which ssh connection I have open in different tabs I use the following ~/.bashrc script:

function set-title() {
  if [[ -z "$ORIG" ]]; then
set-title <SERVERNAME>;
echo "set-title <SERVERNAME>"

I do this for my tabs that I don't have ssh open (with set-title LOCAL;) and on two different servers. On one server it does exactly what I want to do and changes the tab name, but on the other server it does not change.

When I type set-title <SERVERNAME>; on the command line myself it does change the tab name, and when logging in it does echo "set-title <SERVERNAME>". Also, if I do source ~/.bashrc it works as expected, so it is only when logging in to the server that it does not work.

On the server where it works on login runs Scientific Linux release 6.7 (Carbon), on the server where it does not work runs CentOS release 6.6 (Final). What could cause the set-title <SERVERNAME>; in the .bashrc script to not run correctly on login?

1 Answer 1


Without further information, it’s not possible to answer this question.

However, I imagine the most likely scenario is that the .bashrc is sourced by on login by .bash_profile or .profile – probably something similar to this:

# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"

I’d guess that on the system where the title isn’t being set, the PS variable is being set to another value at a later stage in the logon script.

The PS1 variable should really be set in the Bash profile (.bash_profile or .profile) which is only run on login and the variable should be exporteded as an environment variable so that its value is inherited by any sub-shells.

export PS1

or to use a short-hand that works for the Bash shell:

export PS1=${ORIG}${TITLE}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .