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
------------------------------------------------------------------------------
Now with one keystroke I get my header and am thereby compelled to add a task
description and tags.
NOTE — in the script on my system I use the Satimage.osax
<http://tinyurl.com/satimage-osaxen> to replace the `date` function.
------------------------------------------------------------------------------
set dateTime to strftime (current date) into "%Y/%m/%d %R" -- Satimage Osax
------------------------------------------------------------------------------
Enjoy.
--
Best Regards,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.