Skip to content

Terminal (Mac)

brew package manager

  1. Shells
  2. bash script
  3. Tips - Handling Files & Directories
  4. Tips - Keyboard Shortcuts
  5. Kill a process
  6. Using alias
  7. Using curl
  8. Using find
  9. Using grep
  10. Cheatsheet
  11. Linux Commands by Alex Xu

Plugins

Auto Completion

# Bash version
$ bash --version

# Auto Completion
## If running Bash 3.2 included with macOS
$ brew install bash-completion
## or, if running Bash 4.1+
$ brew install bash-completion@2

Working with JSON

Bash doesn't ship with supporting JSON out of the box. If you do not have a command line utility (jq), install it

$ brew install jq

Examples

# Read and use JSON in bash
$ echo '{"a": {"b":123 } }' | jq '.a.b'    # returns 123 as output

# Read API response
$ curl https://swapi.co/api/people/2 | jq    # Pretty print JSON

# Pass a JSON file to jq for filtering content
$ jq '.dependencies | keys' package.json