views:

34

answers:

3

I'm using Terminal under OS X quite extensively.

I find quite annoying (and a bit dangerous, too) that my local and remote sessions look exactly the same in the Terminal. I'm wondering if it's possible - maybe through a bit of bash-programming - to clearly distinguish between local and remote sessions. A different background color would be an amazing start.

NOTE: I was unsure about posting this question here or on SuperUser. It could potentially involve a bit of bash-programming and it could be of interest for many developers, so I chose Stack Overflow in the end. If you think I should move it to SU, just leave a comment...

+3  A: 

see e.g. http://stackoverflow.com/questions/103857/what-is-your-favorite-bash-prompt/109487#109487

second
+1 Changing the bash promp is the way to go.
karlphillip
Awesome. Thank you. I'll give it a try asap.
Roberto Aloi
A: 

Here is a suggestion for Leopard and Snow Leopard (I don't have Tiger to verify if it works).

  1. In Terminal Preferences, select the Settings tab and create a new settings with different background and name it your remote host.
  2. Click the Shell tab button, check the Run command box and enter the ssh command to connect to your remote host
  3. Now you can click your Terminal's Shell menu (on top), select either New Window or New Tab, select the setting you just created.
Hai Vu
+1  A: 

I've looked for a programmatic way to do this from the shell myself (I have a lot of different local users, for things like postgres, oracle, etc).

It looks like you can do it via AppleScript (which given that this sits on top of an underlying scripting framework suggests it should be possible to do it in something else).

http://www.red-sweater.com/blog/220/random-color-terminal

Some further digging turned up this - osascript is obviously the command line access to AppleScript. There are several approaches listed here, but it does look like this identifies a way to programatically change the active terminal window from within the Terminal (so you should be able to change the local session on login, if not the remote one).

http://hints.macworld.com/article.php?story=20040823015557368

A third way of doing it could be to wrap up a script to open a specific colour terminal for SSH sessions and create a separate icon for that.

JulesLt