Search
⌘K
    to navigateEnterto select Escto close

    Setting up macOS

    Enable Rosetta for Terminal on M1 Mac

    If Rosetta 2 is not installed by default in your M1 Mac, then open the pre-installed Terminal app and run the following command:

    1/usr/sbin/softwareupdate --install-rosetta --agree-to-license

    Rosetta allows us to use apps built for Mac with intel chip.

    Several CLI tools do not have native versions built for the new M1 architecture.

    Enabling them on your native M1 Mac terminal can be frustrating.

    Follow these steps to enable Rosetta:

    • Select the app(Terminal) in the Finder.

    • Right click on the app(Terminal) and select Get Info.

    • In General, check the Open using Rosetta check-box.

    • Close the Terminal Info.

    • Now when you quit the terminal and open it again.

    • If you haven't installed Rosetta yet, then it would prompt you to install it.

    • If the popup shows up, then click on Install button, then enter your user name and password to allow installation to proceed.

    • Close the Terminal and open again.

    • Now we have a special terminal that can install tools with Rosetta translation.

    To verify that you are using a Rosetta terminal, run the following command and it should output i386:

    1arch

    The native terminal without Rosetta would output arm64 for the above command.

    Moving forward, all commands we ask you to execute should be done in Rosetta enabled terminal.

    Install Xcode

    Check the version of your operating system. If your version number is 10.9 or higher, follow the next step. If your OS X version is less than 10.9, you should consider upgrading your operating system to 10.9 or higher. It's completely free.

    Install Xcode Command Line Developer Tools:

    1xcode-select --install

    Uninstall arm64 brew

    If you have installed brew in the past from the native terminal, it is likely that you have an arm64 build of brew. Having two different builds of brew can cause major problems as the packages with different builds will not be compatible with each other.

    To avoid this problem you need to uninstall your current installation of arm64 brew.

    You can check which build you have by running the following command:

    1which brew

    If your installation of brew is the Intel build, then the command should output /usr/local/bin/brew. If that is the case you can skip installing brew and just update your current installation by running brew update.

    If your output is /opt/homebrew then your installation of brew is the arm64 build.

    You need to uninstall the arm64 build of brew by running the following command from the native terminal:

    1/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

    Install Intel brew

    Install Homebrew, which is the package manager:

    1/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    Once done, run the below command to ensure that we make use of the HEAD revision:

    1git -C $(brew --repository homebrew/core) checkout master

    Now verify the installation of the brew command:

    1which brew

    The command should output /usr/local/bin/brew, which is the expected path.

    Ensure ZSH is the default shell

    Before going forward, please make sure zsh is your default terminal shell.

    You can run echo $SHELL to see what's the current shell.

    If it's not your default shell, then set it up manually:

    1chsh -s $(which zsh)

    Setting up VSCode

    VSCode, short for Visual Studio Code, can be downloaded and installed from their official website.

    If you're using M1 Mac, then you can opt for Apple Silicon build and download it from their website.

    These are the steps for installation:

    • Download Visual Studio Code for macOS.
    • Open the browser's download list and locate the downloaded archive.
    • Select the 'magnifying glass' icon to open the archive in Finder.
    • Drag Visual Studio Code.app to the Applications folder, making it available in the macOS Launchpad.
    • Add VSCode to your Dock by right-clicking on the icon to bring up the context menu and choosing Options > Keep in Dock.

    Most of us in BigBinary use VSCode as our daily tool for editing files. Thus if you ever wanted to check out how to do something faster or better in VSCode, then your colleagues are always there to help you out!

    Enable code command

    In order to run VSCode from terminal, we need to add code command in to our PATH.

    There are two ways to do this.

    First method is from VSCode itself:

    • Go to VSCode application.

    • Press "Shift" button, "Command" button and "p".

    • Type > shell command.

    • Select "Install 'code' command in PATH.

    • VSCode will give you a prompt. Click "Ok".

    • VSCode will ask for your laptop password. provide password.

    Or you can add it manually from your terminal itself without opening VSCode, like mentioned below.

    Note: You don't need to run below command if you had already added to PATH from VSCode.

    For Zsh users, run the following command from your terminal:

    1cat << EOF >> ~/.zshrc
    2# Add Visual Studio Code (code)
    3export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
    4EOF
    

    Since we have made changes to .zshrc we need to reload the shell for the changes to take effect. The easiest way to do so is to quit the current terminal and open a new terminal.

    Now let's test if command code is working or not.

    Open terminal and type code dummy.txt and that file should be opening up in VSCode.

    Enabling auto save feature

    Auto Save feature will save your changes after a configured delay or when focus leaves the editor.

    With this option turned on, there is no need to explicitly save the file.

    The easiest way to turn on Auto Save is with the File > Auto Save toggle from menu bar, that turns on and off save option after a delay.

    Other way of enabling this feature, is by appending the following to your user settings and reload. It does the same job:

    1{
    2  // rest of the keys as it was
    3  "files.autoSave": "afterDelay",
    4  "files.autoSaveDelay": 1000
    5}

    Installing Prettier plugin

    To make code more readable and consistent we can install the Prettier plugin.

    This tool works well with Visual Studio Code such that code is automatically formatted every time changes are saved.

    Installing the Prettier Visual Studio Code plugin

    • Hit Cmd+Shift+P on Mac or Ctrl+Shift+P on Linux.
    • Select "Extensions: Install Extensions".
    • Search for Prettier plugin.
    • Click "Install" and then reload VSCode after the installation.
    Run Prettier every time a JavaScript file is saved

    This is also an optional step.

    • Hit Cmd+Shift+P on Mac or Ctrl+Shift+P on Linux.
    • Type "Preferences: Open Workspace Settings".
    • We will see two options.
    • Select the option that has the word JSON.
    • Paste the following content in the Settings file.
    1{
    2  // rest of the keys as it was
    3  "folders": [],
    4  "settings": {},
    5  "[javascript]": {
    6    "editor.formatOnSave": true
    7  }
    8}

    Installing Oh My ZSH

    Oh My Zsh(OMZ) is a delightful, open source, community-driven framework for managing your Zsh configuration.

    It comes bundled with thousands of helpful functions, helpers, plugins, themes, and other goodies that will make you say Oh My ...!.

    Install OMZ:

    1sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

    Now restart your terminal.

    Add OMZ plugins

    To add a new plugin, type the names shown in parentheses below to plugins key, making sure to include a space between each name.

    Add the following at the top of your .zshrc:

    1plugins=(git ruby rails yarn bundler docker docker-compose brew osx z node)

    Restart the terminal for zsh to auto install all the specified plugins.

    If you ever feel that your SHELL is slow in starting, then removing few of these plugins is a good step.

    Install fonts

    Now if you restart your terminal, zsh will auto install all the plugins.

    But most probably your shell prompt would be looking very ugly.

    The issue is that we don't have a good font which contains all the glyphs that are part of our prompt.

    Thus let's install powerline fonts:

    1git clone https://github.com/powerline/fonts.git --depth=1
    2# install the fonts
    3cd fonts
    4./install.sh
    5# clean-up a bit
    6cd ..
    7rm -rf fonts

    Now let's setup the terminal font.

    Open Terminal app, and do the following:

    • Open Terminal > Preferences > Profiles > Text > Change Font.
    • Set it to something that has "for Powerline" in its name.
    • Use Meslo LG DZ for Powerline font.

    Now restart your terminal and you should be seeing a beautiful prompt!

    Installing z for jumping around

    The idea behind z is that it builds a list of your most frequent and recent — "Frecent" — folders.

    It allows you to jump to them quickly in one command, rather than having to tab through a nested folder structure.

    To install it, make sure z is included in the plugins list as mentioned in OMZ plugins section.

    While adding it in OMZ plugins section works for most, some users have trouble getting it to work.

    If that is the case, download z and put it in your home directory so that it’s located at ~/z.sh, like so:

    1curl -o "${HOME}/z.sh" "https://raw.githubusercontent.com/rupa/z/master/z.sh"

    Then, in your .zshrc file, after listing the plugins, include the following and then restart your terminal:

    1. ~/z.sh

    It's time for what you’ve been waiting for. Time to jump around!

    If you type just z in your terminal, it should now show you the locations you’ve visited, along with the Frecency score.

    But let's say that you're using a new laptop/terminal where you haven't traversed to many folders yet. Then there won't be any "frecency" score that z can show.

    Let's do an example to understand how z comes in handy.

    Run the following from your terminal:

    1cd ~/.oh-my-zsh/plugins

    Now the current directory in your terminal should be plugins.

    You can verify your current working directory by running the following command:

    1pwd

    Let's say that everyday as part of your work you need to change pwd into this plugins directory.

    So rather than running the cd ~/.oh-my-zsh/plugins command each time, you could run the following:

    1z plug

    Now your pwd should be ~/.oh-my-zsh/plugins folder.

    Using z we have used one substring part of the path where we wanted to traverse and we've reached that folder.

    In a daily work environment this comes in super handy!

    Note that you may not be able to run the following commands given that your cd history and folders specified may not exist.

    As an example, based on my jumping history, I can do the following.

    1# Takes me to /var/www/mysite/wp-content/themes
    2z themes
    3
    4# Takes me to /var/www/staging/wp-content/themes
    5z staging themes
    6
    7# Takes me to /var/www/mysite/wp-content/plugins
    8z plu
    9
    10# Lists all the paths including "themes" in them.
    11z themes -l
    

    Installing ripgrep

    You can search a keyword/sentence within a directory or file and ripgrep will give your the results almost instantly.

    ripgrep is really fast when compared to other searching tools like find.

    Let's install it:

    1brew install ripgrep

    Great! Now goto any project and search for any keyword like so:

    1rg "keyword"

    Installing Vim

    At one point of your development life, you will rely on vim to get the job done.

    There will be valid cases like say SSH'ing into a server, where vim can be your knight in shining armor.

    Install vim, like so:

    1brew install vim

    Installing Docker

    Docker Engine still hasn't ported a build that natively supports M1 Chips.

    Thus the best way to use Docker will be using Docker Desktop.

    It will provide us with docker as well as docker-compose.

    You can install Docker Desktop for M1 by downloading the application from the official website.

    Once installed docker and docker-compose should be working.

    Installing Node.js

    Different applications use different versions of Node.js.

    Thus it is useful to be able to switch between different versions of Node.js on the fly.

    At BigBinary we use Node Version Manager (nvm), which helps us maintain the correct Node.js version specific to a project, and switch between them without much hassle.

    Installing nvm

    Running the below command on your terminal will install nvm locally:

    1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

    Installing a Node.js version using nvm

    Currently, we use Node.js v16.4.2 in our wheel project. You can install the same version by running the following:

    1nvm install 16.4.2
    2nvm alias default 16.4.2

    If you're not a fan of nvm, then n is a good alternative.

    Installing Yarn

    You shouldn't use npm command in BigBinary projects.

    We make use of yarn to manage JavaScript libraries and tool chains.

    Install it:

    1brew install yarn
    Previous
    Next