Friday, July 20, 2018
  • Index
  •  » Code Exchange
  •  » How to make html files open in TextWrangler from your browser

#1 2015-01-14 02:59:49 pm

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

How to make html files open in TextWrangler from your browser

Hello.

Occassionally, it is convenient to be able to edit html pages that are on disk. I was looking for a way to this, and I found the way in Google Groups for TextWrangler.

The thing is, is that TextWranglers, or BBEdits uri handler, only brings the respective app to front, but, if you use Text Mate's protocol, then it works. You may want to use RCDefault app, to set up the default receipient of the protocol, if you have several apps installed, since the txtmt protocol will work with the latest app of TextWrangler, BBEdit and TextMate.

I have used ~/.bashrc as the file to open in the demo below, but it should really work with any text file, provided it exists of course! By the way: During the process of making this to work, i found out that the webpagehelper app over at MacOsXAutomation still works under Mavericks. I thought it didn't, probably because I didn't respect the format of the protocol for the URI's, namely following the structure of the passing of the file as seen below.

<!DOCTYPE html>
<html lang="en">
    <body>
        <a href="txmt://open/?url=file:/Users/me/.bashrc">Edit bashrc</a>
    </body>
</html>

Last edited by McUsrII (2015-01-14 03:02:07 pm)


Filed under: HTML, edit, Link, Uri

Offline

 

#2 2015-01-27 10:15:07 am

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Re: How to make html files open in TextWrangler from your browser

Hello.

Here is a bookmark that lets you open a file url from 'Safari into TextWrangler. The full path of a file must not contain any spaces, or it won't work, whether any spaces are real spaces, or encoded as %20.

You must first make a new dummy bookmark on your favourite bar, and then paste the snippet below in as its address, and then rename it to TW or simiiar. -You get to the bookmars by choosing Edit Bookmarks on the Bookmarks menu, and the choices for editing is on the contextual menu.

NB!

If you have installed TextMate, or BBEdit after TextWrangler, then the file will open in the last installed, (they share the same protocol). You can always adjust what app to open the protocol with (among those 3), by using RCDefaults.app.

javascript:(function(){var%20pgsrc;try{pgsrc=window.frames[0].location.toString();}catch(err){pgsrc=window.location.href.toString();}var%20file_loc=pgsrc.indexOf('file://');if(file_loc==0){var%20segm_loc=pgsrc.indexOf('#');if(segm_loc>0){var%20tmpS=pgsrc.substr(0,segm_loc);pgsrc=tmpS;}var%20twCmd="txmt://open/?url="+pgsrc;window.open(twCmd,"_self");}})();


Filed under: textwrangler

Offline

 
  • Index
  •  » Code Exchange
  •  » How to make html files open in TextWrangler from your browser

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)