0

I often work with 3 machines at the same time, several sessions on X, several on Y, and Z is my local machine so obviously some sessions there - all sitting around in a terminal windows / tabs.

The thing is, I often confuse my local machine with some remote one, and this leads to amusing but occasionally somewhat tragic results.

I would like to have strong visual cues, which are triggered automatically by me logging in to a different machine, for which machine I am on, or at least cues which differ significantly for different machines.

So far I've been manually switching the color scheme for remote hosts (using Konsole), but that's: 1. manual and 2. doesn't distinguish between different hosts. And 1. manual, that's the most annoying part. If you forget to make this setting, you get a false sense of security.

Notes:

  • I already have PS1 spelling out the hostname, I need something more eye-catching than that.
  • Any reasonable heuristic for deciding when I've switchined hosts is fine, and you may assume I only use ssh if that helps.
  • Solutions which also support SSHing-within-SSHing are quite welcome.
  • I'm particularly (but not exclusively) interested in terminal emulator apps which let you control not just the backround as a solid color, but also have some image floating somewhere, or change the color of the session bar / window title bar, or other kinds of bells and whistles. Actually, something with actual bells and whistles would probably do the trick :-)
einpoklum
  • 10,666

2 Answers2

1

Take a look at Terminix. It includes features such as, quoting their homepage: "Automatic (triggered) profile switches based on hostname and directory".

(Or iTerm2 if you're on Mac, however, you using Konsole at the moments suggests it's probably not the case.)

egmont
  • 2,566
  • 1
  • 15
  • 18
0

My basic prompt:

$ echo $PS1
\u@\h\w\$

If I want the host to be green, I pick out the escape sequence of green from the ansi color list (\e[32m) and prepend the sequence of host (\h) with that and put the sequence of reset ([0m) so that other parts be with normal characters. Hence, my new PS1 is

export PS1='\u@\e[32m\h\e[0m\w\$ '

Putting it into my .bashrc would result in my choice of prompt at that host.

If I should want more, let's say my background to be cyan, then I would set the background sequence with an echo command and then just clear the screen:

echo -e '\e[46m'; clear
user556625
  • 4,400