Skip to content

Instantly share code, notes, and snippets.

@AtmaMani
Last active October 23, 2020 23:00
Show Gist options
  • Save AtmaMani/6613cfe7a43d001ea176b52befa8634f to your computer and use it in GitHub Desktop.
Save AtmaMani/6613cfe7a43d001ea176b52befa8634f to your computer and use it in GitHub Desktop.
custom-zsh-profile.md

Newer Mac OS uses ZSH instead of bash. This wiki will talk through setting it up with nice features such as autocomplete, colorized ls, git & conda aware prompts etc.

Steps

  1. After upgrading to zsh, confirm you have it by typing zsh in terminal.
  2. Install a framework such as Oh my zsh which will simplify the whole process. Rest of steps assume you have it running. As of today, you can install it by running

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

Restart terminal.

  1. Look at available plugins and enable the ones you need. You can do so by editing the .zshrc file as

subl ~/.zshrc

Add necessary plugins (separated just by a single space or new line) to the plugins tuple. I added git pipenv pip zsh-interactive-cd. Restart terminal.

  1. Add conda by pasting the following. Note you may have to edit the username accordingly. To know your username, type $ whoami and use what it returns.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/username/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/username/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/username/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Restart terminal. This will prefix the env name in parenthesis before your terminal.

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