Software

Five shell tricks I use every day

Small habits that add up. Swipe or use the arrow keys.

1. Jump back with cd -

Toggles between your current and previous directory. Surprisingly handy when bouncing between a repo and a config folder.

2. Reuse the last argument

!$ (or Alt+.) gives you the last argument of the previous command.

mkdir -p src/very/long/path
cd !$

3. Search history with Ctrl+R

Start typing any fragment of a past command. Press Ctrl+R again to cycle older matches.

4. Brace expansion

cp config.yml{,.bak} expands to cp config.yml config.yml.bak.

5. set -euo pipefail

Put it at the top of scripts so they fail loudly instead of carrying on after an error.

1 of 5