Focus on last tab in Safari

How to focus on last tab in Safari?

There is a hotkey combination for Chrome cmd + 9.
Looks like that apple missed this function.

It is possible to do it with KM?

Thanks in advance.

sVim has this action.

"g $" by default.

1 Like

Much appreciated!

Just installed it but not sure how to use the extension, “g $” - what does it mean? How can i set a hotkey for this action?

Thank you in advance.

The extension gives you vim mode in the browser.

Search a bit about vim and normal and insert mode that it has. When you install the extension and open any page, when you insert g followed by $ sign, it will go to the most right tab as you want it.

I binded this action to another key though, shift + s and I have shift + a go to leftmost tab. Here are my settings.

Take a look at the README of that extension, it has everything you need there.

1 Like

Thanks a lot for your help, it worked!

Use Select Safari Tab and SAFARITABCOUNT function.


The above solutions are great—the one by Peter has got me thinking. :slight_smile:

If you want to do a lot with Safari tabs, you may want to take a look at Canisbos’ Tab Options.

Already using it, it’s a great extension.

@peternlewis — are there options in Keyboard Maestro to move Safari tabs to the left or right, or to move them to the far right end or the far left end of the tab bar? If not, I’d love to see them added in a future update.

Nope. It might be possible to do in AppleScript (which would be what the actions would use anyway). Probably I wouldn’t implement such actions, they are a bit too specific, but hopefully it can be done in AppleScript (if it can’t, then I wouldn’t be able to implement it anyway).

Thanks Peter.

I took a look at the code in the Canisbos’ Tab Options extension, and it appears to be JavaScript.

Unfortunately, it uses a lot of variables and the function is related to the hotkeys set by the extension.

I’m lost when I look at this (does anyone here know how to adjust this code to work in a Keyboard Maestro macro?):

function handleHotkey(match, toolbarVisible, srcTab) {
	var action = match.action;
	var thisWindow = sa.activeBrowserWindow;
	var thisTab = thisWindow.activeTab;
	var thisTabIndex = thisWindow.tabs.indexOf(thisTab);
	var ntp = (action == 'newBgTab') ? se.settings.newBgTabPosition : se.settings.newFgTabPosition;
	var newTabIndex =
		(ntp == 0) ? thisTabIndex           :
		(ntp == 1) ? thisTabIndex + 1       :
		(ntp == 2) ? thisWindow.tabs.length :
		(ntp == 3) ? 0                      : undefined;
	switch (action) {
		case 'moveTabRightMost':
			thisWindow.insertTab(thisTab, thisWindow.tabs.length);

I think the above contains the code to move a tab to the far right of the tab bar (but I may have missed parts when I tried to locate the pertinent code).

Safari 11.1 released today adds Command-9 as a shortcut to go to the right-most tab.