consular icon indicating copy to clipboard operation
consular copied to clipboard

[Terminal.app] A new window initialized with some tabs always has an empty tab

Open mcmire opened this issue 13 years ago • 7 comments

In other words, if you have a file like

window do
  tab "foo"
end

then tab 1 will be empty and tab 2 will contain the "foo" command. This is probably just because as soon as you create a window in Terminal.app, you always get one tab to start out with.

So it would be nice if terminitor just switched to the first tab and removed it (if there is a way to do this). It's not a huge deal, except I have to do it every time :/

mcmire avatar Jun 18 '11 00:06 mcmire

Read my mind, I would like this feature as well.

jch avatar Jun 22 '11 22:06 jch

You can work around this by running a command in the window outside of the tab... therefore if you have 2 tabs, only declare 1 tab and then put a command right in the window...

window do
  tab do
    run 'bundle exec spork'
  end

  run 'bundle exec guard'
end

And I'm not entirely sure this is a "work around" it just seems to make sense that terminitor would operate this way.

cfeduke avatar Jun 23 '11 05:06 cfeduke

Can I programmatically close the original separate window then? The point is to only have the tabs I defined and no extra launch window or tab.

On Jun 22, 2011, at 10:08 PM, [email protected] wrote:

You can work around this by running a command in the window outside of the tab... therefore if you have 2 tabs, only declare 1 tab and then put a command right in the window...

window do
 tab do
   run 'bundle exec spork'
 end

 run 'bundle exec guard'
end

And I'm not entirely sure this is a "work around" it just seems to make sense that terminitor would operate this way.

Reply to this email directly or view it on GitHub: https://github.com/achiu/terminitor/issues/79#issuecomment-1423087

jch avatar Jun 23 '11 17:06 jch

one way to avoid having that extra tab is to use the run command instead:

run 'irb'      # current(first) tab
tab 'ruby -v'  # second tab
tab 'whatever' # third tab

As @cfeduke mentioned, that applies to a new window context as well if you want to have the current tab of the new window to spawn the commands.

achiurizo avatar Jun 23 '11 17:06 achiurizo

I'm assuming you mean since you launch terminitor from an actual terminal and it creates new windows that you'd like either the original window re-used (not sitting behind the terminitor created windows) or as you said automatically closed. This was irking me as well. I haven't looked too closely at the source to see if there's anyway to bind the first window to the parent term but I got around this by making a custom Alfred alias that executes the following command:

cd ~/Projects/tabletop_calculator ; terminitor start ; exit

Its important to also make sure your Terminal preferences under Shell you've selected the value "Close the shell if exited cleanly" for the "When the shell exits" option.

If you aren't using Alfred and you just want to make the launching Terminal close you can make a script - in my case this is ~/ttc - and chmod +o ~/ttc:

#!/usr/bin/env bash
cd ~/Projects/tabletop_calculator
terminitor start
kill -9 $PPID

This took a bit to figure out since exit within a script is actually implied, you need to cause the parent process ID to terminate

cfeduke avatar Jun 23 '11 18:06 cfeduke

@cfeduke: Closing the terminal that launches the terminitor command is not quite what I'm talking about -- it can be annoying, but it isn't surprising, because after all, you're opening a new window (which I always prefer, in case I'm launching the terminitor command from a window that already has tabs and I don't want to pollute it with more). I just mean if your termfile opens a new window, it's always initialized with a tab, so if you create multiple tabs within the window, you always end up with a blank initial tab. Which is surprising (from a termfile point of view).

@achiu: That works, but what if you want to give the first tab a name?

mcmire avatar Jun 24 '11 01:06 mcmire