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.10.2
ST 3 (3065)
handycam
 
Posts: 276
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: 3199
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.10.2
ST 3 (3065)
handycam
 
Posts: 276
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.10.2
ST 3 (3065)
handycam
 
Posts: 276
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: 1064
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.10.2
ST 3 (3065)
handycam
 
Posts: 276
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

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

Postby gunmetalgrey on Thu Feb 26, 2015 7:44 pm

Sorry to revive this old post but is there anyway to do this for Sublime 3? I've tried to run the command sublime.set_clipboard(view.syntax_name(view.sel()[0].b)) in the console, but am getting the error.

Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'View' object has no attribute 'syntax_name'

what am I missing?!?..
gunmetalgrey
 
Posts: 2
Joined: Thu Feb 26, 2015 7:38 pm

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

Postby FichteFoll on Thu Feb 26, 2015 8:07 pm

The method is now called "scope_name".
FichteFoll
 
Posts: 620
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

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

Postby gunmetalgrey on Thu Feb 26, 2015 8:15 pm

Thank you so much!
gunmetalgrey
 
Posts: 2
Joined: Thu Feb 26, 2015 7:38 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests