Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Color Terminal screens and ssh revisited yet again UNIX
After at least five different hints on the matter, you may be getting sick of hearing about coloring your Terminal when you run ssh.

Well, relax! This hint actually reduces the number of total hints. JD Smith and I have collaborated to produce a joint version of our previous hints, ssh_host (link #2 above) and colorssh (#4 above). The new script is called colorwrap (2KB download) and includes the following features:
  • Simplicity (from ssh_host)
  • No more wrong windows getting colored (from ssh_host)
  • Detection of previous color settings (from colorssh)
  • Ability to wrap arbitrary commands (from colorssh)
  • Handling of both foreground and background colors (brand new)
To use it, simply prefix your command with colorwrap, like this:
colorwrap ssh -X bubba@some.machine.com
I personally like to alias my ssh command to colorwrap ssh. You can also edit the script to customise the colors that get set. One handy trick is to use the GUI to the set the colors to taste, and then run the following command to find the relevant codes:
colorwrap getcolor
Use those codes when editing the file to set your own custom colors.

[robg adds: I tested the script, and it worked fine, though I chose to remove the .sh from the script's name ... and remember to use chmod a+x colorwrap to make it executable.]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[11,938 views]  

Color Terminal screens and ssh revisited yet again | 8 comments | Create New Account
Click here to return to the 'Color Terminal screens and ssh revisited yet again' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Color Terminal screens and ssh revisited yet again
Authored by: pauljlucas on Fri, Sep 23 2005 at 12:21PM PDT
I still don't get why people like to make simple things complicated. Just create a Terminal window as you want it, color and all, and save its .term file. You change the Shell plist item to be "ssh whatever" and it works.

Unless you're ssh'ing to lots of different hosts all the time, the above is good enough.

---

- Paul

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: tomholio on Fri, Sep 23 2005 at 3:27PM PDT
Unless you're ssh'ing to lots of different hosts all the time, the above is good enough.
uhm, that's pretty much the whole point! thanks to the two authors for collaborating and wrapping everything up!

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: the_shrubber on Fri, Sep 23 2005 at 7:27PM PDT
That's one good way to do things (especially since it lets you set all the colours, unlike our script). But for me, invoking a special purpose Terminal for a specific subtask doesn't come very naturally. My perhaps suboptimal tendency whenever I want to ssh somewhere is to pick up whatever terminal I have nearby and just use that. This script is useful for dealing with this sloppy behaviour.

Also, one thing which seems harder with the save-a-Terminal method is using ssh-agent. I tend to set up an ssh-agent, paste the details into a Sticky, and replicate it across several Terminals. I'd welcome any elegant suggestions you have for dealing with that :-)



[ Reply to This | # ]
ssh-agent
Authored by: sjk on Fri, Sep 23 2005 at 7:58PM PDT
Not sure I completely understand your problem with ssh-agent but SSHKeychain might be a solution for it. Highly recommended, even with an intermittent memory leak on 10.3.x (haven't seen that on 10.4.x).

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: capacity on Tue, Nov 13 2007 at 2:27PM PST
This script broke under 10.5 for me because the RGB values for "special" colors have apparently changed in Terminal.app. I used colorwrap.sh getcolor to re-get my colors and set the new values in colorwrap.sh and almost everything is back to normal.

However, I cannot get window background color to go partially transparent using a negative value as the 4th color argument as described in this hint (e.g., {57212, 56949, 40762, -5000}), so whenever I ssh to a host my window goes completely opaque (but I can't say I remember if this worked under 10.4.x or not...).

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: capacity on Tue, Nov 13 2007 at 6:49PM PST
Also, I can't figure out why the echo command now (under 10.5) prints the -n -e flags when it didn't used to. I removed them, and despite their apparent necessity from checking out the man page (or at least the need for -n, not sure what the -e is for), colorwrap.sh seems to still function normally. Maybe printf should be used instead.

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: leono on Wed, May 14 2008 at 12:18PM PDT
To fix the script in 10.5, replace all negative numbers in your color strings by adding 65536 to them. E.g. -1 become 65535.

Apparently the older version of Applescript in 10.4 had a bug that caused the higher numbers to be interpreted as signed integers, rolling them over into the negative numbers.

[ Reply to This | # ]
Color Terminal screens and ssh revisited yet again
Authored by: jaserh on Sun, Nov 8 2009 at 4:50AM PST
This no longer seems to work for me in Snow Leopard. I get errors like:

247:263: execution error: Terminal got an error: Can’t get window 1 whose name contains "ssh -C -c blowfish -g -i /Users/jason/.ssh/id_rsa jasonh@SOMESERVER.com_342". Invalid index. (-1719)

Anyone else having this problem?

[ Reply to This | # ]