Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save venkatesh87/a3d4a1eee4b37ef451f97db5d5249a32 to your computer and use it in GitHub Desktop.
Save venkatesh87/a3d4a1eee4b37ef451f97db5d5249a32 to your computer and use it in GitHub Desktop.
Setup a new mac

Before anything else:

  • Dropbox: Store all the things (including my 1Password database needed next)
  • 1Password: The best password manager (Need this early so that I can enter passwords for the rest of the stuff below)

App Store:

  • Mindnode: Mind Mapping
  • Trello: Basic project board
  • Todoist: Todo manager (Integrates with google assistant)
  • Keynote: Presentations
  • Numbers: Spreadsheets
  • Pages: Documents
  • Harvest: Time tracking
  • Hidden Me: Hide desktop icons (for screen sharing and the like)
  • Slack: Work chat app
  • MindNode Pro 1: Mind Mapping
  • Moom: Window manager
  • Alfred: App launcher and so much more (Spotlight replacement)

3rd Party

iTerm Preferences

General:

  • Closing (uncheck all)

Appearance:

  • Show tab bar even when there is only one tab

Profiles:

  • Working Directory: Reuse previous session's directory

Terminal:

  • Scrollback Lines: Unlimited scrollback

General Terminal Stuff

  • Command Line Tools: Git and stuff
    • xcode-select --install
  • Git Config
    • git config --global user.name "Your Name"
    • git config --global user.email "[email protected]"
  • Homebrew
    • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • wget
    • brew install wget
  • Fish: Bash replacement
    • brew install fish (Install it)
    • Add /usr/local/bin/fish to /etc/shells
    • chsh -s /usr/local/bin/fish (Set it as default)
    • fish (Use it now)
  • Oh my Fish: Addons for Fish
    • curl -L https://get.oh-my.fish | fish
  • Eden: Fish Theme:
    • omf install eden
  • Fisher: Package manager for fish (required for fish-nvm)
    • curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
  • fish-nvm: NVM support for fish
    • fisher add jorgebucaran/fish-nvm

Fish aliases

To create and save aliases, enter the following pattern:

alias <shorthand> "<text your would like to be run>"

funcsave <shorthand>

e.g.

alias gs "git status"

funcsave gs

  • gs "git status"
  • ga "git add"
  • gba "git branch -a"
  • gbd "git branch -D"
  • gcm "git commit -m"
  • gcam "git commit -am"
  • gd "git diff"
  • gdw "git diff --word-diff"
  • gds "git diff --staged"
  • gdsw "git diff --staged --word-diff"
  • gco "git checkout"
  • gl "git log --oneline"
  • gps "git push"
  • gpu "git push -u origin"
  • gpl "git pull"
  • gm "git merge"
  • dcdown "docker-compose down"
  • dcup "docker-compose up -d --build --remove-orphans"
  • ys "yarn start"
  • yi "yarn"
  • uis "yarn upgrade; and yarn; and yarn start"

Create an SSH Key

  • ssh-keygen -t rsa -b 4096

Add the key to your keychain so you don't have to type your password every time

  • ssh-add -K ~/.ssh/[your-private-key]
  • vi ~/.ssh/config Enter the following in to the config file:
Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

Add additional IdentityFile lines for additional keys

RVM

  • brew install gpg: Prerequisite for installing rvm
  • RVM
    • Install gpg keys gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
      • If you get this error gpg: keyserver receive failed: No route to host, runcurl -sSL https://rvm.io/mpapis.asc | gpg --import - then try again (Reference)
    • Install rvm with Ruby curl -sSL https://get.rvm.io | bash -s stable --ruby
    • Download the fish functions from GitHub curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
    • And activate the default Ruby manually in your config.fish file: echo "rvm default" >> ~/.config/fish/config.fish
    • Test it with rvm -v and ruby -v

Node

Composer

  • Follow the installation instructions here: https://getcomposer.org/download/
  • Move the composer to a globally accessible location: mv composer.phar /usr/local/bin/composer

Extensions

text snippets

Twig Include

{
  "Twig Include": {
    "prefix": "tinclude",
    "body": [
      "{% include \"@${1:atoms/text/headings/_heading.twig}\" ${2:with {",
      "  ${3:heading_level}: '${4:3}',",
      "  ${5:heading_blockname}: ${6:component}__base_class,$0",
      "\\} }%}"
    ]
  }
}

Twig Embed

{
  "Twig Embed": {
    "prefix": "tembed",
    "body": [
      "{% embed \"@${1:atoms/text/headings/_heading.twig}\" ${2:with {",
      "  ${3:something}: ${4:awesome},$0",
      "\\} }%}",
      "  {% block ${5:super} %}",
      "    ${6:{{ cool \\}\\}}",
      "  {% endblock %}",
      "{% endembed %}"
    ]
  }
}

Twig Extends

{
  "Twig Extends": {
    "prefix": "textends",
    "body": [
      "{% extends \"@${1:templates/_default.twig} %}",
      "  {% block ${2:page_content} %}",
      "    ${3:{{ content \\}\\}}",
      "  {% endblock %}"
    ]
  }
}

Twig Set

{
  "Twig Set": {
    "prefix": "tset",
    "body": [
      "{% set ${1:something} ${2:= ${3:awesome} }%}",
      "$0",
    ]
  }
}

Twig If

{
  "Twig If": {
    "prefix": "tif",
    "body": [
      "{% if ${1:something} ${2:== ${3:awesome} }%}",
      "  ${4:{{ do stuff \\}\\}}",
      "{% endif %}",
    ]
  }
}

Twig For Loop

{
  "Twig for loop": {
    "prefix": "tfor",
    "body": [
      "{% for ${1:item} in ${2:items} %}",
      "  ${3:{{ item.content \\}\\}}$0",
      "{% endfor %}",
    ]
  }
}

Twig Block

{
  "Twig Block": {
    "prefix": "tblock",
    "body": [
      "{% block ${1:block} %}",
      "  ${2:{{ content \\}\\}}",
      "{% endblock %}"
    ]
  }
}

Elemnt with BEM function

{
	"Element with BEM class naming": {
		"prefix": "ebem",
		"body": [
			"<${1:div} {{ bem(${3:$2__base_class}${4:, [$5]${6:, $2__base_class}}) }}>",
			"  $0",
			"</$1>",
		]
	}
}

Settings

{
  //////////////////////////////
  // VS Code Interface Tweaks //
  //////////////////////////////
  // Disable breadcrumbs
  "breadcrumbs.enabled": false,
  // Make the cursor solid at all times (disables blinking)
  "editor.cursorBlinking": "solid",
  // Disable the minimap
  "editor.minimap.enabled": false,
  // Show rulers at 80 and 100 character
  "editor.rulers": [
    80,
    100
  ],
  // Alsways show the folding controls
  "editor.showFoldingControls": "always",
  // Hides the Editor, Search, Extenstions, etc. bar.
  // You can still get to them via hot-keys or the "View" menu
  "workbench.activityBar.visible": false,
  // My preferred theme
  "workbench.colorTheme": "One Dark Pro",
  // Hide the close button on tabs to condense them a bit
  "workbench.editor.tabCloseButton": "off",
  // Condense the tabs at the top just a bit
  "workbench.editor.tabSizing": "shrink",
  // Material theme icons
  "workbench.iconTheme": "material-icon-theme",
  // Enables horizontal scrolling in the sidebar
  "workbench.list.horizontalScrolling": true,
  // Add the path to the file in the window title
  "window.title": "${activeEditorMedium}${separator}${rootName}",
  // Starts up new windows with a new untitled file
  "workbench.startupEditor": "newUntitledFile",
  //////////////////////////
  // Code Writing Helpers //
  //////////////////////////
  // Enable auto-closing of tags in all file types
  "auto-close-tag.activationOnLanguage": [
    "*"
  ],
  // Set tabs to equal two spaces
  "editor.tabSize": 2,
  // Tell emmet to work on .js files (not just when specified as react)
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  },
  // Tell emmet to use single quotes
  "emmet.syntaxProfiles": {
    "jsx": {
      "attr_quotes": "single"
    }
  },
  /////////////////////////////////
  // Code Linting and Formatting //
  /////////////////////////////////
  // Style linting //
  // Disable VS Code's validation of css, less, and scss because we're using Stylelint
  // (This just prevents duplicate reports in the log)
  "css.validate": false,
  "less.validate": false,
  "scss.validate": false,
  // Tell Stylelint to autofix on Save
  "stylelint.autoFixOnSave": true,
  // JS linting
  // Disable format of save for JS and JSX, we will do this via eslint
  // "[javascript]": {
  //   "editor.formatOnSave": false,
  // },
  // "[javascriptreact]": {
  //   "editor.formatOnSave": false
  // },
  // Turn on Auto Fix for all providers (including eslint)
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  },
  // General linting/formatting
  // Format on Paste
  "editor.formatOnPaste": true,
  // Format on Save
  "editor.formatOnSave": true,
  // Format on Type
  "editor.formatOnType": true,
  // Insert a final newline
  "files.insertFinalNewline": true,
  // Remove additional newlines after the "final" one
  "files.trimFinalNewlines": true,
  // Trim any whitespace at the end of lines
  "files.trimTrailingWhitespace": true,
  //////////////////////
  // User Preferences //
  //////////////////////
  // Custom dictionary
  "cSpell.userWords": [
    "endblock",
    "endembed",
    "nypl",
    "stylelint"
  ],
  // Don't confirm when deleting files in the explorer
  "explorer.confirmDelete": false,
  // Don't confirm when dragging and dropping files in the explorer
  "explorer.confirmDragAndDrop": false,
  // Associate extensions with languates
  "files.associations": {
    "*.theme": "php",
    "*.module": "php",
    "*.css": "postcss"
  },
  // Use iTerm when opening current project in terminal (Cmd + Shift + C)
  "terminal.external.osxExec": "iTerm.app",
  // The window zoom level
  "window.zoomLevel": 0,
}

Fish Aliases

  • alias mampsql "/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot"
  • funcsave mampsql

Increase max_allowed_packets

  • Create the file: touch /Applications/MAMP/Library/my.cnf
  • Write the first line: echo "[mysqld]" >> /Applications/MAMP/Library/my.cnf
  • Write the second line: echo "max_allowed_packet=64M" >> /Applications/MAMP/Library/my.cnf
  • Restart MAMP

Check the value:

  • mampsql
  • SHOW VARIABLES LIKE 'max_allowed_packet';

Divide the value by 1048576 (1024x1024) and verify it's set to the value in the second line above

Enable Virtual Hosts

  • Edit httpd.conf: vi /Applications/MAMP/conf/apache/httpd.conf
  • Find the right line: Press /, then type/paste # Virtual hosts
  • Uncomment the next line #Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Enable MySql

  • sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
  • sudo mkdir /var/mysql
  • sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Installing a Drupal Site

Create the database

  • Go to: localhost/phpMyAdmin
  • Create the database
  • Import existing database

Clone the code base

  • git clone <repo>

Add the site to /etc/hosts

sudo vi /etc/hosts

Add the vhost to /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

vi /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/path/to/docroot"
    ServerName loc.domain.tld
</VirtualHost>

Restart MAMP

Configure database settings in settings.php and settings.local.php

@Todo

Install Multiple Versions of Drush

Follow the next steps for each version of Drush you need to install

  • cd /usr/local/bin
  • mkdir drush-9
  • cd drush-9
  • composer require drush/drush:^9
  • cd ..
  • ln -s drush-9/vendor/bin/drush drush9

If you do this for versions 7-9, you'll be able to run any of the following: drush7 status drush8 status drush9 status

Create Shell Script to Automatically Select Drush Version Based on Git Config

  • cd /usr/local/bin
  • vi drush
  • paste the following
#!/bin/sh
version=$(git config --get drush.version)
if [ "$version" = '7' ];
then
    drush7 "$@"
elif [ "$version" = '8' ];
then
    drush8 "$@"
else
    drush9 "$@"
fi
  • Save the file
  • Make the script executable chmod +x drush

This makes drush 9 the default when we type a command like "drush --version". In order to use Drush 7 (or 8), we need to set a configuration variable in the git repo of the project that should use it.

Set Drush 7 (or 8) as the Required Version for a Project

  • cd /path/to/project
  • git config drush.version 7
  • drush --version (to see which version is active)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment