macOS
cmd + shift + .— toggle hidden filesecho 'alias list-background-apps="ls -d /Library/LaunchDaemons/* /Library/LaunchAgents/* ~/Library/LaunchAgents/*"' >> ~/.zshrc && source ~/.zshrc
CLI
Tools & References
- tldr — simplified, community-driven man pages
- Shell Script Best Practices
- explainshell — paste a command to see what each part does
See also: Linux
History & Snippets
historyshows command history- Repeat commands from history by adding
!then line number e.g.!406will run the command on line 406 - Prefix the last command with
!!e.g.sudo !!
Add a trailing newline to tracked non-empty text files (Stack Exchange):
git ls-files -z | while IFS= read -rd '' f; do if [ -s "$f" ] && file -b --mime-encoding "$f" | grep -qv binary; then tail -c1 < "$f" | read -r _ || echo >> "$f"; fi; donepg_dump
Dump a local PostgreSQL database from a container on macOS (use host.docker.internal on macOS/Windows, or --network=host -h localhost on Linux):
docker run --rm -e PGPASSWORD='<password>' postgres:17-alpine \
pg_dump -h host.docker.internal -p 5432 -U <user> -d <db> --create --inserts > dump.sqlmacOS Startup
/Library/LaunchAgents//Library/LaunchDaemons/~/Library/LaunchAgents/sudo launchctl listsfltool dumpbtm
ls -la /Library/LaunchAgents/
ls -la /Library/LaunchDaemons/
ls -la ~/Library/LaunchAgents/Zip
zip -r archive.zip ./project -x "*.DS_Store" "*/node_modules/*" "*._*" "*/.angular/*" "*/.terraform/*"