Pristine – ZSH Theme

A while back I posted about Amuse my prompt theme for ZSH targeting oh-my-zsh. Since this was a much appreciated theme, I would like to share another theme, Pristine, that I have created.

However, I recently switched to using Prezto. This is because it felt like a more minimalistic configuration framework for ZSH. I also wanted to get faster load times. I must say my experience has been quite good and I really like it. Obviously there are pros and cons but I digress.

Needless to say Pristine targets Prezto. It is influenced by and has a lot of similarities with Amuse. However, there are subtle changes that I feel make it more cleaner and simpler. These are the highlights of Pristine :

  1. It tells you which branch you are on if the current working directory is a git repository.
  2. It indicates the git status of the repository to highlight whether there are any changes by using a green tick (✔) for no changes or a red cross (✗) for uncommitted changes.
  3. It keeps the prompt where you type on a new line with a preceding $ sign, to make more space for typing commands.
  4. It displays both ruby & node versions in use currently on the right. I find this very useful since I often work with both.
  5. It also modifies the spell correction prompt offered by ZSH to highlight the spelling error more prominently.

Here is Pristine :

function prompt_pristine_precmd {
  git-info
  node-info
  ruby-info
}

function prompt_pristine_setup {
  setopt LOCAL_OPTIONS
  unsetopt XTRACE KSH_ARRAYS
  prompt_opts=(cr percent subst)

# Load required functions.
  autoload -Uz add-zsh-hook

# Add hook for calling git-info before each command.
  add-zsh-hook precmd prompt_pristine_precmd

# Set git-info parameters.
  zstyle ':prezto:module:git:info' verbose 'yes'
  zstyle ':prezto:module:git:info:action' format ' +%s'
  zstyle ':prezto:module:git:info:branch' format '%F{magenta}%b%f'
  zstyle ':prezto:module:git:info:commit' format ' %F{white}%.7c%f'
  zstyle ':prezto:module:git:info:indexed' format ' '
  zstyle ':prezto:module:git:info:unindexed' format ' '
  zstyle ':prezto:module:git:info:untracked' format ' '
  zstyle ':prezto:module:git:info:clean' format ' %F{green}✔%f'
  zstyle ':prezto:module:git:info:dirty' format ' %F{red}✗%f'
  zstyle ':prezto:module:git:info:keys' format \
         'prompt' ' on $(coalesce "%b" "%p" "%c")${git_info[rprompt]}%s' \
         'rprompt' '%C%D'

# Set ruby-info parameters.
  zstyle ':prezto:module:ruby:info:version' format ' %F{red}ruby-%v%f'

# Set node-info parameters.
  zstyle ':prezto:module:node:info:version' format ' %F{red}node-%v%f'

# Define prompts.
  PROMPT='%F{green}%~%f${(e)git_info[prompt]}
$ '
  RPROMPT='${node_info[version]},${ruby_info[version]}'
  SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}

function prompt_pristine_preview {
  local +h PROMPT='%# '
  local +h RPROMPT=''
  local +h SPROMPT=''

  prompt_preview_theme 'pristine' "$@"
}

prompt_pristine_setup "$@"

And this is what it looks like :

Image
Pristine.

Installation: In order to use Pristine you need to add git, ruby and node modules to be loaded and set your theme to pristine in your ~/.zpreztorc.

I really like it, and I hope you guys do too!

comments powered by Disqus