Re: Xterm window title enhancement to hostname:/path II.



Hello Pavel,

here is the patch where both hostname and username are printed in the
xterm window title.

Cheers,
Jindrich

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1a/src/main.c.hostname	2005-03-23 13:59:31.198747928 +0100
+++ mc-4.6.1a/src/main.c	2005-03-23 16:00:49.135333392 +0100
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <pwd.h>
 
 #include "global.h"
 #include "tty.h"
@@ -1612,9 +1613,22 @@ void
 update_xterm_title_path (void)
 {
     unsigned char *p, *s;
+    char h[64];
+    struct passwd *pw;
 
     if (xterm_flag && xterm_title) {
 	p = s = g_strdup (strip_home_and_password (current_panel->cwd));
+	if ( !gethostname (h, 64) ) {
+		h[63] = '\0'; /* Be sure the hostname is NUL terminated */
+		s = g_strdup_printf ("%s:%s", h, s);
+		g_free (p);
+		p = s;
+	}
+	if ( (pw = getpwuid(getuid())) ) {
+		s = g_strdup_printf ("%s %s", pw->pw_name, s);
+		g_free (p);
+		p = s;
+	}
 	do {
 	    if (*s < ' ')
 		*s = '?';


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]