When you write and edit a command to execute in zsh, you’re using zshzle , its command line editor. zshzle sets up keybindings like <Ctrl-b> to move the cursor back one character, and <Ctrl-r> to search command history. In zsh, use zle’s vared built-in to quickly set a variable’s value interactively. vared pastes the variable’s current value in a command line ready for you…
Minutes in a Year
How minutes are there in a year? Thanks to the solar system, it’s complicated, but Google tells us one answer: 525960. That’s equal to 8766 hours, or 365.25 24-hour days, which is the average number of minutes in a Julian calendar year. Google also gives a nice tip: in case 525960 is too long for you to remember, you can also use this approximation: 526000. When you just want to do…
Global find and replace in Vim
Use the quickfix list. :grep 'whatever' Fills the quickfix list with matches. Be sure and disable anything else which might stomp over the quickfix list, like ALE. Or, use :lgrep which fills the location list, which is scoped to a window. Acting on the results Run a command (search and replace, then write) for each file in the quickfix list: :cfdo %s/whatever/whomstever/g | w
Developing Python CLIs with Poetry
Poetry brings a simplified interface to Python’s packaging and distribution system. It makes all the right things easy to do. Here’s how you use it to develop a new Python CLI project. Getting started We’ll make a CLI called hello-snake , in a package and project called snake . First run poetry new to create the project skeleton. tom@tomtop 🎪:~/tmp % poetry new snake Created…
Two shebang papercuts
You’ve written a Ruby script on your Mac. The script demands great performance, so you add --enable=jit to its shebang : #!/usr/bin/env ruby --enable=jit print 'Hello, world!' You test on your Mac and the program greets everybody in record time. Ship it! Some time later, a user reports a problem. When they run the script, it seems rather slow; in fact, they’ve waited for hours and no…
[activating prefrontal cortex]
Since last weekend, I’d been meaning to write here. I have a few ideas to write about—some of them I’ve even outlined and sketched diagrams for—but I haven’t actually gotten to writing anything. It’s bothered me all week. While stuck in bed reading my phone Friday morning, a Hacker News comment caught my eye. Quoting user stevewodil: If you’re having trouble getting…
Healthchecking in Neovim
I like to use a few text editor plugins for finnicky things like “smart” code completion. These plugins often rely on some assumptions about the state of the computer outside of the editor: they might need a utility program installed (such as rls ), or a configuration file to exist in a certain location, or a certain environment variable to be set. When the computer’s state is…