Skip to content

Instantly share code, notes, and snippets.

@lcrespom
Last active December 16, 2019 14:58
Show Gist options
  • Select an option

  • Save lcrespom/f57c88490c9a55721bb2a48d7cacd692 to your computer and use it in GitHub Desktop.

Select an option

Save lcrespom/f57c88490c9a55721bb2a48d7cacd692 to your computer and use it in GitHub Desktop.

Installing and customizing oh-my-zsh

Install oh-my-zsh

curl -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash

Install autosuggestions and syntax-highlight plugins

From the zsh shell:

# Install syntax highlight plugin
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# Install autosuggestions plugin
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Optionally, delete the .git directory in both plugins to make room.

Configure .zshrc

Agnoster theme

Ensure the font supports the special characters, e.g. Fira Mono for Powerline. The Powerline fonts can be downloaded from https://github.com/powerline/fonts, and installed by double-clicking on the font file.

Enable the theme by editing .zshrc and locating the line starting with ZSH_THEME=...:

ZSH_THEME="agnoster"

Plugins

In .zshrc, locate the line starting with plugins=( and add the installed plugins:

plugins=(
  git
  zsh-syntax-highlighting
  zsh-autosuggestions
)

Customize prompt colors

Slightly change the code of Agnoster theme segments. In file ~/.oh-my-zsh/themes/agnoster.zsh-theme, update the prompt_context and prompt_dir functions:

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    # prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
    prompt_segment cyan black "%n@%m"
  fi
}

# ...

# Dir: current working directory
prompt_dir() {
  # prompt_segment blue $CURRENT_FG '%~'
  prompt_segment blue white '%~' # Or '%2d' for the last 2 directories
}

Add z to jumpt to directories

Check out the z tool to quickly jump across directories. Download it and source it from ~/.zshrc.

Add the fantastic Mistory plugin

Check its repository at: https://github.com/lcrespom/oh-my-zsh-history-popup

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