Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the hostname name in screen when you ssh into remote system?

I have various systems to which i regularly ssh into . The problem is , at some point of time i forget the hostname into which i have ssh into. Its kinda tedious to keep checking hostname all the time. Is it possible to display the hostname in screen ( i use screen to ssh into remote machines ) .

For example

$screen  
$ssh hostname.com

after i ssh , in my screen the current hostname is displayed.

like image 401
Rahul Avatar asked Jan 25 '12 07:01

Rahul


2 Answers

put this in .bashrc or .bash_profile

PROMPT_COMMAND='echo -ne "\033k$HOSTNAME\033\\"'

like image 153
farhad Avatar answered Oct 22 '22 00:10

farhad


Does the "hostname" command work?

I suspect your solution will be terminal program specific. What is your terminal client? Take a look at http://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/ .

like image 1
Mikhail Avatar answered Oct 22 '22 02:10

Mikhail