mc/mc-userhost.patch
Jindrich Novy e52ead9872 - update from CVS
- sync with .utf8 patch
- add displaying of username/hostname in xterm title
2005-03-24 14:34:59 +00:00

34 lines
833 B
Diff

--- 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 = '?';