macOS

  • cmd + shift + . — toggle hidden files
  • echo 'alias list-background-apps="ls -d /Library/LaunchDaemons/* /Library/LaunchAgents/* ~/Library/LaunchAgents/*"' >> ~/.zshrc && source ~/.zshrc

CLI

Tools & References

See also: Linux

History & Snippets

  • history shows command history
  • Repeat commands from history by adding ! then line number e.g. !406 will 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; done

pg_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.sql

macOS Startup

  • /Library/LaunchAgents/
  • /Library/LaunchDaemons/
  • ~/Library/LaunchAgents/
  • sudo launchctl list
  • sfltool 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/*"