[patch] have autoaka mode use the full cmd, not just the first word

Erik Osheim <[email protected]> Thu, 2 Oct 2008 07:08:09 -0400
Newsgroups gmane.comp.gnu.screen
Message-ID <20081002110808.GA4454__24556.9134400741$1238089070$gmane$org@worlock.plastic-idolatry.com>
--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here's a patch that I've been using locally for a couple of years. It
sets window titles to the full command run, not just the first word.

Many people where I worked were frustrated that often their screen
windows would get autotitled as so:

0 ssh
1 ssh
2 vi
3 vi
4 su
5 bash

With this patch, it would work as follows:

0 ssh larry
1 ssh curly
2 vi .bashrc
3 vi .screenrc
4 su - joe
5 bash

In general, I think users who like autoaka tend to prefer getting more
information rather than less. Anyway, this patch just changes the
behavior, but I could imagine having a setting in .screenrc control
whether or not to limit the effect to a word (or maybe truncate at a
fixed number of characters).

-- Erik

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="full_aka2.patch"

diff --git a/src/ansi.c b/src/ansi.c
index 20082fe..0dc204a 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -2261,13 +2261,14 @@ FindAKA()
       else
 	wp->w_autoaka = 0;
       line = cp;
-      while (len && *cp != ' ')
-	{
-	  if (*cp++ == '/')
-	    line = cp;
-	  len--;
-	}
-      ChangeAKA(wp, (char *)line, cp - line);
+      y = (int)cp;
+      while (len)
+        {
+          if (*cp++ != ' ')
+            y = (int)cp;
+          len--;
+        }
+      ChangeAKA(wp, (char *)line, (int)y - (int)line);
     }
   else
     wp->w_autoaka = 0;

--J2SCkAp4GZ/dPZZf--