Sublime Forum

Add sidebar right click commands ... (LiveReload and SASS)

#1

I want to add some sidebar right click commands that launch CMD and pass it a variable from the selected file name or path. Specifically i want…

  1. A right click on .scss files that launches Ruby in CMD.exe and watches the selected file.
  2. A right click on folders to that launches Ruby in CMD.exe and the selected folder path and runs livereload.

How would I go about doing this?

Here are the commands I’d use for the windows registry to add them to the explorer right click…

  1. cmd.exe /E:ON /K C:\Ruby192\bin\setrbvars.bat && sass --watch “%1”
  2. cmd.exe /E:ON /K C:\Ruby192\bin\setrbvars.bat && pushd %L && livereload

For those who don’t know what livereload and SASS are they’re awesome for web development.

0 Likes

#2

You’ll have to make a plugin to launch cmd.exe. You can take a look at Default/exec.py for an example, but it’s likely doing a lot more work than what you need it to.

To get an entry for the plugin on the sidebar context menu, you can create a Context.sublime-menu file in your package. Take a look at the ‘Diff’ package that ships with Sublime Text 2 for an example of this.

0 Likes