Open a New iTerm Window in My Current Desktop Space

Hello,

I have a shortcut to activate iTerm. If there is an open iTerm window somewhere, it takes me there. However, what I'm trying to do is open a new iTerm window in whichever desktop/space I'm currently at, not just activate an existing iTerm window. I am also assuming that if iTerm isn't open at all, this action will do it. Any help is greatly appreciated by this KM newbie!

Thanks!

Hi @shuss and welcome to the forums.

I don't use spaces, but I do use iTerm, so I looked through its preferences and saw this:

The default is "Current Space" but I wondered if "All Spaces" might work for what you wanted to do.

1 Like

Thanks, @tjluoma!

This option seems to open a window that "follows" me to whichever workspace I switch to! It's hard to imagine why this feature might be useful, but I think this defeats the whole purpose of desktop spaces :slight_smile:

I suspect this problem might require some Apple Script jujitsu to solve, of which I have no mastery.

Cheers!

If you don't get an answer here, I would suggest asking on iTerm’s mailing list which has a lot of good folks on it, including the developer.

That sure sounds like excellent advice, @tjluoma! Thanks for taking the time to help me out.

Cheers!

Hi @shuss.

I don't have a quick answer, but I might have something related.

I was having the same kind of problem with Chrome where when I clicked on a *.webloc file , it would open a new tab in whatever my most recent Chrome window was, no matter what desktop that window might be in. That would usually bounce me over to a different working project with annoying results. I did succeed in setting up a keyboard shortcut that, when pressed on a selected *.webloc file, opens that URL in a new Chrome window in the current desktop. Much more like I want. And it sounds like what you want with iTerm.

It's late and I'm off to bed, but if you're still interested in the problem a year later, let me know and I'll dig up how I did it. That solution might help your problem.

Or it might use a command line option to Chrome that forces a new window and so it doesn't really apply to iTerm unless iTerm has a similar command line option.

Or something else. I just don't remember now so I'll look for it later. Let me know if you ever solved your problem.

August

P.S. UPDATE: Here's the thread that helped me do it to open a new Chrome window from an OSX webloc file:
"Is it possible to force a Mac *.webloc file to open in a new Chrome window instead of a new tab in an existing window?"
Maybe that will give you a hint on your problem.

1 Like

Hey @shuss,

Give this a try.

-Chris

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/01/09 13:59
# dMod: 2021/01/09 13:59 
# Appl: iTerm
# aVer: 3.3.0beta16
# Task: Open a New Window Terminal Session in the Current Space.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @iTerm, @Open, @New, @Terminal, @Session, @Current, @Space
--------------------------------------------------------

tell application "iTerm"
   set newSession to create window with default profile
end tell

--------------------------------------------------------
2 Likes

Thank you @ccstone! This works well :slight_smile:

1 Like