Skip to content

Instantly share code, notes, and snippets.

@RobTrew
RobTrew / bashSelectByGlobInFinder.sh
Last active April 5, 2021 15:18
Bash command `lf` - like ls but selects glob-matched files in an OS X Finder window
# An lf command in my ~/.bash_profile
# like a simple ls, but selects the glob-matched files in the Finder
# `lf *.txt` to Finder-select all *.txt files in the working directory
# `lf *.[^t]?? to Finder-select all files with a 3-char extension which doesn't start with t
lf() {
local IFS=":"; local f=$@; local seln=""; fldr="$(pwd)"
for l in ${f[@]}; do
if [[ ! -d $l ]]; then
seln=$seln"file \"$l\", "
fi
@RobTrew
RobTrew / bbEditCaseCycle-001.js
Created May 16, 2018 11:40
A BBEDIT version of a Drafts 5 action which toggles the case of selected text
(() => {
'use strict';
/*
A JavaScript for Automation script for BBEDIT
Cycle the case of selected text :: Mixed -> Upper -> Lower -> Mixed
(If the selection is collapsed, the nearest word will be selected)
@RobTrew
RobTrew / dtSheetMMDPrettyPrinted.js
Last active October 3, 2022 18:22
Selected DEVONthink Sheet -> DEVONthink markdown record (pretty-printed MMD table)
((options) => {
'use strict';
// (NB JavaScript for Automation – JXA: Save as .scpt )
// Selected DEVONthink Sheet -> DEVONthink markdown record (MMD table)
// (New record containing MMD table created is same group as selection)
// Uses original fileName stem, with '.md' appended.
// This is the *whitespace pretty-printed* version
@RobTrew
RobTrew / JXA_UIToggle.applescript
Created February 24, 2015 13:06
OS X Yosemite Javascript for Applications (JXA): Toggling background, dark mode, and screen color inversion between day ⇄ night settings
function run() {
// Rob Trew 2015
// Ver 0.01
// UI day/night toggling through OS X 10.10 JXA Javascript for Automation
// SWITCH FROM DAY-TIME DARK MENU BAR AND DOCK WITH DARK BACKGROUND
// TO NIGHT-TIME *ALL DARK*
// (TOGGLE MODE AND BACKGROUND TO BRIGHT, THEN INVERT ALL)
@RobTrew
RobTrew / expand_ft.applescript
Created November 18, 2012 18:57
Expand/Collapse FT to level N, or by N levels
-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
@RobTrew
RobTrew / set_ft_heading_levels.applescript
Created November 18, 2012 18:52
Script which sets the top N levels of a FoldingText outline to Markdown hash headers
-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
@RobTrew
RobTrew / select_ft_theme.applescript
Created November 18, 2012 15:39
Select FoldingText theme, and restart FoldingText
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
-- subject to the following conditions:
@RobTrew
RobTrew / make_or_deepen_header.applescript
Created November 16, 2012 13:11
Mark the selected FoldingText line as a heading (or deepen its heading level) – simple script for keyboard assignment
-- Change first selected node to heading,
-- or deepen level if already heading
-- DEV 1.1 Script
property pstrType : "heading"
on run
tell application "FoldingText"
-- CHECK THAT THERE IS A DOCUMENT
@RobTrew
RobTrew / dtSheetTableMMD.js
Last active October 3, 2022 18:43
Selected DEVONthink Sheet -> DEVONthink markdown record (MMD table)
((options) => {
'use strict';
// (NB JavaScript for Automation – JXA: Save as .scpt )
// Selected DEVONthink Sheet -> DEVONthink markdown record (MMD table)
// (New record containing MMD table created is same group as selection)
// Uses original fileName stem, with '.md' appended.
// Default alignment string is centered ':--:'