Tmux Application Startup Script

My development environment depends on several processes running. Here’s how I’ve scripted this setup. Whenever I boot up, I need at least these processes running: Sidekiq (jobs) Rails (API) Webpack (frontend) Docker (containers) Here’s how I’ve scripted it: #!/bin/bash tmux new-window -n sidekiq tmux send-keys -t sidekiq 'sidekiq' Enter tmux new-window -n rails tmux send-keys -t rails 'rails s' Enter tmux new-window -n webpack tmux send-keys -t webpack 'bin/webpack' Enter tmux new-window -n docker tmux send-keys -t docker 'bin/docker' Enter open http://host.docker.internal:3000/ This starts each process in its own named Tmux window, then opens the application in my browser. That last step is a losing race condition with the other processes, which are still booting, but I just wait a few seconds and refresh the browser tab. ...

July 28, 2022

Spell Checking with Vim: Tutorial and Best Practices

I write each post for this blog in Vim. Writing in the terminal makes me feel like a programmer, even when I’m not specifically programming. In this post, I’ll share how I spellcheck in Vim. Enable Spelling Vim’s spelling help page is extensive, and can be viewed at: :help spell It suggests enabling spelling like this: :setlocal spell spelllang=en_us When you to this, you’ll see words that Vim considers misspelled in red. ...

June 15, 2022

Select First Spell Suggestion

I use Vim’s spell feature when writing blog posts. Very often, the first suggestion it makes is the one that I choose. Consider a word like ‘Rubysit.’ My dictionary contains the word ‘Rubyist’ (naturally) and that’s what Vim spell is going to suggest to me first. For transposition errors like this I’d like to skip the word picker when possible. To automatically choose the first suggestion, in normal mode put your cursor over the word and type 1z=.

June 14, 2022

My psql Config

RC files, thought to stand for “run command” files, are read by a program during startup. The file that configures the PostgreSQL REPL psql is called .psqlrc. In this post I’ll share my personal psql configuration. Note: many of these configurations came from my time at Hashrocket. We documented some these preferences via PG Casts. Here’s my .psqlrc. \set QUIET on \pset null 'ø' \x auto \timing \set HISTFILE ~/.psql_history-:DBNAME \set HISTCONTROL ignoredups \set QUIET off Let’s look at each setting. ...

April 12, 2022

Solved! How to Exit Vim "Ex" Mode

How does one exit Vim “Ex” mode? But first… how did you even get into “Ex” mode? Probably by accidentally typing Q in normal mode: *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501* Q Switch to "Ex" mode. This is a bit like typing ":" commands one after another, except: - You don't have to keep pressing ":". - The screen doesn't get updated after each command. - There is no normal command-line editing. - Mappings and abbreviations are not used. If this is true you probably missed the initial instructions: ...

April 6, 2022

Autoformat Your Code

Auto-formatting code is good, and you should be doing it all the time. Why? It helps you write better code in real-time, preempt trivial discussions, and maybe even democratize programming. Better Code in Real-time First, writing better code in real-time: I’ll use the Prettier auto-formatter as an example. I have Prettier running everywhere, auto-formatting on write. This means that each time I write my file, which I do a lot, Prettier attempts to format my code. Neatening my work as I go along helps me think clearly and see refactoring opportunities. ...

March 10, 2022

Why Vim

I’ve been using, teaching, and stanning Vim since almost the beginning of my programming career. Yet, when asked to explain this preference, I stumble. In this post, I’d like to explore why I love Vim. Disclaimer: I haven’t used every text editor that has ever existed! I haven’t used Emacs or some of the GUI editors that have come and gone over the years. I’m not arguing that Vim is better than any of these. In particular, VSCode in Vim mode seems to rival Vim in some ways. ...

February 23, 2022

Refining Your Terminal Aliases

Any command you type out manually, or even tab-complete a few times, can be shortened. A common shortening technique is the terminal alias. Here are some tips that help me write better aliases and cut my terminal keystrokes. Identify Alias Opportunities With the ’typeless’ Command I found this trick a long time ago from, I believe, Thoughbot’s Upcase course. I call it typeless, and it’s a well-worn alias in my .zshrc: ...

February 10, 2022

Jump to N Percent of a File

From normal mode, N% will jump you to that percentage of the file. So 50% jumps to halfway through the file.

January 23, 2022

Man pages in Vim

Hit K on a keyword, and Vim looks up the program under the keyword. It’s a bit jarring because Vim appears to shell out from your buffer to show the definition. To see that man page in Vim, load the man.vim plugin from command mode or in your .vimrc: :runtime! ftplugin/man.vim Now, you can read man pages as a Vim buffer: :Man curl

November 11, 2021