Home Download Buy Blog Forum Support

Browser Preview

Browser Preview

Postby burn4ever on Thu Feb 09, 2012 4:13 pm

Hey,
is it possible to preview/open my html/css code from Sublime with an shortcut in a Browser?
burn4ever
 
Posts: 7
Joined: Thu Feb 09, 2012 4:05 pm

Re: Browser Preview

Postby agibsonsw on Thu Feb 09, 2012 5:56 pm

If you choose the Tools menu, Build System, New Build System and create this:

Code: Select all
{
   "cmd": ["C:\\Users\\Andrew\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe", "$file"]
}


Save this file using the extension 'sublime-build' in your User folder. This opens the displayed page in whichever browser you identify. ($file means the current file.)

Then you can run it by choosing Tools, Build System 'YourNewBuild'. After you've used it once. then pressing Ctrl-B should in future cause it to run your build.

I haven't worked out yet how to assign it to some other shortcut key - perhaps it needs to be converted to a macro or command?

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Browser Preview

Postby handycam on Thu Feb 09, 2012 9:30 pm

Interesting. This seems to work for Mac users:

Code: Select all
{
    "cmd": ["/Applications/Safari.app/Contents/MacOS/Safari", "$file"]
}


Except it opens the Sublime console and displayed this 3 times:

Code: Select all
2012-02-09 16:34:06.860 Safari[64689:707] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.


Edit: the messages only happend the first time, when Safari launched. Can you prevent the console from opening on a build, though?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Browser Preview

Postby rchl on Thu Feb 09, 2012 11:12 pm

Might be better to use "open" command on Mac which should open file in the default browser.
And also add "selector" so that one doesn't have to change to proper build system manually.

Code: Select all
{
    "cmd": ["open", "$file"],
    "selector": "text.html, source.html, text.xml",
}
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

Re: Browser Preview

Postby handycam on Fri Feb 10, 2012 12:57 am

Except open would open it in the default app, which I have set to Sublime. Right?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Browser Preview

Postby burn4ever on Sat Feb 11, 2012 9:40 am

rchl wrote:Might be better to use "open" command on Mac which should open file in the default browser.
And also add "selector" so that one doesn't have to change to proper build system manually.

Code: Select all
{
    "cmd": ["open", "$file"],
    "selector": "text.html, source.html, text.xml",
}


Okay,
but the "open" command only opens the dialog box to open a new document.....in my case ;-)
burn4ever
 
Posts: 7
Joined: Thu Feb 09, 2012 4:05 pm

Re: Browser Preview

Postby burn4ever on Tue Feb 14, 2012 3:52 pm

Soory guys,
but if I´m creating an build-file like this:
Code: Select all
{
   "cmd": ["/Applications/Safari.app", "$file"],
   "selector": "text.html, source.html, text.xml"

}

nothing happend!?
Any hint for me?
burn4ever
 
Posts: 7
Joined: Thu Feb 09, 2012 4:05 pm

Re: Browser Preview

Postby agibsonsw on Tue Feb 14, 2012 6:03 pm

handycam originally suggested this was needed

Code: Select all
"/Applications/Safari.app/Contents/MacOS/Safari"

Not sure if you've tried this already. You also need to then choose this option from Tools/ Build System/ Whatever.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Browser Preview

Postby svenax on Tue Feb 14, 2012 8:27 pm

As for OS X, you really want
Code: Select all
"cmd": ["open", "-a", "Safari", "$file"]

to force Safari to open the file. You can of course substitute Google Chrome or Firefox if you want.
svenax
 
Posts: 155
Joined: Tue Dec 20, 2011 12:47 pm

Re: Browser Preview

Postby ryentzer on Thu Feb 16, 2012 1:18 pm

svenax wrote:As for OS X, you really want
Code: Select all
"cmd": ["open", "-a", "Safari", "$file"]

to force Safari to open the file. You can of course substitute Google Chrome or Firefox if you want.


How do I learn to do this? What I'm referring to is how would someone know to try:
Code: Select all
"cmd": ["open", "-a", "Safari", "$file"]

Is this python code?

Thanks,
Rick
ryentzer
 
Posts: 8
Joined: Wed Aug 03, 2011 1:14 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 18 guests