I can tell you the day I knew I would be a Systems Administrator (the term SRE hadn’t been invented yet.) My Linux professor, a brilliant engineer at NASA, said: “The best system administrators are the laziest.” He went on to qualify that statement but I had stopped listening. My fate was sealed.
I know you’ve been there. Sitting on a Zoom video conference, watching a brilliant person sharing their screen but being hand-cuffed by the way they use their laptop. I try to ignore it, presuming they won’t appreciate my unsolicited advice on how they use their own computer. After all, such things are somewhat personal and habitual. My favorite quote from The Phoenix Project is: “Any improvements made anywhere besides the bottleneck are an illusion.”
We refresh our laptops every three years because they are ‘getting slow’. We buy bigger monitors because we know it improves productivity. But sometimes the real bottleneck is the habits that we’ve developed for years. A workflow that was once annoying has cemented itself as a functional habit and our fingers just fall into a familiar groove. When Apple removed the escape key from the MacBook Pro, I was terrified my laptop would break and I would be forced to upgrade. A friend of mine said, “Remap it to caps lock and use it for a week, you won’t ever think about it again.” He was right, I am able to retrain my fingers after forcing myself into a change.
Over the years, I’ve compiled a variety of tips and tricks that help me make better use of my MacBook Pro laptop, and as a result, be more productive at my job. I’m sharing them here, hoping others may find them useful as well.
Using your pixels wisely
Here are some brutal truths to help you decide if your window management could use some improvements:
- If you have ever seen your desktop picture (other than after a restart), you aren’t using your screen effectively.
- If you have ever spent more than two seconds finding an application window, something is probably wrong.
- If you routinely use your Dock or Mission Control, things could probably be better.
The first trick in my toolbag is how I use the Spaces feature. I keep different things in different Spaces so I always know where they are.
For example:
Space 1 – Firefox / Notes / Sublime Text
Space 2 – iTerm2
Space 3 – Slack
Space 4 – IntelliJ
Space 5 – Calendar
Then I add these keyboard shortcuts to navigate between them (the mouse is always the last resort!)
The second trick is how I populate these Spaces. I never use the OSX “full screen” but instead I drag the window up and it snaps to a full screen. This is a feature of BetterSnapTool. After a restart, sometimes windows get reshuffled so I use Stay to help with that.
The third trick is a fallback if the first two fail me. I turn on Mission Control and map it to a hot corner. I keep my Dock hidden and mostly ignore it. It’s important to understand that using command-tab or Mission Control is an ineffective way to switch windows because the placement of each window in the “choosing interface” is always changing.
Tabs are the best and the worst
In a world where we can’t live without browser tabs, I’m always surprised with how few browsers support horizontal tabs. Horizontal tabs allow tabs to stay legible, groupable, and organized. Tabs can even be pinned to stay in a specific place or dragged around to group them logically. I use Firefox and Tab Center Redux for this:
I also use horizontal tabs for iTerm2:
Another neat trick with iTerm2 is you can change the color of tabs programmatically using the escape codes (one idea: red tab for prod, blue tab for engineering).
Clipboards needn’t be ephemeral
Using a clipboard manager with clipboard history is an often-overlooked optimization, but once you’ve learned to use it, it will save so much time. There are many available but here are my basic requirements:
- mouse-less usage
- store and search my history
- delete things from my history (like passwords)
I use the Powerpack from Alfred for this, with double-command as the keyboard shortcut. It works great.
Am I muted?
I recently started using AirPods instead of my headset and there’s no mute button. The keyboard shortcuts in Zoom only work when Zoom is selected, so I created some global keyboard shortcuts that will mute my microphone via the Alfred Powerpack :
This uses the code from Ben Lobaugh, although I changed mine to be a static mapping instead of a toggle.
I also installed MuteMyMic so that I have an icon in my toolbar to check if I’m muted or unmuted .
What’s my password? Where did I save that MFA token?
I’m going to assume you already use a password manager with browser integration, otherwise this is going to diverge into a diatribe on security! I was a longtime user of LastPass but I’ve recently migrated to 1Password. The support for one-time passwords and multi-factor authentication in 1Password is unparallelled and it speeds up login to some websites significantly.
A picture perfect explanation
I prefer to use Skitch for screenshots so I can quickly annotate and share them. It also saves your history and supports custom naming. This is handy to start a conversation in Slack without starting a Zoom meeting, or to share during a Zoom meeting when someone else is already sharing their screen. For example:
Terminals and shells and iTerm2, oh my!
There are infinite possibilities for automation when using your terminal. Here are some ideas and tips:
-
- There are numerous benefits to using a third party terminal app like iTerm2 instead of the OSX Terminal app:
- tabs, split panes and color customizations
- custom profiles, launch-templates and additional settings
- If you can get your whole team to agree certain things, it will aid in collaboration:
- Choose a shell (zsh or bash) so you can then share functions
- Choose your dev OS (MacOS X or Linux); then your internal documentation, troubleshooting and cross-training will be easier
- Consider centralized SSH (Secure Shell) workstations or other dev collaboration tooling to keep everyone’s dev environments in sync
- When choosing the tools your team will use, don’t forget to consider:
- how you currently do development (centralized or bespoke-laptops)
- how you will keep versions and dependencies in sync
- Figure out a useful command prompt:
- This is ever-changing but here is what I use right now:
- There are numerous benefits to using a third party terminal app like iTerm2 instead of the OSX Terminal app:
export PS1="\e[02;34m<\$(basename \${KUBECONFIG:=\"\"})/\$(kubens -c)>\e[m \[\033[01;35m\]\u@\h:\[\033[01;34m\]\$(parse_git_branch) \[\033[01;32m\]\w \[\033[01;34m\]\n\[\e[0m\]"
-
- Which yields this:
- Don’t forget that loops can work fine from prompt and can gather information quickly or change things quickly.
- How many pods do I have in every kube?
for i in `find ~/.kube -name "kubeconfig*"`; do echo $i:; kubectl get pods -A --kubeconfig=$i | wc -l; done
-
- Update all my repos:
for i in `ls ~/git/`; do cd ~/git/$i; git checkout master; git pull; done
- Functions for your .bashrc or .zshrc
- If you find you are using these loops repeatedly, it might be time to add a function to your shell (.bashrc or .zshrc):
function mooo-kubectl-all () { for i in `find ~/.kube -name "kubeconfig*"`; do export KUBECONFIG=$i CLUSTER=$(basename $i | sed 's/kubeconfig_//') echo "#### Running command '"$@"' on" echo "#### $CLUSTER:" bash -c "$@" echo "" done }
-
- Naming your functions:
- You may have noticed I used the name mooo-kubectl-all instead of kubectl-all. This makes it easier to find your function via bash and prevent the function from ruining your existing autocomplete for ‘kubectl’
- Using a function in a function:
- Don’t forget you can call one function from another:
- Naming your functions:
function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } function gp() { # git push the current branch and set upstream tracking branch=$(parse_git_branch | tr -d '()') if [[ "$branch" != *"master"* ]]; then git push -u origin $branch elif [[ "$branch" == *"master"* ]]; then echo "Don't push to master branch. Create a branch and try again." fi }
- Aliases:
- If you find yourself using the same command a lot, it might be time to add some aliases like these:
alias tf='terraform' alias tg='terragrunt' alias k='kubectl' alias kn='kubectl --namespace=kube-system' alias ka='kubectl get pods -A' alias pg="grep -RIi" alias cdg='cd ~/git' alias sre='cd ~/git/sre' alias dev='cd ~/git/dev'
Conclusion
These steps are a culmination of years of laziness. I hope you find it useful. Stay lazy out there!