If I execute a program using the -e option for xterm and close this program, then xterm closed as well, e.g.

xterm -hold -e "nano"

The window (i3wm) is still there but it's empty and I'm not able to do any inputs. How to run xterm like in the example above with a additional requirement, a callback for xterm if I closed nano?

What I can do is:

xterm -hold -e "nano;bash"

But I don't understand, why I have to start a shell like bash again. I thought xterm already should run a shell.

  • Why are you using -hold in the first place? -hold means "don't destroy the window, wait for the window manager to do it", and that's exactly what happens. If you want to start a new xterm with a login shell, why don't you use just xterm? Or do you want to start a login shell, and execute a command within this shell, and then continue to use the shell? – dirkt May 10 '17 at 6:33
  • @dirkt, your second guess, is what I'm looking for. – Hölderlin May 10 '17 at 8:38

xterm -hold -e cmd will run cmd in a new xterm window and then keep the window displayed after the command has exited (it would normally close the window).

If you want an interactive shell in the window after running an initial command, then

xterm -e 'cmd; bash'

will do this. There's no need for -hold as the window doesn't close until the shell session exits.

xterm can be used to run any program. By default it runs a shell, but with -e you change this default behaviour. xterm -e mutt, for example, would run the email reader mutt instead of a shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.