Dellanave

Holy Crap I Found an Awesome OS X Feature

Posted April 26th, 2007 by david & filed under Apple, Code, Tech.

I got to thinking today that it would be neat if I could place a background image in my Terminal windows. See, I spend 99.9% of my time ssh’ed into other machines. I do all my development remotely on other boxes. It doesn’t really get confusing which box I’m on, but it can take a second to find a different machine, and a lot of times I end up popping a new Terminal and opening a new ssh.

Sure enough, Terminal.app has a background image feature. Thing is, I needed to find a way to automatically change the image based on what machine I ssh’ed into. I started digging around, and holy shit did I find an awesome feature. I had no clue that you can actually save entire Terminal sessions.

You go into Terminal->Window Settings. Make whatever changes you want. In my case I set the name and background image for a particular machine. Close that. File->Save. Select “Execute this command” and enter the ssh command for the host. Say “ssh -l david dellanave.com”. Save the file. Couple this with ssh public key authentication, and I can launch a new Terminal session with a handy background image that automatically connects and logs into the box I want. Hell yes.

And no, this isn’t my normal desktop, I setup one of my side monitors as an example. Too much sensitive stuff on the main display.

Sexworld Minneapolis

If you like what’s here, please follow me on twitter here.

Posted by: David Dellanave

Check Out David's Website.

28 Responses to “Holy Crap I Found an Awesome OS X Feature”

David Mendez | April 27th, 2007 at 10:56 pm

This is a nice feature of Terminal windows, I also like being able to set transparency on them which can be very convenient for development on a smaller screen (plus it’s nice eye candy).

Steve | April 27th, 2007 at 11:47 pm

There is a nice program available on Linux and Mac called “screen”. It creates virtual terminals for you. Screen can use one horizontal row on the bottom of your terminal to identify which machine you’re on (just configure .screenrc). I use this application to manage about six terminals during the day. Oh and, you can even split each screen horizontally. Finally, if you close your terminal, screen will keep running and you can reattach to it. Great when you network connection drops.

Regards,
Steve

Matt Peters | April 28th, 2007 at 12:13 am

Nice. I knew about saving the terminal sessions… But what I’ve been trying to do is find a way to connect to multiple ssh servers at launch of Terminal.app. Any idears? :D

Andrew Kneebone | April 28th, 2007 at 12:30 am

Lets hope it does work in X11.. BTW how damn nice is piping X from a Linux or Unix etc server to your mac..

Lex | April 28th, 2007 at 1:25 am

Us old timers have used this for a while…

### — VT100 escape sequence to set titlebar to hostname
printf “33]0;%s07″ `uname -n | cut -f1 -d.`

Bill | April 28th, 2007 at 1:31 am

You can actually save all sessions too. I have a few .term files that launch a series of windows to one machine (e.g., one tall window on the left, two half sized windows on the right).

Combined w/ Quicksilver, it’s just Cmd-Space foo, return to launch foo.term.

Sean | April 28th, 2007 at 2:02 am

Terminal also accepts XTerm control sequences for setting titles.
I have a simple program that sends the “set window title” string (ESC]2;^G). This allows me to quickly select a window from the window menu. :-)

I have all my remote hosts (and my local one, for that matter) call the program on login (I have a ksh function called ’setwin’ that handles the converting my info (what host I’m on and the tty)).

- | April 28th, 2007 at 4:55 am

“too much sensitive stuff on my main display” – hey I’ve got an Awesome OS X Feature for you too – it’s called minimize!

Showing off that you have more than one display is pretty sad.

Cheeseburger Brown | April 28th, 2007 at 5:31 am

That’s very cool. And, I’d like to add, your backgrounds for disambiguating sessions are practically identical to my backgrounds for disambiguating my various virtual desktop zones.

We’re connected somewhere, through sub-Finder space.

bigkm | April 30th, 2007 at 4:48 pm

Most people don’t know that you can drag a file into the window and the escaped path will be printed

brian | April 30th, 2007 at 7:17 pm

A few notes:

1) first of all, rather than ’ssh -l user example.com’, you can say ’ssh user@example.com

2) you can also color your terminals with the process described here: http://apple.newbox.org/article.php?story=colorful_terminal

3) a benefit of coloring them, rather than using a grey-and-black picture, is that you can tell which is which even when they’re minimized.

4) also, coloring terminals as described above doesn’t require any window settings–just type in the command and the session starts and the proper color appears. So you can log out of one box, log into another, and everything is colored correctly–no need to open a new window.

aidanfindlater.com » Blog Archive » Keeping track of ssh connections the colourful way | May 3rd, 2007 at 11:07 am

[...] This guy has each Mac OS X Terminal window with a custom background, but it would mean I would have to open ssh connections using saved sessions, which I don’t want to do. As well, I suspect that after you log out, the window background will still be set for the remote server. I like the idea, but not the implementation. If there was a way to manipulate the current Terminal window from the command line, then I’d just write a wrapper script for ssh that automagically changes the background to and from the server being connected to (but I haven’t found a way of doing this). [...]

david | April 28th, 2007 at 8:56 am

Matt,

If you didn’t see below, you can save a bunch of Terminals too, rather than just one.

I use screen as well religiously, but it doesn’t do the same thing for me as being able to launch Terms with a file.

Bob Harris | April 28th, 2007 at 8:43 pm

The X11.app on Mac OS X works fairly well (Optional Install from the installation DVD). I use a PowerMac G5 as my workstation and develop Linux kernel software, so I’m constantly exporting X-Window sessions back to my Mac (mostly things like xload, gvim and TightVNC).

Dealing with copy/paste issues can be a bit interesting. It is important to read the X11.app Preferences on how to map mouse clicks to get the most out of X11 on Mac OS X.

Bob Harris