Probably a bit niche, and I believe that style sheets may feature somewhere on the roadmap of future developments for Bike 2.0, but in the meanwhile, I happen to toggle Bike between two different fonts.
For some reason I like to draft in English in Courier New
(imprint of 1970s typewriters ?),
but in a couple of other languages, and for more formal stages of writing, I prefer the look of the default Apple System font.
To test the following in Script Editor, set the language selector at top left to JavaScript rather than AppleScript
.
Expand disclosure triangle to view JS source
(() => {
"use strict";
// Toggle Bike Font settings.
const baseFont = ".AppleSystemUIFont";
const draftFont = "Courier New";
// main :: IO()
const main = () => {
const
bike = Application("Bike"),
doc = bike.documents.at(0),
font = toggleBikeFontSetting(baseFont)(
draftFont
);
return doc.exists()
? (() => {
const maybeFile = doc.file();
return null !== maybeFile
? (
doc.save(),
doc.close(),
bike.open(maybeFile.toString()),
`Bike window re-opened in "${font}"`
)
: `Reopen to see Bike font toggled to "${font}"`;
})()
: `Bike font toggled to "${font}"`;
};
// toggleBikeFontSetting :: String ->
// String -> IO String
const toggleBikeFontSetting = baseFontName =>
// e.g. ".AppleSystemUIFont", "Courier New"
altFontName => {
const
shellResult = Object.assign(
Application.currentApplication(),
{includeStandardAdditions: true}
)
.doShellScript,
id = "com.hogbaysoftware.Bike",
key = "bike.fontName",
bikeFont = `${id} ${key}`,
newFont = shellResult(
`defaults read ${bikeFont}`
) === baseFontName
? altFontName
: baseFontName;
return shellResult(
[
`defaults write ${bikeFont} "${newFont}"`,
`defaults read ${bikeFont}`
]
.join("\n")
);
};
return main();
})();
See: Using Scripts - Bike
I personally use Keyboard Maestro to attach this kind of thing to a keyboard shortcut, and get a notification of the result:
BIKE - Toggle font setting.kmmacros.zip (13.6 KB)