lazy.sh

How I've been coping with my iLife

lazy.sh

I'm not a big fan of Apple computers and while I've found wisdom about what to do when life gives you lemons, there's not as much guidance available for when it gives you Apples. My life has given me both, but in this post I'll focus on the latter.

Software Essentials

I dislike most of Mac's defaults, but here's what I installed and am currently pretty happy with:

Terminal: https://iterm2.com/
iTerm2 is amazing. It's actually better than any terminal emulator I've used on Windows.

Shell Enhancement: https://ohmyz.sh/
Some shell enhancements to make my life easier. Apple has moved to zsh as their default shell over the tried and true bash, which the traditionalist in me hates, but it's been fine to use.

Package Manager: https://brew.sh/
How do we want to install software? With a package manager of course, because GUIs are kind of lame. brew is a powerful piece of software that offers a decent replacement to my beloved apt.

iTerm2 running oh-my-zsh and brew

Notable Mentions: Sublime Text Editor (text editing, duh), Visual Studio Code (top-dog IDE), CopyClip (clipboard history), KeePassXC (password manager), uBar4 (dock replacement)

Laziness

The most important question is how do we script a way to keep the computer pushing the letter k every 5 seconds for a period of time determined by user input.

Well lucky for you (and me), there is a way:

#!/bin/bash
if [ -z ${1+x} ]; then echo "How many seconds times 5?"; read numIn; else numIn=$1; fi
echo "set i to 0
repeat while i < $numIn
set i to i + 1
delay 5
tell application \"System Events\" to keystroke \"k\"
end repeat" | osascript

Save the above block into a text file (call it lazy.sh), run a chmod +x ./lazy.sh to make it executable, and call it with /path/to/lazy.sh or /path/to/lazy.sh 5, where the number sets the amount of seconds multiplied by 5 you want this to run for.

3x5 (15) glorious seconds of wakefulness

The result is that it'll push k that many times, which keeps your computer "active" while you step away to conduct important business.

Me in a year or two