Skip to content

Instantly share code, notes, and snippets.

@bagonyi
Last active May 23, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagonyi/57a414831f190905c671 to your computer and use it in GitHub Desktop.
Save bagonyi/57a414831f190905c671 to your computer and use it in GitHub Desktop.
TotalSpaces2 - Change name of current space

This setup will let you change the name of the current space by using a keyboard shortcut.

Requirements:
  1. Registered version of TotalSpaces2
  2. CocoaDialog
  3. totalspaces2 ruby gem
  4. BetterTouchTool
Installation:
  1. Install and register a copy of TotalSpaces2
  2. Download and install CocoaDialog from http://mstratman.github.io/cocoadialog/
  3. Install totalspaces2 ruby gem by entering the following to the Terminal: sudo gem install totalspaces2
  4. Install BetterTouchTool (or other alternative that you can configure to run commands using keyboard shortcuts).
  5. Download change-space-name.rb from this gist and place it in your ~/bin directory.
  6. Make the change-space-name.rb script executable by running chmod +x ~/bin/change-space-name.rb in the Terminal.
  7. Edit ~/bin/change-space-name.rb and change line 5 to point to your installed CocoaDialog path_to_cocoa_dialog = "/Volumes/Macintosh SSD/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog"
  8. Open up BetterTouchTool Preferences, select Keyboard settings, select Global application and click Add New Shortcut. Define a keyboard shortcut (I use Ctrl+Option+Command+R) and change Predefined Action to "Execute Terminal Command". In the popup dialog enter ~/bin/change-space-name.rb
Usage:

Hit your predefined keyboard shortcut and enter the desired name for the current space. Profit!

Pro tip:

By using HyperSwitch (https://bahoom.com/hyperswitch) you can limit cmd + tab to list only those windows that are present on the current space.

#!/usr/bin/env ruby
require 'totalspaces2'
path_to_cocoa_dialog = "/Volumes/Macintosh SSD/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog"
response = `"#{path_to_cocoa_dialog}" standard-inputbox --title "Change name for current space" --informative-text "Name for space #{TotalSpaces2.current_space}" --text "#{TotalSpaces2.name_for_space(TotalSpaces2.current_space)}"`
response = response.split("\n")
if response[0] == '2'
puts "Clicked cancel. Exiting."
exit
end
if response.length < 2
puts "Did not provide name. Exiting."
exit
end
name = response[1]
puts "Changing space name to " + name
TotalSpaces2.set_name_for_space(TotalSpaces2.current_space, name)
@bagonyi
Copy link
Author

bagonyi commented Aug 10, 2015

screen shot 2015-08-11 at 00 31 54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment