Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Created May 31, 2010 14:56
Show Gist options
  • Select an option

  • Save jacaetevha/419898 to your computer and use it in GitHub Desktop.

Select an option

Save jacaetevha/419898 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Fast User Switching from the command line
# I saved mine as /usr/local/bin/fus
CGSession='/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession'
case "$#" in 0)
# display login screen
exec "$CGSession" -suspend exit ;;
esac
# No reason to display the login panel for the current user
case "$1" in "$USER" | "$UID")
exit 0 ;;
esac
# can pass in a (short) username or userid
id=`/usr/bin/id -u "$1"` || exit
# display login panel for user
exec "$CGSession" -switchToUserID "$id"
do shell script "/usr/local/bin/fus "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment