Skip to content

Instantly share code, notes, and snippets.

@bitjockey42
Last active May 6, 2016 12:23
Show Gist options
  • Save bitjockey42/0fca4b0ba5f30d73a625ef41670a7c5e to your computer and use it in GitHub Desktop.
Save bitjockey42/0fca4b0ba5f30d73a625ef41670a7c5e to your computer and use it in GitHub Desktop.
#
# Lambda Mod
# A simple theme inspired by lambda from oh-my-zsh and lambda_mod from prezto
#
# Authors:
# AJ (0x414A) <aj@hckr.eml.cc>
# Halfo
# Nicolas A. Tonne <nixo@gmx.com>
#
# Lambda_Mod Authors:
# Brian Tse <briankftse@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
# http://i.imgur.com/V7fzEUg.png
#
pmodload 'helper'
function prompt_lambda_mod_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
_prompt_lambda_mod_pwd="$MATCH"
unset MATCH
else
_prompt_lambda_mod_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
fi
}
function +vi-git_status {
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
hook_com[unstaged]='%F{red}'
fi
}
function prompt_lambda_mod_precmd {
vcs_info
prompt_lambda_mod_pwd
}
function prompt_lambda_mod_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
# Add hook for calling vcs_info before each command.
add-zsh-hook precmd prompt_lambda_mod_precmd
# Set vcs_info parameters.
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '*'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}'
zstyle ':vcs_info:*' formats ' at %F{blue} %u%b%c%f %F{cyan}→%f'
zstyle ':vcs_info:*' actionformats " %b%c%u|%F{cyan}%a%f"
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b|%F{cyan}%r%f'
zstyle ':vcs_info:git*+set-message:*' hooks git_status
# Define prompts.
PROMPT='%F{green}%(?::%F{red})λ%f %F{yellow}%n%f %F{black}[${_prompt_lambda_mod_pwd}]%f${vcs_info_msg_0_} '
RPROMPT=''
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_lambda_mod_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment