A BBEdit package to help with scripting.
I hope to add a fair amount to this. As I use scripts, clippings, text filters and find them worthy I’ll move them into this project.
- rake package:install Installs Scripts, Text Filters, Clippings, and Resources for Scripting Tricks.
- rake package:remove Deletes Installed Package.
- rake stationery:install Installs stationery files into BBEdits Stationery folder.
- rake stationery:remove Deletes installed stationery files.
The best way to install this package is to download/clone it where you might keep projects and install it with the commands above.
You can however download and install it by copying or moving the files manually.
- Align Assignments This is a text filter that will align a list of assignments to their operators.
So it takes this mad woman's breakfast:
var magic-johnson = "Number one choice"
var oscar-robertson = "Number two choice"
var i-thomas = "Number three choice"
Then makes:
var magic-johnson = "Number one choice"
var oscar-robertson = "Number two choice"
var i-thomas = "Number three choice"
What it will align:
extern float var_name = 4.2;
static string var_name = "I don't move";
const int var_name = 299792458; // meters a second
These also (works with a bunch of operators):
name = "Livingston"
@this = "that"
$way = "way back"
Const = "antly"
_valuable = "name"
foo := "bar"
this |= "that"
cat ||= "what ever I first observed"
This as well:
var jack = "jumped"
let jill = "go to college out of state"
var jason:Killer = "overrated eighties villain"
let old:Int = 42
this::That = "dig deep!"
Processes assignments in groups and respects indention
fun withIndented ( stuff, as, well ) {
red = "#FF0000"
orange = "#FF3300"
blue = "#175987"
}
outside = "cold"
inside = "warm"
florida = "crazy town"
$one = "lonely"
two = "not so much"
self-quarantined = "I love books"
What it won't:
var b, c int = 1, 2
var c, d string = "s", "x"
let (firstNumber, secondNumber) = (10, 42)
Note: You can use the Setup palette to enable or disable clipping groups per language. You can find it under the menu BBEdit > Setup.
-
Ruby Clippings A set of simplified clippings for ruby.
-
Scripting Clippings to help with scripting in general.
-
shebang
#!/usr/bin/env < interpreter >
This works with a script in the Resources folder to try and guess the right interpreter. It’s default (or fallback) is the documents language. -
BB*_ All of the BBEdit environmental variables wrapped in a single quote string.
-
-
Applescript Clippings A little help with AppleScript App. AppleScript, well, it’s better than JXA.
-
path_to & path_to_bbedit This will help in dealing with paths. You can convert then to Classic Mac/Finder paths with
<path> as alias
or convert them to Unix style paths withPOSIX path <var for path>
.-
path_to
set #INSERTION#_path to ((path to <#?home folder | application support folder | application app#> from user domain) as text) <#? as alias #>
-
path_to_bbedit
set #SELSTART#bbedit_folder#SELEND# to ((path to application support folder from user domain) as text) & "BBEdit" <#? as alias #>
-
-
-
WorkSheet Clippings are to be used with Shell/Unix Worksheets. They expand out to useful shell commands.
-
man_bb
man < cmd > | col -b | bbedit --view-top -m "UNIX man page"
Executing this will open a Unix man page in a separate BBEdit window with the language set to UNIX man page.
My normal color scheme is a dark blue, I have the the Unix Man page language (doc type) set to the standard black and white. If I were really hip it would be yellow with black text. I think a lot of folks would like this as addition to their .bashrc, I added it as a function to Fishshell. -
cd_pwd
cd < '/Users/chris/' >; PWD
cd '/projects/root/dir/'; PWD
cd < You might want to save. >; PWD
This one finds your working directory and uses it as the input for thecd
command, followed byPWD
to display the directory.- If your using BBEdits persistent Unix Worksheet
PWD
will be the current working directory. The default is your home directory. The path toPDW
will be selected so it can be changed easily. - If your working in a BBEdit project the
PWD
is the projects root directory. - If you are using a good ol' Shell Worksheet it's parent directory is the PWD. If the Worksheet isn’t saved it will remind you to save and let you type something in.
- If your using BBEdits persistent Unix Worksheet
-
- List BBEdit Env Variables Opens a document with the BBEdit environmental variables listed with their current values.
-
Text Filter.rb is a starting point to write a text filter in ruby. Text filters the selection ( if present ) or the entire file as input.
-
Menu AppleScript is a starting point to write a Menu Script for BBedit. These are scripts that let you prepend, highjack, and/or append to a BBEdit native menu command.
-
Launchd Definition ... to make a definition for the launchd demon/agent launcher in macOS ( and sometimes Linux ).