Monospaced Font in the Text Fields and Text Areas of Actions?

When writing scripts and such, it would be nice to write in a text field that uses a mono spaced font. Is this possible?

1 Like

Hey @fnurl,

Note the preformatted-text (or code) button in the forum editor.

Backticks can be used for inline monospaced font items.

This line is backticked

Triple-backticks may also be used for code-blocks.

set x to "One"
set y to "Two"
set z to "Three"

-Chris

Monospaced would be nice for script actions, too:

printf "Proportional fonts are hard to read: these are 3 different characters: I|l"
3 Likes

There is no current way to do that. Added to the very long todo list.

3 Likes

Hey Tom,

The best way to handle that at present is to use TextEdit as the display mechanism.

printf "Proportional fonts are hard to read: these are 3 different characters: I|l" | open -f

AppleScript will give more options still.

-Chris

Chris, I think you misread that. I meant the input field (edit field) of a script action, as shown in the screenshot above.

In KM’s output window the font already is monospaced:

Hey Tom,

Sure enough.

I hadn't noticed that the Execute a Shell Script action's output was monospaced now either which is good to know.

-Chris

1 Like

Arrived here from Google and the monospace formatting would be amazing indeed :pray:

This can be done with the font specifications described in the Preferences.

defaults write com.stairways.keyboardmaestro.editor Font-Normal -string "Monaco"
defaults write com.stairways.keyboardmaestro.editor Font-Shell -string "USER"
defaults write com.stairways.keyboardmaestro.editor Font-AppleScript -string "FIXED"
defaults write com.stairways.keyboardmaestro.editor Font-JavaScript -string "SYSTEM"
defaults write com.stairways.keyboardmaestro.editor Font-Swift -string "Times"
defaults write com.stairways.keyboardmaestro.editor Font-HTML -string "Courier:25"
defaults write com.stairways.keyboardmaestro.editor Font-JSON -string "Marker Felt:10"
defaults write com.stairways.keyboardmaestro.editor Font-Comment -string "Palatino:20"
defaults write com.stairways.keyboardmaestro.editor Font-Shell -string "FIXED"

will use a fixed width font in the Execute a Shell Script action.

2 Likes

Which of these sets the font in the Display Text action?

None, it is always the system user fixed pitch font.

Which Display Text action?

Display Text in a Window takes on the styles the user has emplaced in the action.

It would be nice to be able to set a default for that, but I've just created some favorite actions with a few preferred font styles.

1 Like

In my case I would like the output from a shell script to be displayed with at fixed font:

1 Like

See:

You can configure the fonts used for the various action text views with:

Here's how I have mine set:

defaults write com.stairways.keyboardmaestro.editor Font-Shell -string "Menlo:14"
2 Likes

Thanks. Exactly what I needed.

1 Like

Hi. I try to find a way to change font style in Display in Text - output window.

defaults write com.stairways.keyboardmaestro.editor Font-Shell -string "Monaco:12"

I failed with this line on my machine.


Please see the above Pic.
with the method in this POST.

I successed with cmd-T method.
But today, things go worse. Please see the below Pic.


in this kind of structure:
use the defaults write method, failed.
use cmd-T method, failed.
Hope people help me :sob: :sob:

Might you get more control by writing yourself a subroutine which uses the Custom Floating HTML Prompt action ?

(Then you can quickly experiment and refine with CSS tweaks)

If you are doing this a lot, set up a "Display Text" action with the font formatting that you want, then make it a Favourite action.

You can have different formatting in the one "Display Text" action:

image

...so perhaps you aren't overwriting some existing choices? Try clicking in the text field, ⌘A, then setting your format options.

1 Like

But actually I am not a programmer. I think Applescript is my limit.
I always want to learn HTML. Since it was mentioned a lot here.
But cannot find a friendly instruction for non-programmer.

just success. your way is NICE.
Thanks!
I tried this method this morning. all failed.
Interesting to see this.