Skip to content

Instantly share code, notes, and snippets.

@mbierman
Created August 2, 2012 00:57

Revisions

  1. mbierman renamed this gist Aug 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. mbierman renamed this gist Aug 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. mbierman renamed this gist Aug 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. mbierman renamed this gist Aug 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. mbierman renamed this gist Aug 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. mbierman revised this gist Aug 13, 2012. No changes.
  7. mbierman revised this gist Aug 13, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions preview in Chrome.scpt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    -- Based on Sam Dutton's script (http://goo.gl/27XlZ)
    -- which was based on Mike Piontek's script (http://goo.gl/SBkkL)
    -- This is Chrome specific. See https://gist.github.com/3232318 for a Safari Script

    tell application "TextWrangler" to set theFile to file of document 1
    tell application "TextWrangler" to save document 1
  8. mbierman revised this gist Aug 2, 2012. No changes.
  9. mbierman revised this gist Aug 2, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions preview in Chrome.scpt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    -- Based on Sam Dutton's http://goo.gl/27XlZ script
    -- which was based on Mike Piontek's script http://goo.gl/SBkkL
    -- Based on Sam Dutton's script (http://goo.gl/27XlZ)
    -- which was based on Mike Piontek's script (http://goo.gl/SBkkL)

    tell application "TextWrangler" to set theFile to file of document 1
    tell application "TextWrangler" to save document 1
  10. mbierman revised this gist Aug 2, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion preview in Chrome.scpt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    -- Based on Sum Dutton's http://goo.gl/27XlZ script
    -- Based on Sam Dutton's http://goo.gl/27XlZ script
    -- which was based on Mike Piontek's script http://goo.gl/SBkkL

    tell application "TextWrangler" to set theFile to file of document 1
  11. mbierman revised this gist Aug 2, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion preview in Chrome.scpt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    -- Based on Sum Dutton's http://goo.gl/27XlZ script which was based on Mike Piontek's script http://goo.gl/SBkkL
    -- Based on Sum Dutton's http://goo.gl/27XlZ script
    -- which was based on Mike Piontek's script http://goo.gl/SBkkL

    tell application "TextWrangler" to set theFile to file of document 1
    tell application "TextWrangler" to save document 1
  12. mbierman revised this gist Aug 2, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions preview in Chrome.scpt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    -- Based on Sum Dutton's http://goo.gl/27XlZ script which was based on Mike Piontek's script http://goo.gl/SBkkL

    tell application "TextWrangler" to set theFile to file of document 1
    tell application "TextWrangler" to save document 1

  13. mbierman renamed this gist Aug 2, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  14. mbierman revised this gist Aug 2, 2012. No changes.
  15. mbierman created this gist Aug 2, 2012.
    20 changes: 20 additions & 0 deletions Preview in Google Chrome
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    tell application "TextWrangler" to set theFile to file of document 1
    tell application "TextWrangler" to save document 1

    set appleScriptPath to theFile as text
    set currentURL to POSIX path of appleScriptPath
    set currentURL1 to POSIX path of appleScriptPath
    set currentURL to ("file://" & currentURL)

    -- this script will get the <title> tag from the web page for comparison below.
    set theTitle to do shell script "grep -i '<title>' " & currentURL1 & "| sed -e 's#<[^>]*>##g' | sed 's/^[ ]*//;s/[ ]*$//'"

    tell application "Google Chrome"
    activate
    -- using the <title> tag above, we compare to the current open tab. If they are equal, replace the contents, otherwise, open a new tab.
    if (exists window 1) and (title of active tab of window 1 is theTitle) then
    tell window 1 to set URL of active tab to currentURL
    else
    open location currentURL
    end if
    end tell