a solution for high and dry xterm_title

Tribhuvan loka at rcn.com
Wed Jan 1 08:29:32 UTC 2003


While happily running mc-4.6.0pre2 on solaris-9-x86 - appreciating the new
xterm_title function, I couldnt help but notice that after I exit from 
mc the
xterm title was left high & dry where mc was last performing.

I'm envoking this tiny c-prog from .bashrc to return the xterm_title to 
something suitable:

Here's the line in my .bashrc at the end of the 'mc-pwd' function:
 
    if [ "$SESSION_SVR" != "" ]
        then echo "$USER@$SESSION_SVR" | xterm_title_command
    else
        echo "$LOGNAME@$HOSTNAME" | xterm_title_command
    fi

and the source for  xterm_title_command.c  :
__________________________________________

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

/* Set text in the xterm title from command line */
void
update_xterm_title (void)
{

  char title[50];
  scanf("%s",title);

  fprintf (stdout, "\33]0;%s\7",title);
  fflush (stdout);
}

int main (void)
{
  update_xterm_title ();
}
_________________________________________________

and, what the hek, here's the full mc .bashrc stuff:

alias m='mc-pwd'

mc-pwd ()
{
    MC_CWD_FILE="${TMPDIR-/tmp}/mc-$USER/mc.cwd.$$"
    /usr/local/bin/mc -c -P "$MC_CWD_FILE" "@$"
    if test -r "$MC_CWD_FILE"; then
        MC_CWD="`cat $MC_CWD_FILE`"
        if test -n "$MC_CWD" && test -d "$MC_CWD"; then
        cd "$MC_CWD"
        fi
        unset MC_CWD
    fi
    rm -f "$MC_CWD_FILE"
    unset MC_CWD_FILE
    if [ "$SESSION_SVR" != "" ]
        then echo "$USER@$SESSION_SVR" | xterm_title_command
    else
        echo "$LOGNAME@$HOSTNAME" | xterm_title_command
    fi
}
export -f  mc-pwd
________________________________________________________

midnight commander is by far the most-used utility on all of my systems
and I'm psyched to see development continued. It's one of the first things
I install on a new system.  Installed without a snag on solaris-9-x86 - just
use the new /usr/sfw/ tree for gnu/gnome1 libs which are now part of the
standard solaris distribution - or if you have the gnome-2-beta-3 package
installed, autoconf will find gnome-2 libs in /usr/gnome.

btw, I regularly check gnu/gnome mirrors for updated packages, and the 
new mc
was not anywhere to be seen. I found it rather by chance on:
http://www.go.dlr.de/fresh/unix/src/misc/
If there's an mc-devel mailing list I'd like to be on it.

Thanks and I hope this is useful!
Tribhuvan





More information about the mc-devel mailing list