Skip to content

Instantly share code, notes, and snippets.

@mixio
mixio / adapt_tab_width_to_bbedit_csv_tsv_contents.applescript
Created June 10, 2021 10:38
BBEdit script to set the tab width of a CSV or TSV document to the size of the longest field in order to view data "in aligned columns"
# This script will use the `xsv` command line tool:
# <https://github.com/BurntSushi/xsv>
# to compute the max length of all cells of columns from 1 to n - 1 of
# the front document of BBEdit if it is a CSV of TSV file with
# respective extensions of '.csv' and '.tsv'.
# It will then set the tab width of the document to this max length,
# allowing the user to view the data in aligned columns.
# For that purpose, in CSV files a tab will be inserted
# after each comma separator when required.
tell application "BBEdit"
@mixio
mixio / open_bbedit_selection_with_terminal.applescript
Last active March 14, 2021 17:12
AppleScript for BBEdit that tries to use the selected text as a path or paths to files to open with the help of the terminal. This script should be compiled as an .scpt script before use.
# Author: Jean Jourdain
# © 2021, mixio.com
# License: MIT
--
use AppleScript version "2.7"
use scripting additions
use framework "Foundation"
--
property NSString : class "NSString"
property NSCharacterSet : class "NSCharacterSet"
@mixio
mixio / entities_canonize_diacritics.txt
Created February 25, 2021 19:14
file used to convert diacritic characters to html entities with the canonize utility of BBEdit
# -*- x-bbedit-canon-case-sensitive: 1; x-bbedit-canon-match-words: 0; x-bbedit-canon-grep: 1; -*-
À \&Agrave;
Á \&Aacute;
 \&Acirc;
à \&Atilde;
Ä \&Auml;
Å \&Aring;
Æ \&AElig;
Ç \&Ccedil;
È \&Egrave;
@mixio
mixio / run_jq.applescript
Last active February 1, 2020 08:33
Applescript for json transform with jq in BBEdit
--
on escape_new_lines(aText)
set vDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"\\n", "\\r"}
set vParts to (text items of aText)
set AppleScript's text item delimiters to {"\\\\n"}
set vResult to (items of vParts) as string
set AppleScript's text item delimiters to vDelims
return vResult
end escape_new_lines
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
<key>BBLMColorsSyntax</key> <true/>
<key>BBLMIsCaseSensitive</key> <false/>
<key>BBLMLanguageCode</key>
<string>Ldgr</string>