My Interesting Zsh Prompt

Published on November 8, 2014 MacOS Shell

Yes, this is outdated - I’ve now moved on to use Oh My Zsh, mostly with the default setup to keep things simple.

I already did a post on the steps I took to set up my new macbook for development.

After that post I started using Zsh more and more, and came to realize how much better it could become with some tweaking.

edges -

If you just want to replicate this just follow these two steps:

  1. Install antigen:
  2. Use this .zshrc file.


The first thing I recommend is using antigen. It is something like Pathogen for Vim, a configuration/plugin manager for Zsh.

It works great with Oh My Zsh, which should also be your first step into setting up your zsh shell.

Once antigen is installed the first part of the .zshrc file is setting that up and loading Oh My Zsh.

# Antigen — A zsh plugin manager
source ~/antigen.zsh

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

Now load all the plugins (bundles) you want, the great thing about antigen is that you can add any plugin from any repository/url:

antigen bundles <<EOBUNDLES




Automaticcally list directory on cd

I find this really useful, it triggers an ls whenever you cd into a directory.

# Automatically list directory contents on `cd`.
auto-ls () { ls; }
chpwd_functions=( auto-ls $chpwd_functions )

We add the history substring plugin to enable fish style search, first add the plugin: zsh-users/zsh-history-substring-search.

Now we can bind the search to Up/Down arrows:

# bind UP and DOWN arrow keys
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down

### Fish-style autosuggest

A great plugin that shows the first suggestion in light grey as suggestion as you type. It might have some small bugs but for the most part it works great.

Add the plugin: tarruda/zsh-autosuggestions

Set it up:

# Setup suggestions
zle-line-init() {
    zle autosuggest-start
zle -N zle-line-init