How To Make CMD-T in Safari Open a Tab Next to Current Tab

Default for Safari is new tab always opens way out at the end, which to this user is an illogical default.

Anyway...

The KBM CEO says possibly an AppleScript to the rescue?

Anyone got a suggestion for that - or another approach?

Hey @bhelmick,

Welcome to the forum!Ā  :sunglasses:

This seems to work pretty reliably with Safari on macOS 10.14.6 Mojave.

I'm not sure if it has any relationship to the tab settings, but here are mine just in case.

Open a New Tab Next to the Current Tab v1.00.kmmacros (5.8 KB)
Keyboard Maestro Export

-Chris

OK Chris, thanks,

I tried giving it a go.

However, youā€™ve got a very very barely capable programmer here, although I did drop in an AppleScript one time and got that to work.

Here is the script you supplied - believe Iā€™ve got it correctly

(() => {

   // Change to a URL if desired.
   const newDocURL = ā€˜about:blankā€™;

   const openTab = window.open(ā€˜ā€™,ā€™_blankā€™);
   openTab.location = newDocURL;

})();

So a couple of questions:

  1. So I donā€™t even know what kind of script that is - AppleScript?

  2. Assuming it was, the image below shows how I tried to set it up. It didnā€™t work but then Iā€™ve got Ventura here so maybe that is the issue? FYI when you do up to Ventura, there are other issues. I couldnā€™t even get plain old Ctrl T to execute a Cmd T. Then Peter Lewis guessed correctly it was because Apple moved the location of Safari in Ventura so I had to set up a new macro group and link it to the new Safari. The old Safari icon also shows up, so I just selected both to make sure I got the right one, and it worked. But getting the tab to open next to the current one may ba a leap too far.

I also tried Swift script, and a couple of the other JavaScripts. With Swift Script it said I had to first supply the Swift tools from the command line

So what says Chris the Wizard! And with a guy with your expertise, why arenā€™t you up on Ventura!!

Brooks

Which of those is the type of script you used here

  1. When you click on anyone of the above, if Iā€™m interpreting it right, there is some upfront script that

Hey Brooks,

I gave you a downloadable macro. You didn't download and install it?

Download it and double-click to install ā€“ then make sure both the macro and the group it's installed into are enabled. (You may need to move it into your own Safari Group.)

Make sure Safari's Develop Menu is enabled:

Turn ON ā€œEnable JavaScript from Apple Eventsā€.

image

I'm living with a 2012 MacBook Air at the moment, and it doesn't support Ventura.

I really need to upgrade my hardware, but unfortunately my wallet has been saying no for a while.

Near death experience and hospitalization in 2020 hasn't helped on that front.

-Chris

Hi Christopher

Ah! Very slick.

No I hadnā€™t downloaded and clicked, but now have done - and put into both my old and new Safari Group, but alas, pressing \F1 didnā€™t do it.

See image for how it looks on screen.

Brooks

New tab locations are a hidden preference that can apparently only be changed through a Debug menu that itself can only be enabled through a defaults command in the shell. See this Six Colors post for details and instructions:

1 Like

That's Option-F1. Is that what you tried?

Did you turn ON ā€œEnable JavaScript from Apple Eventsā€? JavaScript cannot be run from AppleScript in Safari without that being on.

Another way to customize the placement of new tabs is to

  1. Enable Safari debug menu.
  2. Select Debug > Tab Ordering > Position of New Tabs > $OPTION

Christopher et al

I missed turning on Allow JavaScript for Apple Events
Now it works
Youā€™re the man

Thanks to all

Brooks

1 Like