How can I set up keyboard shortcuts to put a tab into a position?

1 for example selects the first tab, can I make a keyboard shortcut like 1 to make my current tab the first tab in the tab bar?


If you are using Chrome, the Rearrange Tabs extension works perfectly.

For Safari, you can setup an Automator service to run this Applescript and bind it to a key combination:

tell application "Safari"
    tell front window
        move current tab to before first tab
        -- for some reason it just creates a new tab with the same URL,
        -- so we need to do this:
        close current tab
        set current tab to tab 1
    end tell
end tell

To set up an Automator service and assign a keyboard shortcut to it:

Edit: On macOS Mojave in Automator, services might be named "Quick Action" or "Contextual Workflow".

  1. Open Automator and choose "New Document"
  2. Select service as the type of document
  3. At the top, set it to "Sevice receives no input in Safari" like this: Service receives no input in Safari
  4. Search for and drag in a "Run Applescript" action
  5. Replace the (* Your script goes here *) text with the code from earlier
  6. Test the script to make sure it works with the Run button
  7. Save the service with whatever name you want
  8. Close Automator and now go to System Preferences > Keyboard > Shortcuts > Services
  9. Find the service that you just created(it should be in the "General" section) and use the "Add Shortcut" button to add a keyboard shortcut for it. enter image description here
  10. Now you should be able to use the keyboard shortcut.

Here's a GIF of it in action: enter image description here

Unfortunately, there is no way to prevent the reloading of the tab when moving it. It is impossible to get the same effect as actually dragging the tab to move it.

  • This makes the tab refresh – theonlygusti Oct 25 '18 at 2:29
  • macOS 10.14, Safari 12.0 – theonlygusti Oct 25 '18 at 2:31
  • How many tabs do you have open and what keyboard shortcut are you using? – abc Oct 25 '18 at 2:31
  • I also can't choose "service" as the document type. I have 4 tabs open, didn't use a keyboard shortcut, just ran it from Script Editor to test. – theonlygusti Oct 25 '18 at 2:33
  • You have to use Automator, not Script Editor. – abc Oct 25 '18 at 2:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .