Skip to content

Instantly share code, notes, and snippets.

@ModulesUnraveled
Last active December 13, 2023 15:37
Show Gist options
  • Save ModulesUnraveled/d0746a0a1c14ed69414ddc4a551b60b4 to your computer and use it in GitHub Desktop.
Save ModulesUnraveled/d0746a0a1c14ed69414ddc4a551b60b4 to your computer and use it in GitHub Desktop.
Setup a new (M1) mac

Before anything else:

  • 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
  • Keynote: Presentations
  • Numbers: Spreadsheets
  • Pages: Documents
  • Hidden Me: Hide desktop icons (for screen sharing and the like)
  • Slack: Work chat app
  • 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
    • If the above doesn't work, download directly from here: Apple
  • Git Config
    • git config --global user.name "Your Name"
    • git config --global user.email "[email protected]"
  • Homebrew
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • Add the arm (M1 macs) directory to your path for bash
    • PATH=/opt/homebrew/bin:$PATH
  • wget
    • brew install wget
  • Fish: Bash replacement
    • brew install fish (Install it)
    • Add /opt/homebrew/bin/fish to /etc/shells
    • chsh -s /opt/homebrew/bin (Set it as default)
    • fish (Use it now)
  • Add the arm (M1 macs) directory to your path for fish
    • set -U fish_user_paths /opt/homebrew/bin/fish $fish_user_paths
  • Oh my Fish: Addons for Fish
    • curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish
  • Eden: Fish Theme:
    • omf install eden
  • NVM for Fish
    • omf install nvm
    • You have to install nvm itself separately (the curl method works fine under Fish too).
    • Install whatever version you want
      • nvm install 14
    • Set 14.15.1 (or another version) as default
      • nvm alias default 14.15.1
  • Set Fish theme settings
    • fish_config
  • Set directoryies to a legible color
    • set -Ux LSCOLORS gxfxbEaEBxxEhEhBaDaCaD

Automatically set node version if a .nvmrc file is present

Checkout the official docs and follow the instructions for your shell: https://github.com/nvm-sh/nvm#automatically-call-nvm-use

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

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

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 --apple-use-keychain ~/.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

Yarn

  • brew install yarn

Extensions

Install shell extension

  • Open Visual Studio Code and access the Command Palette (⇧⌘P) and start typing "shell command" and select option "Shell Command: Install ‘code’ command in PATH".
  • After that you’re able to start a new terminal window, change into your project directory and use code . to open the current directory in Visual Studio Code.

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],
  // Always show the folding controls
  "editor.showFoldingControls": "always",
  // Hide the Editor, Search, Extensions, 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",
  // Focus on files in the sidebar when selected in the main editor window
  // But don't move the sidebar scroll position to them
  "explorer.autoReveal": "focusNoScroll",
  // 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,
  // Colorize bracket pairs
  "editor.bracketPairColorization.enabled": true,
  "editor.guides.bracketPairs": "active",
  //----------------------//
  // Code Writing Helpers //
  //----------------------//
  // Enable auto-closing of tags in all file types
  "auto-close-tag.activationOnLanguage": ["*"],
  // Set tabs to equal two spaces
  "editor.tabSize": 4,
  // Tell emmet to work on .js files (not just when specified as react)
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  },
  //-----------------------------//
  // 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,
  // Turn on Auto Fix for all providers (including eslint)
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  },
  // Use prettier to format code
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[markdown]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[scss]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  // Format json with the json formatter
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  // 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 //
  //------------------//
  // Use iTerm when opening current project in terminal (Cmd + Shift + C)
  "terminal.external.osxExec": "iTerm.app",
  // Stop suggesting to search parsers for unknown extensions
  "extensions.ignoreRecommendations": true,
  // Stop asking if I trust files
  "security.workspace.trust.untrustedFiles": "open",
  // Preferred Terminal
  "terminal.integrated.defaultProfile.osx": "fish",
  // Preferred font and ligatures
  "editor.fontFamily": "Fira Code",
  // What do these mean? See: https://github.com/tonsky/FiraCode/issues/1203
  "editor.fontLigatures": "'ss01', 'ss02', 'ss04', 'ss06', 'ss07', 'ss09', 'zero', 'cv14', 'cv22', 'cv24', 'cv25', 'cv26', 'cv28', 'cv30'",
    "better-comments.tags": [
    {
      "tag": "! ",
      "color": "#FF2D00",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    },
    {
      "tag": "? ",
      "color": "#61dcef",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    },
    {
      "tag": "* ",
      "color": "#98C379",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    },
    {
      "tag": "> ",
      "color": "#fff381",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    },
    {
      "tag": "TODO ",
      "color": "#cb00e6",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    },
    {
      // for documentation
      "tag": ": ",
      "color": "#cbdadf",
      "strikethrough": false,
      "underline": false,
      "backgroundColor": "transparent",
      "bold": false,
      "italic": false
    }
  ],
  "todo-tree.highlights.customHighlight": {
    "LINK": {
      "background": "#334bff",
      "foreground": "#fff"
    }
  },
  "todo-tree.regex.regex": "(//|\\*|<!--)\\s+($TAGS)\\s+",
  "todo-tree.general.tags": [
    "BUG",
    "HACK",
    "FIXME",
    "TODO",
    "LINK",
    "?",
    "*",
    ">",
    "!"
  ],
  "todo-tree.filtering.excludedWorkspaces": ["docs_site/*, node_modules/*"],
  "todo-tree.highlights.defaultHighlight": {
    "foreground": "#fff",
    "background": "#cb00e6"
  },
  // Custom dictionary
  "cSpell.userWords": [
    // This will build up as you add words.
  ],
  "window.zoomLevel": 1
}
#!/bin/sh
# Installation:
# - Copy this file to /usr/local/bin/4k
# - Make it executable `chmod +x /usr/local/bin/4k`
#
# Use:
# - Run `4k <command>`
# - If you haven't configured that command for the current project
# you'll be asked to configure it now
# - If you have already configured it, it'll be run
#
# Example:
# - `4k rebuild` can be configure to run:
# - `aquifer run rebuild` in an old D7 site
# - `gulp run -t rebuild` in a project that uses gulp for build tasks
# - Any other repo-specific script that accomplishes the task
command=$(git config --get alias.$@)
if [ "$command" = '' ];
then
echo "No command"
read -p "Do you want to enter it now? [y/n]: " -n 1 -r
echo "\n"
if [[ $REPLY =~ ^[Yy]$ ]]
then
read -p "Enter the command for $@: " input;
echo "git config alias.$@ $input"
git config alias.$@ "$input"
else
echo "Okie doke. Nothing saved."
fi
else
echo "\nRunning \"$command\"\n"
$command
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment