Skip to content

Instantly share code, notes, and snippets.

@metasean
Forked from JoniWeiss/Mac-CLI-Tools.md
Created October 9, 2016 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metasean/f63cc230ad6c7ab293baac84e45fbe49 to your computer and use it in GitHub Desktop.
Save metasean/f63cc230ad6c7ab293baac84e45fbe49 to your computer and use it in GitHub Desktop.
Mac Command Line for Web Devs

Mac Command Line for Web Devs

Handy Tools

  • mdn-search.
    • Quick tool for search in Mozilla Developer Network from command line, built with nodejs by Nicolás Arias (ezakto):

    • Usage:

    mdn   [options]   [command]   <query>
  • Dash for macOS.

    • Dash is an API Documentation Browser and Code Snippet Manager.
    • Dash stores snippets of code and instantly searches offline documentation sets for 150+ APIs.
    • You can even generate your own docsets or request docsets to be included.
    • See Function below for a CLI function to work with Dash.
  • Atom Snippets.

    • Replace tag/element expansion with your customized one (Ex.: html).
    • Add the following to your snippets file to replace functionality of html autocomplete to include viewport tag:
'.text.html, .atom/language-html':
   'HTML':
      'prefix': 'html'
      'body': '<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<meta charset="utf-8">\n\t\t<meta name="viewport" content="width=device-width, initial-scale=1">\n\t\t<title>$1</title>\n\t</head>\n\t<body>\n\t\t$2\n\t</body>\n</html>'

Command-Line Tools:

  • Open current directory in MacOS Finder
    open -a Finder ./
  • Create a bash alias called “f”:
    alias f='open -a Finder ./'
  • Open Dash app from command line:
    open -a Dash
  • Open Dash app from command line and search for ‘flex’ in CSS documentation:
    open dash://css:flex
  • Open MDN in Chrome browser:
    mdn open
  • Open MDN in Chrome browser and search for ‘flex’ in CSS documentation:
    mdn -o -t css flex

Bash Aliases & Functions

  • Alias for ls -l command:
    alias lsl=‘ls -l’
  • A fancier ls -l command (try it!):
    alias ll='ls -FGlAhp'
  • Clear terminal display (without affecting history):
    alias c='clear'
  • Create a bash function called “dash” as a CLI for Dash macOS app:
function dash() {
    open "dash://$*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment