Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any terminal command I can use to switch directly to a space in OS X 10.6 ?

Something like:

spaces switch 2
share|improve this question
up vote 6 down vote accepted

If you have assigned keyboard shortcuts for switching between Spaces in System Preferences, you can trigger them using AppleScript:

osascript -e 'tell application "System Events" to key code 124 using control down'

This will effectively press Control-Right. Left is 123, Up is 126, and Down is 125.

These are the key codes for the number keys:

1 18
2 19
3 20
4 21
5 23
6 22
7 26
8 28
9 25
0 29

Just assign an alias to that osascript call or wrap it in a shell function.

share|improve this answer
Thanks Daniel. I guess you don't know of a way to do it other than the old "have applescript press the keys for me" method then? – cwd Dec 14 '11 at 20:07
@cwd I didn't find anything. Given the UI requirement and the default assignable shortcuts it's likely not supported because it's of limited usefulness. But wait a few days, maybe Lri or slhck or someone else has an idea. – Daniel Beck Dec 14 '11 at 20:30
Thanks, I gave you an upvote. Take a look at this one too when you have a chance: – cwd Dec 15 '11 at 2:08

You must log in to answer this question.

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