Skip to content

Instantly share code, notes, and snippets.

@wmayner
Last active April 29, 2020 20:18
Show Gist options
  • Save wmayner/903d51fe927d75657fe954e5503dcd24 to your computer and use it in GitHub Desktop.
Save wmayner/903d51fe927d75657fe954e5503dcd24 to your computer and use it in GitHub Desktop.
Brief guide on how to set up a new Mac

Set up a new Mac

zsh

zsh is a more useful shell than bash, in my opinion, so we'll change your default shell from bash to zsh.

Follow instructions here: https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH#macos

Note: zsh uses the ~/.zshrc file instead of ~/.bash_profile, so you should move anything that you need in your ~.bash_profile to the ~.zshrc.

oh-my-zsh

This supplies a bunch of useful zsh features, and gives you a basic .zshrc that sets them up.

Run the command shown here: https://github.com/ohmyzsh/ohmyzsh#via-curl

Once you've installed oh-my-zsh, we'll add some plugins. In your .zshrc, there should now be a line that starts with plugins=. Replace that line with the following:

plugins=(brew command-not-found git github history-substring-search fasd osx python)

Each name inside the parenthesis (separated by spaces) is the name of an oh-my-zsh plugin.

In particular, the history-substring-search plugin is very useful: it lets you type in any part of a command and then cycle through matches from your command history.

For example, if a long time ago you typed a command rsync -vah ~/long/path/name/ ~/another/long/path/ and you want to run it again, you could do the following:

  1. Type syn
  2. Press the up arrow
  3. Keep pressing the up arrow, cycling through all commands in your history that contain the substring syn until you get to the long rsync command
  4. Press enter

This is much easier than repeatedly pressing the up arrow to cycle through your entire command history until you reach the desired command. See here for more information.

Python

I use the miniconda3 distribution from Anaconda: https://docs.conda.io/en/latest/miniconda.html

Once you've installed Miniconda, add its binaries to the PATH by adding this line to your .zshrc:

export PATH="$HOME/miniconda3/bin:$PATH"

Now confirm that you're using the Miniconda Python:

  1. Open a new shell (a new Terminal tab or Window)
  2. Run which python
  3. Check that the output is a path that has miniconda3 in it

powerline

This will make your command line prompt nice.

  1. pip install powerline-status
  2. Find out where powerline was installed by running python and then running the following in the Python REPL:
    >>> import powerline
    >>> powerline
    This should print a path to the powerline module, which you'll use below.
  3. Put these lines in your .zshrc:
    powerline-daemon --quiet
    source "<path_to_powerline>/bindings/zsh/powerline.zsh"
    where <path_to_powerline> is replaced with the path that you found in the previous step.
  4. Install powerline fonts:
    git clone https://github.com/powerline/fonts
    cd fonts
    ./install.sh
  5. In iTerm2, set your font to be Roboto Mono for Powerline (or any other font that has "for Powerline" in the name).

fasd

This will let you jump around your filesystem on the command line instead of having to laboriously type out paths. See here for more info.

  1. Install it:
    git clone https://github.com/clvv/fasd
    cd fasd
    make install
  2. Put these lines in your .zshrc:
    # Initialize fasd
    eval "$(fasd --init auto)"
    
    # Use `j` to jump around
    alias j='fasd_cd -d'

There's a lot more to it than this. Check the README to see what else it can do.

Slate

This will let you efficiently arrange windows with keyboard shortcuts, instead of having to click and drag to move and resize windows.

  1. Download and install the Slate window manager here: https://github.com/jigish/slate#installing-slate. Important: Note the part about turning on the Accessibility API; this is needed to allow Slate to control your windows.
  2. Configure slate. Slate uses a configuration file that sets up key bindings that arrange your windows. My configuration file is here: https://github.com/wmayner/dotfiles/blob/master/slate/slate.symlink. It has comments in it that describe the key bindings and what they do. Download this and move it to ~/.slate by running mv <path_to_downloaded_file> ~/.slate.
  3. Run Slate and make sure it runs on startup by clicking its icon in the menu bar and checking that option in the dropdown menu.

Check my dotfiles

This is the basic setup. There's a lot of other stuff in my dotfiles repo which you might want. Also, you can check my setup against yours to debug it in case something here isn't working. In particular, check the .zshrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment