Skip to content

Instantly share code, notes, and snippets.

@cherring
Created June 15, 2018 11:44
Show Gist options
  • Save cherring/486d4c51295300d45a014daa45685671 to your computer and use it in GitHub Desktop.
Save cherring/486d4c51295300d45a014daa45685671 to your computer and use it in GitHub Desktop.
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Add additional directories to load prezto modules from
# zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib
# Set the Zsh modules to load (man zshmodules).
# zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
# zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
'environment' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'utility' \
'ssh' \
'completion' \
'homebrew' \
'osx' \
'ruby' \
'rails' \
'git' \
'syntax-highlighting' \
'history-substring-search' \
'prompt'
#
# Autosuggestions
#
# Set the query found color.
# zstyle ':prezto:module:autosuggestions:color' found ''
#
# Completions
#
# Set the entries to ignore in static */etc/hosts* for host completion.
# zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \
# '0.0.0.0' '127.0.0.1'
#
# Editor
#
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'vi'
# Auto convert .... to ../..
# zstyle ':prezto:module:editor' dot-expansion 'yes'
# Allow the zsh prompt context to be shown.
#zstyle ':prezto:module:editor' ps-context 'yes'
#
# Git
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
# zstyle ':prezto:module:git:status:ignore' submodules 'all'
#
# GNU Utility
#
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
#
# History Substring Search
#
# Set the query found color.
# zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
# zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
# zstyle ':prezto:module:history-substring-search' globbing-flags ''
#
# macOS
#
# Set the keyword used by `mand` to open man pages in Dash.app
# zstyle ':prezto:module:osx:man' dash-keyword 'manpages'
#
# Pacman
#
# Set the Pacman frontend.
# zstyle ':prezto:module:pacman' frontend 'yaourt'
#
# Prompt
#
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'paradox'
# Set the working directory prompt display length.
# By default, it is set to 'short'. Set it to 'long' (without '~' expansion)
# for longer or 'full' (with '~' expansion) for even longer prompt display.
# zstyle ':prezto:module:prompt' pwd-length 'short'
# Set the prompt to display the return code along with an indicator for non-zero
# return codes. This is not supported by all prompts.
# zstyle ':prezto:module:prompt' show-return-val 'yes'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
#
# Python
#
# Auto switch the Python virtualenv on directory change.
# zstyle ':prezto:module:python:virtualenv' auto-switch 'yes'
# Automatically initialize virtualenvwrapper if pre-requisites are met.
# zstyle ':prezto:module:python:virtualenv' initialize 'yes'
#
# Screen
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'
#
# SSH
#
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
#
# Syntax Highlighting
#
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
# zstyle ':prezto:module:syntax-highlighting' highlighters \
# 'main' \
# 'brackets' \
# 'pattern' \
# 'line' \
# 'cursor' \
# 'root'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
#
# Set syntax pattern styles.
# zstyle ':prezto:module:syntax-highlighting' pattern \
# 'rm*-rf*' 'fg=white,bold,bg=red'
#
# Terminal
#
# Auto set the tab and window titles.
# zstyle ':prezto:module:terminal' auto-title 'yes'
# Set the window title format.
# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'
# Set the tab title format.
# zstyle ':prezto:module:terminal:tab-title' format '%m: %s'
# Set the terminal multiplexer title format.
# zstyle ':prezto:module:terminal:multiplexer-title' format '%s'
#
# Tmux
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
# Integrate with iTerm2.
# zstyle ':prezto:module:tmux:iterm' integrate 'yes'
# Set the default session name:
# zstyle ':prezto:module:tmux:session' name 'YOUR DEFAULT SESSION NAME'
#
# Utility
#
# Enabled safe options. This aliases cp, ln, mv and rm so that they prompt
# before deleting or overwriting files. Set to 'no' to disable this safer
# behavior.
# zstyle ':prezto:module:utility' safe-ops 'yes'
# ~/.zprezto/modules/prompt/functions/prompt_paradox_setup
#
# A two-line, Powerline-inspired theme that displays contextual information.
#
# This theme requires a patched Powerline font, get them from
# https://github.com/Lokaltog/powerline-fonts.
#
# Authors:
# Isaac Wolkerstorfer <i@agnoster.net>
# Jeff Sandberg <paradox460@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Patrick Bos <egpbos@gmail.com>
#
# Screenshots:
# http://i.imgur.com/0XIWX.png
#
# Load dependencies.
pmodload 'helper'
# Define variables.
_prompt_paradox_current_bg='NONE'
_prompt_paradox_segment_separator=''
_prompt_paradox_start_time=$SECONDS
function prompt_paradox_start_segment {
local bg fg
[[ -n "$1" ]] && bg="%K{$1}" || bg="%k"
[[ -n "$2" ]] && fg="%F{$2}" || fg="%f"
if [[ "$_prompt_paradox_current_bg" != 'NONE' && "$1" != "$_prompt_paradox_current_bg" ]]; then
print -n " $bg%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator$fg "
else
print -n "$bg$fg "
fi
_prompt_paradox_current_bg="$1"
[[ -n "$3" ]] && print -n "$3"
}
function prompt_paradox_end_segment {
if [[ -n "$_prompt_paradox_current_bg" ]]; then
print -n " %k%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator"
else
print -n "%k"
fi
print -n "%f"
_prompt_paradox_current_bg=''
}
function prompt_paradox_build_prompt {
prompt_paradox_start_segment black default '%(?::%F{red}✘ )%(!:%F{yellow}⚡ :)%(1j:%F{cyan}⚙ :)%F{blue}%n%F{red}@%F{green}%m%f'
prompt_paradox_start_segment blue black '$_prompt_paradox_pwd'
if [[ -n "$git_info" ]]; then
prompt_paradox_start_segment green black '${(e)git_info[ref]}${(e)git_info[status]}'
fi
if [[ -n "$python_info" ]]; then
prompt_paradox_start_segment white black '${(e)python_info[virtualenv]}'
fi
prompt_paradox_end_segment
}
prompt_paradox_print_elapsed_time() {
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
local hours minutes seconds remainder
if (( end_time >= 3600 )); then
hours=$(( end_time / 3600 ))
remainder=$(( end_time % 3600 ))
minutes=$(( remainder / 60 ))
seconds=$(( remainder % 60 ))
print -P "%B%F{red}>>> elapsed time ${hours}h${minutes}m${seconds}s%b"
elif (( end_time >= 60 )); then
minutes=$(( end_time / 60 ))
seconds=$(( end_time % 60 ))
print -P "%B%F{yellow}>>> elapsed time ${minutes}m${seconds}s%b"
elif (( end_time > 10 )); then
print -P "%B%F{green}>>> elapsed time ${end_time}s%b"
fi
}
function prompt_paradox_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Format PWD.
_prompt_paradox_pwd=$(prompt-pwd)
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
# Get Python environment information.
if (( $+functions[python-info] )); then
python-info
fi
# Get ruby information
if (( $+functions[ruby-info] )); then
ruby-info
fi
# Calculate and print the elapsed time.
prompt_paradox_print_elapsed_time
}
function prompt_paradox_preexec {
_prompt_paradox_start_time="$SECONDS"
}
function prompt_paradox_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent sp subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Add hook for calling git-info before each command.
add-zsh-hook preexec prompt_paradox_preexec
add-zsh-hook precmd prompt_paradox_precmd
# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{blue}❯%f%b'
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{red}❮%f%b'
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:action' format ' ⁝ %s'
zstyle ':prezto:module:git:info:added' format ' ✚'
zstyle ':prezto:module:git:info:ahead' format ' ⬆'
zstyle ':prezto:module:git:info:behind' format ' ⬇'
zstyle ':prezto:module:git:info:branch' format ' %b'
zstyle ':prezto:module:git:info:commit' format '➦ %.7c'
zstyle ':prezto:module:git:info:deleted' format ' ✖'
zstyle ':prezto:module:git:info:dirty' format ' ⁝'
zstyle ':prezto:module:git:info:modified' format ' ✱'
zstyle ':prezto:module:git:info:position' format '%p'
zstyle ':prezto:module:git:info:renamed' format ' ➙'
zstyle ':prezto:module:git:info:stashed' format ' S'
zstyle ':prezto:module:git:info:unmerged' format ' ═'
zstyle ':prezto:module:git:info:untracked' format ' ?'
zstyle ':prezto:module:git:info:keys' format \
'ref' '$(coalesce "%b" "%p" "%c")' \
'status' '%s%D%A%B%S%a%d%m%r%U%u'
# %v - virtualenv name.
zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v'
# ruby info (rvm, rbenv)
zstyle ':prezto:module:ruby:info:version' format '[%v]'
# Define prompts.
PROMPT='
${(e)$(prompt_paradox_build_prompt)}
${editor_info[keymap]} '
RPROMPT='%F{blue}${ruby_info[version]}'
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_paradox_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment