The officially official Devuan Forum!

You are not logged in.

#1 2020-05-04 00:07:26

Altoid
Member
Registered: 2017-05-07
Posts: 394  

ssh terminals and how to differentiate between them

Hello:

Those who are more savvy than I am in command line work and SSL'ing into other installations probably have been through this.

I am slowly learning to use ssh, which I find quite entertaining but more than once I've 'almost' goofed up and done something in the local terminal instead of the other terminal I had open to a Raspberry Pi also running Devuan ascii.

Is there a way to eg: when I open a ssh connection, have the terminal automatically show something that would differentiate it from a local one.
eg: the title bar or font colours.

I've looked at the terminal configuration settings but found nothing.

Thanks in advance,

A.

Offline

#2 2020-05-04 01:14:44

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 420  

Re: ssh terminals and how to differentiate between them

You can but the following line in all your ~/.zshrc (or ~/.bashrc perhaps)

function title() { echo -n "\033]0;$1\007"; }

and then use

$ title Bendigo

to change the terminal title. Endless possibilities....

Offline

#3 2020-05-04 11:23:54

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 669  
Website

Re: ssh terminals and how to differentiate between them

Changing the prompt (PS1) is another option, for example: https://unix.stackexchange.com/question … st-via-ssh


"Il semble que la perfection soit atteinte non quand il n'y a plus rien à ajouter, mais quand il n'y a plus rien à retrancher." — Antoine de Saint-Exupéry

Offline

#4 2020-05-04 12:22:05

Altoid
Member
Registered: 2017-05-07
Posts: 394  

Re: ssh terminals and how to differentiate between them

Hello:

ralph.ronnquist wrote:

... the following line in all your ~/.zshrc (or ~/.bashrc perhaps)

function title() { echo -n "\033]0;$1\007"; }

and then use

$ title Bendigo

to change the terminal title.

Head_on_a_Stick wrote:

Changing the prompt (PS1) is another option ...

Thanks to both. =-)
I'll have a look at how these wotk.

In the meanwhile I'll have to be extra carefull.

Cheers,

A.

Offline

#5 2020-05-04 16:10:38

chris2be8
Member
Registered: 2018-08-11
Posts: 87  

Re: ssh terminals and how to differentiate between them

I've got several systems I administer by ssh'ing from my main system so I had this problem too.

My main system sets the window title to match the prompt, eg to the following:

chris@rigel:~/bin

But most of the other systems don't set it. As a work around I created a directory named after each system on my main system, cd'ed  into it and ssh'ed from there onto the other system. So the window title says something like:

chris@rigel:~/vega

which tags the window as being the one ssh'ed onto vega. It's not ideal but it helps.

Also on all my systems the prompt says the hostname as well as the current directory. Train yourself to look at it before doing anything. You might be able to set the prompt to different colours on different systems (although I prefer green prompt most of the time, but red if I need to run as root).

Chris

Offline

Board footer