• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Inserting a Custom Header in BBEdit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inserting a Custom Header in BBEdit


  • Subject: Inserting a Custom Header in BBEdit
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 10 May 2017 09:44:12 -0500

Hey Folks,

I've had a considerably more sophisticated script for constructing my AppleScript headers for many years, but I've never written one for the shell scripts I write in BBEdit.

That means a lot of things don't get documented as well as they should be – and that means I frequently can't find them very easily when I want to.

This morning I decided I'd fix that and write a custom-header-constructor for BBEdit.

I'll probably customize it more after I use it for a while, but here are the bones:

------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2010/10/11 21:32
# dMod: 2017/05/10 09:29
# Appl: BBEdit
# Task: Insert info header into the front document.
# Libs: None
# Osax: Satimage.osax
# Tags: @Applescript, @Script, @Satimage.osax, @BBEdit, @Insert, @Attribution, @Info, @Header
------------------------------------------------------------------------------

set dateTime to do shell script "date '+%Y/%m/%d %R'"
set headerTextTemplate to text 2 thru -1 of "
# Auth: Christopher Stone
# dCre: " & dateTime & "
# dMod: " & dateTime & " 
# Task: 
# Tags: @Shell, @Script
"

tell application "BBEdit"
    tell front text document

        

        if contents of line 1 starts with "#!" then -- Shebang line
            set start_Line to line 2
        else
            set start_Line to line 1
        end if

        

        set before start_Line to headerTextTemplate
        set findRec to find "^# Task: " options {search mode:grep, case sensitive:false, starting at top:true}
        select insertion point after found object of findRec

        

    end tell

    

end tell

------------------------------------------------------------------------------

NOTE — in the script on my system I use the Satimage.osax for the `date` function.

------------------------------------------------------------------------------
set dateTime to strftime (current date) into "%Y/%m/%d %R" -- Satimage Osax
------------------------------------------------------------------------------

Enjoy.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Inserting a Custom Header in BBEdit
      • From: debt <email@hidden>
  • Prev by Date: Re: sub-routines' error
  • Next by Date: Making a Folder with Test Files
  • Previous by thread: Re: sub-routines' error
  • Next by thread: Re: Inserting a Custom Header in BBEdit
  • Index(es):
    • Date
    • Thread