10

it sounds like a stupid question, but I hope it isnt.

I want to create a simple xterm with a fixed title. I tried:

xterm -title whatever (that is what xterm --help suggests)

xterm -T whatever (according to man pages, this is the same as --title)

but well, my xterm always comes up showing username@hostname:~ in the title. I guess that this title comes from some environment variable; but I would prefer if I do not have to make a permanent change to my .bashrc or .profile just to be able to create one xterm with a fixed title?!

This is xubuntu 14.04

4
  • The default prompts (PS1) set the title. So any title that's set when xterm starts is then overridden when bash starts.
    – muru
    Apr 30, 2015 at 7:16
  • OK, I thought along those lines. And there is no way to prevent that?
    – GhostCat
    Apr 30, 2015 at 7:18
  • I don't know about XTerm, but GNOME Terminal has an option to keep the title from being overriden. What are you trying to achieve, exactly? What's the actual problem?
    – muru
    Apr 30, 2015 at 7:20
  • My "problem is this": I have to start a command line tool that should sit in the background (doing port-forwarding for me). When I do that in my ordinary terminal ... sooner or later, I might close that terminal; forgetting about the jobs running in the background. So, instead of starting them in a terminal session that looks like any other terminal session; I want to open an xterm with a title like "port-forwarding session!" ... and run the jobs in there. Just a more visible indication to avoid "unwanted" exits.
    – GhostCat
    Apr 30, 2015 at 8:02

3 Answers 3

23

Use

xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T whatever
2
  • 1
    thanks so much for this. saved me a bunch of time!!
    – thang
    Jun 8, 2019 at 19:27
  • This definitely works but just trying to understand this better - why is -xrm 'XTerm.vt100.allowTitleOps: false' required? can i add this to the .Xresources file? sorry total noob here. Apr 23, 2020 at 20:42
3

I know this thread was active a few years ago, but here is what I did recently. First, realize that the default configuration for XTerm is a little bit different now than it was in 1993 and just using the -T command line option won't work without changing a few configuration items for your X session files, .xinitrc and .Xresources. (You can check if these files exist by typing ls -a in your home (~) directory.)

  1. The .xinitrc text file in your home directory must have the first line

    xrdb -merge .Xresources

    (or whatever your resources file is named (it could be .Xdefaults)). This will activate the resources when X starts. If there is no .xinitrc file, you will need to create one. Make sure the last line in the file executes your window manager exec mwm, exec twm, etc.

  2. The .Xresources text file in your home directory must have the line

    xterm*allowTitleOps: false

    xterm*Title: yourtitle (if you want a custom default title for all xterm windows)

    Again, if the .Xresources file doesn't exist, just create one.

  3. Last of all, use the xrdb -merge .Xresources command to make the changes take effect immediately. You should now be able to use the -T and -n options for any new xterm windows.

1

To answer the "question" from the comment

I have to start a command line tool that should sit in the background (doing port-forwarding for me)


Instead of relying on an open xterm, you can run the program with nohup in the background, e.g.

nohup /path/to/port-forwarding-tool 2>&1 &

nohup will answer with

nohup: ignoring input and appending output to 'nohup.out'

This will keep the programm running, even if you close the xterm. If you're not interested in the program's output, redirect it to /dev/null

nohup /path/to/port-forwarding-tool >/dev/null 2>&1 &

Another option would be to start the tool as part of your desktop session, although this might depend on the desktop used, e.g. .xsession or autostart folder. Search for "startup" or "desktop autostart". With current systems, systemd user services might be an option too.

How do I start applications automatically on login?

Autostarting .desktop application at startup not working

1
  • Thanks, but that is really not what I was looking for. The whole point was to have a xterm sitting somewhere to remind me that some background thing was still running. xterm gone, that process gone. Using nohup gives me the exact opposite of that ;-)
    – GhostCat
    Mar 4, 2019 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .