screen is a wildly useful little utility that lets you “multiplex” a terminal window: that is, you can have multiple shells open in a single Terminal window.
(I hear you about to say “tabs,” but please, STFU. screen is better.)
The problem with screen on Mac OS X Leopard is that it breaks a whole hell of a lot of things, notably it clobbers your PATH variable, and it makes things like TextMate’s mate command not work (you just get the error mate: failed to establish connection with TextMate.). Part of the issue seems to be one of the patches apple makes to screen, in particular:
--- screen.c.orig 2007-03-15 14:42:59.000000000 -0700
+++ screen.c 2007-03-15 14:42:10.000000000 -0700
@@ -101,6 +101,11 @@
#include "logfile.h" /* islogfile, logfflush */
+#ifdef __APPLE__
+#include <vproc.h>
+#include <vproc_priv.h>
+#endif
+
#ifdef DEBUG
FILE *dfp;
#endif
@@ -1211,6 +1216,11 @@
freopen("/dev/null", "w", stderr);
debug("-- screen.back debug started\n");
+#ifdef __APPLE__
+ if (_vprocmgr_move_subset_to_user(real_uid, "Background") != NULL)
+ errx(1, "can't migrate to background session");
+#endif
+
/*
* This guarantees that the session owner is listed, even when we
* start detached. From now on we should not refer to 'LoginName'
I reverted this patch (some googling seemed to show that this secret-sauce function _vprocmgr_move_subset_to_user is the problem) from Apple’s screen sources and recompiled it, and now mate -w works as EDITOR!
There is still some weirdness going on with the shells that screen starts, since the bash PS1 variable isn’t getting set, but that’s no big deal.
I’ve made a package out of this, which will overwrite /usr/bin/screen with the unpatched version, and will move the original binary to /usr/bin/screen.orig:
(I also hear you about to say “Fink” or “MacPorts.” Once again, STFU.)