tips
46 tips CLI
One command, setting or habit at a time about CLI: what it does, the line to copy and a caveat or two.
Scripting 9
-
Prints a pull request's diff in the terminal and leaves out files that match a glob.
gh pr diff 123 --exclude '*.lock' -
Shows the log of failed workflow steps in your terminal, without opening the whole run.
gh run view 12345 --log-failed -
Sets GitHub Actions secrets from the terminal, one by one or all at once from a .env file.
gh secret set -f .env -
Watches the checks of a pull request and quits as soon as one fails.
gh pr checks --watch --fail-fast -
Follows a running Actions workflow in the terminal and returns its result.
gh run watch --exit-status -
Downloads only the matching assets of a release, without the browser.
gh release download -R cli/cli --pattern '*linux_amd64.tar.gz' -D /tmp/gh -
Reruns the failed jobs of a workflow run instead of the whole run.
gh run rerun 1234567890 --failed -
Calls any API endpoint with your login and pulls out just the fields you need.
gh api repos/{owner}/{repo}/issues --paginate --jq '.[] | "\(.number)\t\(.title)"' -
Switches Claude Code to a backup model automatically when the main one is overloaded.
claude --fallback-model sonnet,haiku
Windows 6
-
Shows only the usage examples of a cmdlet instead of the full help text.
Get-Help Get-ChildItem -Examples -
Lists the services running inside each process, filtered by name, PID or memory use.
tasklist /svc /fi "IMAGENAME eq svchost.exe" -
Measures packet loss at every router between your PC and a destination.
pathping /n example.com -
Shows what woke the PC from sleep and which devices are allowed to wake it.
powercfg /lastwake -
Observes an idle PC for a minute and writes an HTML report on power problems.
powercfg /energy -
Opens command output in a filterable window and passes the rows you select onward.
Get-Process | Out-GridView -PassThru | Stop-Process
Files and media 4
-
Remembers which videos were downloaded so a re-run only fetches new ones.
yt-dlp --download-archive archive.txt "https://www.youtube.com/playlist?list=PLAYLIST_ID" -
Prints the available HandBrake presets so you can encode from the terminal with one of them.
HandBrakeCLI -z -
Edits the language or default flag of an MKV track in place, in a fraction of a second.
mkvpropedit movie.mkv --edit track:a1 --set language=eng -
One command line option sets hostwebclient to false, so the server hosts no web client.
jellyfin --nowebclient
Linux and shell 4
-
Saves your favourite gh commands as short aliases, with arguments.
gh alias set mine 'pr list --author @me' -
Creates a pull request from the terminal, taking title and body from your commits.
gh pr create --fill -
Jumps from the terminal to a file, line, issue or settings page of the repository.
gh browse src/app.py:42 -
Switches to the branch of a GitHub pull request using only its number.
gh pr checkout 123
Slash commands 3
-
Switches to plan mode with a task attached, so nothing gets edited before you agree.
/plan fix the login redirect bug when the session cookie has expired -
Adds a custom status bar to Claude Code showing things like model and context usage.
/statusline show model name and context percentage with a progress bar -
Splits the current Claude Code conversation so you can explore a different direction safely.
/branch try-sqlite
WP-CLI 3
-
Lists the widgets placed in one sidebar, with their ID and position.
wp widget list <sidebar-id> -
Lists the registered sidebars with their IDs, which you need for other widget commands.
wp sidebar list -
Lists registered taxonomies, optionally only those that belong to one post type.
wp taxonomy list --format=csv
Admin and checks 2
-
Lists all tables and views of a SQLite database with type, column count and strict flag.
PRAGMA table_list; -
Shows databases, tables or columns from the command line, with optional index and row counts.
mysqlshow
Identify and inspect 2
-
See the exact bytes of a file, with hex on the left and readable characters on the right.
printf 'GET /\r\n' | hexdump -C -
Show only a chosen slice of a file in hex instead of the entire thing.
hexdump -C -s 512 -n 64 disk.img
Prompting 2
-
Cycles Claude Code between permission modes, including one that stops asking about file edits.
claude --permission-mode acceptEdits -
Parks the half-written prompt, lets you send something else, then restores it.
Settings and permissions 2
-
Sets a session setting straight from the prompt instead of through the settings panel.
/config verbose=true -
Makes an unattended Claude Code run deny anything not on your allowlist instead of waiting.
claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"
Apps and containers 1
-
Array settings in config.php are set with an index. Without it you overwrite the wrong thing.
sudo -E -u www-data php occ config:system:get trusted_domains
Downloads 1
-
Check if a URL or a list of links still works, without fetching the content.
wget --spider https://example.com/file.zip
Inspect and convert 1
-
Prints selected properties of one stream, such as the video width and height, in plain machine-readable form.
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 in.mp4
Proxying 1
-
Compares a Caddyfile with its formatted version and shows the differences, without touching the file.
caddy fmt --diff Caddyfile
Quick checks 1
-
Reads the actual Arm clock in hertz, which can differ from the speed the kernel asked for.
vcgencmd measure_clock arm
SQL shells 1
-
Takes every value a query returns and executes it as its own SQL statement.
\gexec
Setup and devices 1
-
Writes a Raspberry Pi image from the terminal, and refuses it if the SHA-256 hash does not match.
sudo rpi-imager --cli --sha256 <hash> raspios.img.xz /dev/sdb
Speed and limits 1
-
Cap the speed of a wget download so the rest of the network stays usable.
wget --limit-rate=2m https://example.com/big-file.iso
Text processing 1
-
Limit ripgrep to some file types or skip noisy files with a glob.
rg 'apiKey' -g '!*.min.js' -g '!package-lock.json'
Nothing in this filter yet.