I am on Big Sur. My workflow involves like 10 static spaces that I access with CMD+NUM key shortcuts (not CTRL-NUM you can turn on in Sys Pref's Keyboard Shortcut section). Often I am just switching back and forth between two spaces, and would like to be able to toggle between the previous two spaces.

In Snow Leopard there was a 'double-tab-jump-back' key you could turn on with a 'defaults' terminal command (https://www.cultofmac.com/133205/use-a-secret-gesture-to-switch-to-the-previous-space-os-x-tips/). This is gone now:

$ defaults find double-tap-jump-back 
2021-08-05 10:35:11.617 defaults[5047:253260] No domain, key, nor value containing 'double-tap-jump-back'

Ideally, I would bind CMD+` (I never use it to switch between app windows) to function exactly like CMD+TAB's app switcher but it would be for spaces. This will almost certainly never happen.

So instead I'd just like to figure out a way to switch to the previous space. This would probably involve multiple small applescripts. The main script would save the current space before jumping to the previous one upon a CMD+` keypress. Then I would need 10 other scripts that save the current space before jumping using my CMD+NUM shortcuts. If I switched between spaces using trackpad gestures, then the previous space would not be kept current, but I don't use the trackpad often enough for this corner case to be addressed.

Unfortunately I am just returning to MacOS from a GNOME-based linux desktop and am not very familiar with applescript. Could someone help me draft a template main applescript and then a template for my CMD+NUM applescripts? I imagine this is the only way to accomplish this :)

Additional info:

I have a American English ANSI keyboard on m1 macbook air. I only use the single, built-in monitor and keyboard on this device. I never use full screen apps in their own spaces because I can't switch to them directly. Here are my settings (I don't change keybinds in System Preferences and instead use BetterTouchTool to bind the "Switch to Desktop X" and "Move Window to Desktop X" functions):

enter image description here enter image description here enter image description here

  • Spaces changed dramatically at Lion & really was never as good since. There's no way to get back those long-gone moves, I'm afraid. Spaces/Mission Control never did get an Applescript Dictionary & has been pretty intransigent ever since. We have one user on here who is a bit of a whiz on Applescript, though, so I'm not going to put this in as an answer.
    – Tetsujin
    Aug 5, 2021 at 15:23
  • Hmm… a late thought. You could maybe just do the opposite of this - apple.stackexchange.com/questions/214348/… A truly horrible HUI function to my mind, but it might help a bit in this instance. You'd then just need [by default] Ctrl/ left or right arrow.
    – Tetsujin
    Aug 5, 2021 at 16:20
  • There is a bit of missing information in this question, i.e, explicit settings in System Preferences > Mission Control and System Preferences > Keyboard > Shortcuts > Mission Control. Screenshots of each would be nice. Do you run any applications in Full Screen View that creates its own Desktop/Space that is not a part of the 10 already defined? Is this a single-display or a multiple-display environment? Type of Mac and keyboard? Language & Region settings? Without a solid overview of these settings I would not even attempt to offer an explicit answer. Aug 5, 2021 at 16:33
  • That said, basic vanilla AppleScript, by itself without shelling out (using the do shell script command), does not have the vocabulary to accomplish the goal as Apple has not provided a Spaces API for AppleScript to access directly. There is a possibility using Hammerspoon with asm.undocumented.spaces, along with some AppleScript and or shell script to accomplish the goal. If you provide the missing info mentioned in my first comment I give this some serious thought. Aug 5, 2021 at 16:33
  • 1
    @Tetsujin Ah I never considered allowing spaces to still reorder themselves by recency! It would be a very clean solution indeed. But I probably want to keep the mental organization and the quick nav that a 10 static Spaces approach provides.
    – courtyardz
    Aug 6, 2021 at 14:43


You must log in to answer this question.

Browse other questions tagged .