3

Is there a Safari keyboard shortcut to move a tab?

If not, how can I make one?

I wouldn't even know how to write an AppleScript for this, the only method I see of moving tabs is to drag them.

1 Answer 1

3

Here are two AppleScripts for moving tabs one position right or left. The AppleScript gets the current tab index, checks if it can be moved, then moves it and ensures it's still active. This does refresh the page though but this appears to be a limitation of the AppleScript since it uses the Standard Suite's move.

  • Move tab one to the right

    tell application "Safari" to tell front window
        set currentindex to index of current tab
        if currentindex is equal to number of tabs then return
        move tab currentindex to after tab (currentindex + 1)
        set current tab to tab (currentindex + 1)
    end tell
    
  • Move tab one to the left

    tell application "Safari Technology Preview" to tell front window
        set currentindex to index of current tab
        if currentindex is 1 then return
        move tab currentindex to before tab (currentindex - 1)
        set current tab to tab (currentindex - 1)
    end tell
    

You can assign keyboard shortcuts to these by creating a service to run these scripts and assigning a shortcut to the service, or with a third-party app.

4
  • Pretty good, but as you say it refresh the page. Nice trick though!
    – mjs
    Commented Jan 23, 2019 at 7:23
  • do you think that this might be possible to do generically, not only for safari? Like tell front application, rather than tell Safari ... thanks!
    – mjs
    Commented Jan 23, 2019 at 7:25
  • Also, would be good with a module total windows, that would move it to first if at last and last if at first and moved left.
    – mjs
    Commented Jan 23, 2019 at 7:28
  • I am working on it, but I have never played with applescripts :S
    – mjs
    Commented Jan 23, 2019 at 7:28

You must log in to answer this question.