Zsh Setup (Fall 2021)

Software tutorials of interest.
Post Reply
Message
Author
jstenner
Site Admin
Posts: 87
Joined: Wed Jan 27, 2010 7:33 pm

Zsh Setup (Fall 2021)

#1 Post by jstenner »

Wanna do cool stuff with your computer? Wanna work with open source software? Have a folder with 1440 images you need to rename quickly? You'll need to use the command line.

The command line, also known as "the shell" is accessed on the Mac using an application in the /Applications/Utilities directory called "Terminal". It works great, but there is a more feature-rich, and free version called iTerm2 that a lot of people like to use. Configuring your shell is a personal preference issue, but at a base level the modifications below are a good starting point. You'll probably want auto-completions and suggestions, syntax-highlighting, etc. With Catalina, Apple changed the default shell from bash to zsh. Our lab computers are from 2013, so there were some adjustments that had to be made to accommodate this change. If you're setting up your personal computer and it's fairly new, some of the stuff we do below may not be necessary (e.g. #1). We've installed the Mac package-manager called Homebrew in FAC302, so you'd need to do that if you want to set up your personal computer. Because the lab is a multi-user environment, we added a usergroup called "brew", and you wouldn't need to do that on your own machine (see #3). Otherwise, this is a pretty standard setup for most uses circa 2021.

1. Check Terminal Preferences->General and set zsh as shell if it's not already set as default.
2. Install iTerm2 if it's not already installed. https://iterm2.com/
3. <FOR ADMIN ONLY>Open Preferences->Users&Groups-> authenticate as admin->check student account as member of "brew" group.
4. Change directories to your home with (or, just "cd"):

Code: Select all

cd ~
5. Install Oh My ZSH with:

Code: Select all

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
6. If you're getting some permissions errors on the lab computers, add ZSH_DISABLE_COMPFIX="true" before you source oh-my-zsh in .zshrc.
7. Install Powerline fonts. These allow special characters to show up in oh-my-zsh themes like Agnoster.

Code: Select all

git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
8. iTerm2->Preferences->Profiles->Text->Font  -- set to your preferred Powerline font (e.g. Meslo LG M DZ for Powerline).
9. Install "antigen" oh-my-zsh plugin manager with Homebrew (already installed on lab computers):

Code: Select all

brew install antigen
10. Configure .zshrc with antigen. Add this to your .zshrc using either pico (Mac) or nano (Linux):

Code: Select all

# Configure Antigen ZSH plugin manager.
source $(brew --prefix)/share/antigen/antigen.zsh

# Load Antigen configurations
antigen init ~/.antigenrc
11. Create an antigen configuration file with:

Code: Select all

pico .antigenrc
12. Put this in your .antigenrc:

Code: Select all

# Load the oh-my-zsh's library
antigen use oh-my-zsh

# Load bundles from the default repo (oh-my-zsh)
antigen bundle git
antigen bundle command-not-found

# Load bundles from external repos
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen bundle osx

# Load your favorite theme. With antigen you can change these on they fly with
# commands like: antigen theme robbyrussell
# For themes see: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 
antigen theme agnoster

# Tell antigen that you're done
antigen apply
13. Now, either open a new terminal or source your .zshrc

Code: Select all

source .zshrc
14. That should do it. There are a lot of good tutorials to get you going at the terminal. I have added a ZSH Tutorial to a playlist for my Experiments in ARTificial Intelligence class. To view it, you need to login to UF LinkedIn Learning HERE, then the link to the playlist should work for you HERE. See Learning Zsh.
Zsh_iTerm2.jpg
The master of disaster!

Post Reply