Skip to content

Instantly share code, notes, and snippets.

@albogdano
Last active September 22, 2017 09:34
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save albogdano/10368878 to your computer and use it in GitHub Desktop.
My zsh themes
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
#
# Oh My Zsh! theme
#
setopt promptsubst
autoload -U add-zsh-hook
ROOT_ICON_COLOR=$FG[111]
MACHINE_NAME_COLOR=$FG[208]
PROMPT_SUCCESS_COLOR=$FG[103]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
PROMPT_PROMPT=$FG[255]
GIT_DIRTY_COLOR=$FG[124]
GIT_CLEAN_COLOR=$FG[148]
GIT_PROMPT_INFO=$FG[148]
# Hash
ROOT_ICON="# "
if [[ $EUID -ne 0 ]] ; then
ROOT_ICON=""
fi
PROMPT='%{$ROOT_ICON_COLOR%}$ROOT_ICON%{$reset_color%}%{$MACHINE_NAME_COLOR%}⎔ %{$reset_color%}%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}$ %{$reset_color%}'
RPS1="${return_code} $FG[145]☰ %*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="["
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%}]"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$rset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[103]%}✱%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[103]%}✖%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[103]%}➜%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$FG[103]%}═%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$FG[103]%}✭%{$reset_color%}"
#
# Zsh Prezto theme - based on Sorin's theme
#
# Author: albogdano
#
# Load dependencies.
pmodload 'helper'
function prompt_sorin_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
_prompt_sorin_pwd="$MATCH"
unset MATCH
else
_prompt_sorin_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
fi
}
function prompt_sorin_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Format PWD.
prompt_sorin_pwd
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
# Get Node info
if (( $+functions[node-info] )); then
node-info
fi
# Get Ruby info
if (( $+functions[ruby-info] )); then
ruby-info
fi
# Get Virtual env info
if (( $+functions[python-info] )); then
python-info
fi
}
function prompt_sorin_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_sorin_precmd
# root indicating hash
ROOT_ICON="%F{160}#%f"
if [[ $EUID -ne 0 ]] ; then
ROOT_ICON="$"
fi
# Set editor-info parameters.
#zstyle ':prezto:module:editor:info:completing' format '%B%F{242}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format ' '$ROOT_ICON
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format ' '$ROOT_ICON
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
zstyle ':prezto:module:git:info:added' format ' %%B%F{028}✚%f%%b'
zstyle ':prezto:module:git:info:ahead' format ' %%B%F{028}≫%f%%b'
zstyle ':prezto:module:git:info:behind' format ' %%B%F{088}≪%f%%b'
zstyle ':prezto:module:git:info:branch' format '%F{028}%b%f'
zstyle ':prezto:module:git:info:commit' format ':%F{028}%.7c%f'
zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f'
zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}⬓%f%%b'
zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◆%f%%b'
zstyle ':prezto:module:git:info:dirty' format ' %F{red}✱%f'
zstyle ':prezto:module:git:info:clean' format ' %F{028}✔%f'
zstyle ':prezto:module:git:info:keys' format \
'prompt' ' [$(coalesce "%b" "%p" "%C" "%D")%s%A%B%S%a%d%m%r%U%u%C%D%p]' \
'rprompt' ''
# Define prompts.
PROMPT='%F{208}⎔%f %F{024}%1~%f${git_info:+${(e)git_info[prompt]}}%(!. %F{red}#%f.)${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%(?:: %F{gray}⏎%f)${VIM:+" %F{028}V%f"} ${git_info[rprompt]} %F{024}%~%f %F{242}☰ %*%f'
SPROMPT='zsh: correct %F{red}%R%f to %F{028}%r%f [y/N]? '
}
prompt_sorin_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment