Home Download Buy Blog Forum Support

Any way to capture the current theme selector to clipboard?

Any way to capture the current theme selector to clipboard?

Postby handycam on Wed Jan 11, 2012 2:45 pm

I don't know it I'm calling it the right thing: I mean when you are creating a color scheme and hit shift-command-p to get what the current selector is (e.g. "meta.structure.dictionary.json") so you can style it.

It appears briefly in the status bar, but it is sometimes too long to fit, and disappears after a few seconds.

In TextMate, I usually need to take a quick screen capture of the tooltip that appears.

Having it as text, ready to be pasted into a theme file would be perfect.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Any way to capture the current theme selector to clipboard?

Postby jps on Wed Jan 11, 2012 3:01 pm

You can enter this in the console:

Code: Select all
sublime.set_clipboard(view.syntax_name(view.sel()[0].b))
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Any way to capture the current theme selector to clipboard?

Postby handycam on Wed Jan 11, 2012 3:24 pm

jps wrote:You can enter this in the console:

Code: Select all
sublime.set_clipboard(view.syntax_name(view.sel()[0].b))


Great, thanks.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Any way to capture the current theme selector to clipboard?

Postby handycam on Thu Jan 12, 2012 1:43 pm

jps wrote:You can enter this in the console:

Code: Select all
sublime.set_clipboard(view.syntax_name(view.sel()[0].b))


How could I make this into a custom command?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Any way to capture the current theme selector to clipboard?

Postby C0D312 on Thu Jan 12, 2012 1:55 pm

handycam wrote:How could I make this into a custom command?


Tools > New Plugin:
Code: Select all
import sublime, sublime_plugin

class ScopeToClipboardCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      sublime.set_clipboard(self.view.syntax_name(self.view.sel()[0].b))


Preferences > User Keybindings:
Code: Select all
{ "keys": ["shift+alt+command+p"], "command": "scope_to_clipboard"  }
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Any way to capture the current theme selector to clipboard?

Postby handycam on Thu Jan 12, 2012 2:04 pm

Very cool, thanks!
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Any way to capture the current theme selector to clipboard?

Postby Fed03 on Fri Jan 13, 2012 3:26 pm

i love you allllllll
Fed03
 
Posts: 79
Joined: Sun Oct 16, 2011 6:38 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 27 guests