Results 1 to 10 of 10

Thread: Show hostname of different servers in shell tabs

  1. #1
    Join Date
    Jan 2013
    Beans
    15

    Question Show hostname of different servers in shell tabs

    Hi all,

    I have open several ssh connections to different servers in one terminal under different tabs at the same time. I just want to know what I have to do that the hostname of the different servers I am connected to, apper in the tabs of my terminal. So that I can distinguish better between the different servers.

    Regards,

    patty92

  2. #2
    Join Date
    Oct 2005
    Location
    Milano, Italy
    Beans
    864
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: Show hostname of different servers in shell tabs

    Hi,
    as far as I can tell is already managed in this way in xfce4-terminal; you should have on each tabs the connected hostnames displayed, in this form:
    user@hostname
    ------------------------------------------------
    yep ”short and long URL„
    http://yep.it/
    ------------------------------------------------

  3. #3
    Join Date
    Apr 2012
    Beans
    5,050

    Re: Show hostname of different servers in shell tabs

    it works that way in gnome-terminal for me as well, under the regular Ubuntu desktop - patty92, what version/flavor of Ubuntu and what terminal client (gnome-terminal? xterm? terminator?) are you using?

  4. #4
    Join Date
    Jan 2013
    Beans
    15

    Re: Show hostname of different servers in shell tabs

    Hi,

    thank you for your answer. I guess you are right, normally this should be the case, but as you can see in my screenshot below, there are 2 tabs. The left tab is an normal terminal on my notebook and in the tab is written patty@Lenovo-G770, this is correct so far, but with the right one I am connected to my server and in the tab is also just wirtten patty@Lenovo-G770 instead of patty@fb-websrv-patty. Is there something I can put in the .bashrc maybe?

    Regards,

    patty

    Selection_001.png

  5. #5
    Join Date
    Jan 2013
    Beans
    15

    Re: Show hostname of different servers in shell tabs

    Hi steeldriver,

    I am using xubuntu 13.04 as operation system and my terminal client is a xfce4-terminal.

    Regards,

    patty

  6. #6
    Join Date
    Apr 2012
    Beans
    5,050

    Re: Show hostname of different servers in shell tabs

    It should already be in the (default) .bashrc afaik

    Code:
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    Maybe your remote ~/.bashrc is missing that part - or the $TERM environment variable isn't getting set?

  7. #7
    Join Date
    Jan 2013
    Beans
    15

    Re: Show hostname of different servers in shell tabs

    Quote Originally Posted by steeldriver View Post

    Code:
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    This is set in my ~/.bashrc

  8. #8
    Join Date
    Oct 2005
    Location
    Milano, Italy
    Beans
    864
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: Show hostname of different servers in shell tabs

    Quote Originally Posted by patty92 View Post
    Hi,

    thank you for your answer. I guess you are right, normally this should be the case, but as you can see in my screenshot below, there are 2 tabs. The left tab is an normal terminal on my notebook and in the tab is written patty@Lenovo-G770, this is correct so far, but with the right one I am connected to my server and in the tab is also just wirtten patty@Lenovo-G770 instead of patty@fb-websrv-patty. Is there something I can put in the .bashrc maybe?

    Regards,

    patty

    Selection_001.png
    I see on your screen shot that you connecto to:
    Code:
    patty-hainer.no-ip.org
    Is ths hostname declared somewhere on remote machine?
    ------------------------------------------------
    yep ”short and long URL„
    http://yep.it/
    ------------------------------------------------

  9. #9
    Join Date
    Jan 2013
    Beans
    15

    Re: Show hostname of different servers in shell tabs

    No it is not. The hostname of the machine is "fb-websrv-patty" "patty.hainer.no-ip.org" is just the dynDNS for my server. But this issue is not only related to my own server. On my pc at work, which is running xubuntu 13.04 too the same issue appears if I connect to some servers.

  10. #10
    Join Date
    Jan 2013
    Beans
    15

    Re: Show hostname of different servers in shell tabs

    This entered in the ~/.bashrc works for me:

    function ssh(){
    if [ $# -lt 1 ]
    then
    echo "usage: no shh"
    return
    fi
    ssh_host=`echo $1 | cut -d "@" -f 2`
    echo -ne "\033]0;${ssh_host}"; echo -ne "\007"
    /usr/bin/ssh ${1+"$@"}
    }

    So this issue is solved. Thanks for all of you effort!

    Regards,

    patty

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •