I'm trying to control the titles of my xterm windows and my cleverness has finally outpaced my knowledge. :-)

I have three functions: one which sets the title of the window; one which takes a passed command, calls the title function, and executes the command; and one which resumes a job after using `jobs` to determine the title:

```
title () {
    echo -en "\e]1;$(hostname) : $1\a\e]2;$(hostname) : $2\a"
}

run () {
    title $(basename $1) "$*";
    $*
}

fg () {
    if [[ "x" == "x$1" ]]; then
        title $(jobs | awk '/\['$1'\]/{print $3}') "$(jobs | awk -F '  +' '/\[[0-9]\]\+/{print $3}')";
    else
        title $(jobs | awk '/\['$1'\]/{print $3}') "$(jobs | awk -F '  +' '/\['$1'\]/{print $3}')";
    fi;
    builtin fg $*
}

```

Now, all of this is working beautifully… well, mostly. Setting the title by calling the function manually works fine. Setting the title by way of the `run` function works fine. Setting the title by resuming a job works fine… unless the job was started with the `run` function:

```
$ nano foo.txt
<CTRL-Z>
$ run nano bar.txt
<CTRL-Z>
$ jobs
[1]-  Stopped                 nano foo.txt
[2]+  Stopped                 $*

```

Well, I suppose that *is*, technically, the name of the command being executed by the `run` function, but that isn't really a useful thing to know, in this case.

So, since I have not only reached but *far exceeded* the limits of my knowledge about Bash, perhaps someone here can help me fix this. :-)