0

I open some iTerm2 sessions via ttab. I start these session for textual UI commands like top or commands which might run for a long time like cp -r <large-dir> <backup-location>.

After the command has finshed the iTerm session stays open with the (bash) shell prompt. I have to close it manually via Ctrl-D.

How can I tell iTerm to close the session automatically when the shell is back at its prompt?


I tried using a special profile for this (because ttab can open the session in a specified iTerm profile), but I couldn't find a setting which closes the session when the shell is waiting at its prompt.

6
  • How much monitoring of the command's output do you need?
    – mmmmmm
    Feb 23 at 8:53
  • What about “&& exit” at the end of command? Feb 23 at 9:11
  • @mmmmmm Nothing. Just want to run it. The command might be long running like cp or an outputless “TUI” (like top).
    – halloleo
    Feb 23 at 14:02
  • @AivarPaalberg I tried “&& exit”, but ttab translates this into “\&\& exit”.
    – halloleo
    Feb 23 at 14:08
  • run it in the background nohup <cmd> &
    – mmmmmm
    Feb 23 at 14:28

1 Answer 1

2

The solution is mentioned in the example section of ttab's man page. Use exec as first argument to ttab. E.g.

ttab exec cp -r <large-dir> <backup-location>

or

ttab exec top

You must log in to answer this question.

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