A Few Ruby Snippets for Scripters

I do most of my automation and string manipulation scripting using Ruby. I know it’s not the most popular language these days, but it’s the one I know the best (thanks to my days of hacking on TextMate bundles) and it’s usually the fastest way for me to solve a problem. I have reams of snippets saved (and easily accessible with Snibbets) and thought I’d share a few that are useful for everyday scripting on macOS. ruby, scripting, shell

→ Continue reading

macOS Keybinding Tricks: The Repeat Count Binding

In Vim, most operations have can have a count specified in the keystrokes for the command, e.g. to delete 3 lines. You can do similar in any Cocoa text field (all Apple apps, plus most native apps). You just need to specify a keyboard shortcut to use before the count. Then you can hit that keyboard shortcut, type a number (X) and then hit a key or key combination to have that event repeated X times. keybindings, keyboard, shortcuts, tricks

→ Continue reading

macOS Keybinding Tricks: The Kill Ring

So you may have seen my KeyBindings project before. It’s an insanely large collection of keybinding tricks that work in any macOS text field. Well, any native cocoa field. You won’t have much luck in Electron or other non-native text editors. But for most uses, including in Safari, Mail, Notes, nvUltra, and most of the Markdown editors, the tricks work great. You can do things like adding TextMate-style ⌘+⏎ to any editor to create a new line no matter where your caret1 (cursor) is… editor, keybindings, keyboard, tricks

→ Continue reading

Ruby Regexp::scan With MatchData

This post will only be of interest to people writing scripts in Ruby. Seriously, zero utility if you’re not using Ruby. Though I would be curious how you accomplish the same thing in other languages like Rust and Python, because I’ve never gotten too deep with string manipulation in anything other than Ruby, Swift, and Objective-C. If you care to leave a comment with pointers, I’m all ears. regex, ruby, scripting

→ Continue reading