A shell function I wrote to stop reaching for Sublime Text every time I need to write a Slack message.
The Itch
The further I go in my career, the more obsessed I get with shaving steps off things that mildly annoy me. It’s a sickness, and I’ve made peace with it.
The Problem
At work, I juggle three things all day: my terminal, my IDE, and Slack.
Slack is the weak link. As a Vim user, editing messages is a pain — navigating text with arrow keys and no modal editing makes me feel like I’ve forgotten how to type. So I’d do this:
- Open Sublime Text (vim mode, no save required)
- Open a new tab
- Write and polish the text
- Select all, copy
- Close the tab (maybe)
- Send the message
Cumbersome. Four tools open just to write a Slack message.
So I wrote this:
Show/hide code
# in your ~/.zshrc
s() {
local f
f=$(mktemp /tmp/scratch.XXXXXX)
vi "$f"
cat "$f" | pbcopy
rm -f "$f"
}Now it’s:
- Type
sin the terminal - Write and edit the text in Vim
- Close the file — it’s already in your clipboard
- Send the message
“That’s it?”
Yes. Two steps fewer, one tool fewer, zero context switching.
I know it sounds absurdly small. But small friction compounds. Every time you reach for a separate tool, you break flow, lose a few seconds, and add just enough overhead that you sometimes just… don’t bother refining what you’re writing.
This little function removed that resistance entirely.
If you have a similar itch, here’s a challenge: what other tools in your workflow could be replaced by a scratch buffer and a copy to clipboard?