Skip to main content


tldr man pages:

Bash Reference Manual:

The Art of Command Line:

Pure bash snippets:

Reusable Bash functions:

zsh is the default shell in macOS since Catalina (10.15, released October 2019) - see

Oh-heck, a terminal command for when you forget other terminal commands - -

Command history is saved in ~/.zsh_history.

Terminal shortcuts

  • Ctrl + R: Recall
    • Ctrl + R again to see next match
    • Return to execute
    • Ctrl + G to exit without executing
    • Esc to exit but leaving searched command
  • Ctrl + Z: send to the background

Various commands & tips

  • !!: run the previous command
  • What shell is used: echo $SHELL
  • List all environment variables: printenv. You can also print a specific envar: printenv ANDROID_HOME. (In Linux you can print many, eg printenv ANDROID_HOME PATH, but does not work in macOS.)

Command-line pro tips:

Use curly braces in the command-line to quickly create multiple related files with less typing source:

touch index.{js,css} # creates index.js and index.css
touch {P,H1,H2}.tsx # creates P.tsx, H1.tsx and H2.tsx

You can also use this with npm:

Command substitution

AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)


find . -type d -name "build"

find . -type d -name "build" -exec rm -rf {} +

find . -type f -name "*.iml"

find . -type f -name "*.iml" -exec rm -rf {} +

Exclude: find . -type d -name "dist" | grep -v 'node_modules'


diff -qr Carpeta1 Carpeta2


tree somefolder

To ignore something (eg a folder) use -I <wild-card-pattern>. Eg tree -I node_modules or tree -I venv. There can be multiple -I options.


fc [-e ename] [-lnr] [first] [last]

fc -s [pat=rep] [command]

List recent commands in history: fc -l


If we are running a server at (eg) port 3000 we can do lsof -i :3000 and it will print information about the process that started the server. Doing lsof -t -i :5000 gives the process id. Hence, to kill the process you can do kill -9 $(lsof -t -i :3000).