new repository without sensitive information

This commit is contained in:
Alexander Gehrke 2013-03-15 08:37:33 +01:00
commit 57fa0afede
51 changed files with 1883 additions and 0 deletions

32
modules/autoloader/init Normal file
View file

@ -0,0 +1,32 @@
#!/bin/zsh
#################################################################################
# ZSH zle widget and custom function autloader
#################################################################################
#
# Lets you load custom functions and zle widgets split into single files.
#
# zle widgets are stored in the "widgets" folder in your configuration directory
# (default: /etc/zsh, if you want to use this in a user configuration file, set
# the variable $zcpath to your zsh configuration directory)
#
# functions are stored in the "functions" folder analogous.
#
ZWIDGETPATH=${ZWIDGETPATH:-"${zcpath:-/etc/zsh}/widgets"}
ZFUNCTIONPATH=${ZFUNCTIONPATH:-"${zcpath:-/etc/zsh}/functions"}
fpath+=( "${ZWIDGETPATH}" )
fpath+=( "${ZFUNCTIONPATH}" )
if [ -d $ZWIDGETPATH ]; then
for i in $ZWIDGETPATH/*(N:t); do
autoload -Uz $i
zle -N $i
done
fi
if [ -d $ZFUNCTIONPATH ]; then
for i in $ZFUNCTIONPATH/*(N:t); do
autoload -Uz $i && $i
done
fi

1
modules/bindings/depend Normal file
View file

@ -0,0 +1 @@
need autoloader

50
modules/bindings/init Normal file
View file

@ -0,0 +1,50 @@
#!/bin/zsh
exit(){builtin exit;}
zle -N q exit
bindkey -M vicmd ! edit-command-line-tmux
#unicode input
autoload -U insert-unicode-char
bindkey "u" insert-unicode-char
bindkey "^[[2~" yank # Insert
bindkey "^[[3~" delete-char # Del
bindkey "^[[5~" history-beginning-search-backward # PageUp
bindkey "^[[6~" history-beginning-search-forward # PageDown
bindkey "^[e" expand-cmd-path # C-e for expanding path of typed command.
bindkey "^[[A" up-line-or-search # Up arrow for back-history-search.
bindkey "^[[B" down-line-or-search # Down arrow for fwd-history-search.
bindkey " " magic-space # Do history expansion on space.
case "$TERM" in
*xterm*|(dt|k)term)
bindkey "" backward-delete-char #backspace
bindkey "" backward-delete-word #C-backspace
bindkey "OH" beginning-of-line # Pos1
bindkey "OF" end-of-line # End
bindkey "^[[7~" beginning-of-line # Pos1
bindkey "^[[8~" end-of-line # End
;;
rxvt*|Eterm)
bindkey "^[[7~" beginning-of-line # Pos1
bindkey "^[[8~" end-of-line # End
bindkey "" backward-delete-char #backspace
bindkey "" backward-delete-word #C-backspace
;;
linux|screen*)
bindkey "[1~" beginning-of-line # Pos1
bindkey "[4~" end-of-line # End
bindkey "OD" vi-backward-blank-word
bindkey "OC" vi-forward-blank-word
bindkey "" backward-delete-char #backspace
bindkey "" backward-delete-word #C-backspace
;;
esac
bindkey "OA" up-line-or-history
bindkey "OB" down-line-or-history
bindkey "" vi-backward-blank-word
bindkey "" vi-forward-blank-word
#bindkey . rationalise-dot
bindkey "" push-line-or-edit

75
modules/color/init Normal file
View file

@ -0,0 +1,75 @@
#!/bin/zsh
autoload -U colors && colors
. $MPATH/spectrum
reset="%{${reset_color}%}"
#
# 256-color-term or rxvt with wrong tput output
#
if [[ "`tput colors`" == "256" ]] || [[ "`tput colors`" == "88" ]] ; then
pathcolor="%{${FG[27]}%}"
ropathcolor="%{${FG[92]}%}"
gitdirty="%{${FX[bold]}${FG[160]}%}"
gitstaged="%{${FX[bold]}${FG[34]}%}"
gitclean="%{${FG[240]}%}"
stycolor="%{${FG[240]}%}"
exitcolor=$gitdirty
rpscolor="%{${FG[238]}%}"
gituntracked="%{$FX[bold]$FG[253]%}●%{$reset$rpscolor%}"
local usercolor_base
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
usercolor_base=196
usercolor_mod=30
else
usercolor_base=47
usercolor_mod=28
fi
if [ ! -z $SSH_CLIENT ]; then
usercolor_base=$((usercolor_base + usercolor_mod))
hostcolor="%{${FG[226]}%}"
else
hostcolor=$gitclean
fi
usercolor="%{${FX[bold]}${FG[$usercolor_base]}%}"
# 8-color-term
if [ -e /etc/DIR_COLORS_256 ] ; then
eval "$(dircolors /etc/DIR_COLORS_256)"
elif [ -e /etc/DIR_COLORS ]; then
eval "$(dircolors /etc/DIR_COLORS)"
fi
else
pathcolor="%{$fg_bold[blue]}%}"
gitdirty="%{${fg[yellow]}%}"
gitstaged="%{${fg[green]}%}"
gitclean="%{$rightcolor%}"
vcs_revision="%{${fg[250]}%}"
exitcolor="%{$gitdirty%}"
rpscolor="%{$fg_bold[black]}%}"
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
if [ ! -z $SSH_CLIENT ]; then
usercolor="%{${fg_bold[yellow]}%}"
hostcolor="%{${fg_no_bold[blue]}%}"
else
usercolor="%{${fg_bold[red]}%}"
hostcolor="%{${fg_bold[black]}%}"
fi
else
if [ ! -z $SSH_CLIENT ]; then
usercolor="%{${fg_bold[blue]}%}"
hostcolor="%{${fg_no_bold[blue]}%}"
else
usercolor="%{${fg_bold[green]}%}"
hostcolor="%{${fg_bold[black]}%}"
fi
fi
[ -e /etc/DIR_COLORS ] && eval "$(dircolors /etc/DIR_COLORS)"
fi

19
modules/color/spectrum Normal file
View file

@ -0,0 +1,19 @@
#! /bin/zsh
# A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com>
typeset -Ag FX FG BG
FX=(
reset ""
bold "" no-bold ""
italic "" no-italic ""
underline "" no-underline ""
blink "" no-blink ""
reverse "" no-reverse ""
)
for color in {0..255}; do
FG[$color]="[38;5;${color}m"
BG[$color]="[48;5;${color}m"
done

39
modules/completion/init Normal file
View file

@ -0,0 +1,39 @@
# The following lines were added by compinstall
#zstyle ':completion::complete:*' completer _complete _ignored _correct
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle ':completion:*' completer _complete _ignored _match _approximate _correct
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*' special-dirs true
zstyle ':completion:*' verbose true
zstyle :compinstall filename '/etc/zsh/completion'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# ssh known hosts complete
{
local _myhosts
_myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} )
zstyle ':completion:*' hosts $_myhosts
}&>/dev/null
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
compdef _command fork
compdef _command detach
compdef _command ontv

15
modules/helpers.zsh Normal file
View file

@ -0,0 +1,15 @@
istrue() {
case "$1" in
yes|yeah|on|true|1|y)
return 0;;
esac
return 1;
}
in_array() {
local needle=$1
shift
arr=( "${@}" )
(( $arr[(i)$needle] != ${#arr} + 1 ))
}

25
modules/highlight/init Normal file
View file

@ -0,0 +1,25 @@
. $MPATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor pattern)
ZSH_HIGHLIGHT_STYLES[command]='fg=74'
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=74'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=74'
ZSH_HIGHLIGHT_STYLES[function]='fg=74'
ZSH_HIGHLIGHT_STYLES[alias]='fg=74,standout'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=74,bold'
ZSH_HIGHLIGHT_STYLES[path]='fg=120'
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=215,bold'
ZSH_HIGHLIGHT_STYLES[globbing]='fg=215,bold'
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=203,bold'
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=203'
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=33'
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=51'
ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=40'
ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=35'
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]='bold,bg=75'
ZSH_HIGHLIGHT_PATTERNS+=('${*}' 'fg=215')

@ -0,0 +1 @@
Subproject commit e5d8a50d362a153a28506be6fae9cf179dbb5fd4

195
modules/loader.zsh Normal file
View file

@ -0,0 +1,195 @@
#################################################################################
# ZSH modular config
#################################################################################
#
# Helps you split up your config into modules and reuse modules from other
# people.
#
# Modules are stored in the "modules" folder in your configuration directory
# (default: /etc/zsh, if you want to use this in a user configuration file, set
# the variable $zcpath to your zsh configuration directory)
#
# Each module should have a file called "init". This file is sourced, when the
# module is loaded and is responsible for sourcing any other files needed by the
# module.
#
# The module can use $MPATH variable, which contains the module's directory.
#################################
# INTERNAL MODULE LOADING STUFF #
#################################
# Path to module directory
ZMODPATH=${ZMODPATH:-"${zcpath:-/etc/zsh}/modules"}
. $ZMODPATH/helpers.zsh
errdetails=""
modqueue=( )
# Adds a module to the loading queue
#
# This function adds a module for later loading, if it is not already queued.
# It calls mod_deps for dependency checking. If dependencies are not satisfied,
# the module is not loaded.
#
# Parameters:
# 1: module name
# 2: if loaded as a dependency: is_dep
# otherwise empty
# 3: if loaded as a dependency: the depending module
#
mod_queue() {
local module="$1"
local modsource="$ZMODPATH/$module"
if [[ "$2" == "is_dep" ]]; then
if ! [ -e "$modsource" ] ; then
echo "$3: Unsatisfied dependency \"$module\"";
return 1
fi
fi
in_array "$module" "${(@)modqueue}" && return 0
if mod_deps "$modsource"; then
modqueue=( "${(@)modqueue}" "$module" )
else
case $? in
1) echo "module $module not loaded because of missing dependencies: $errdetails";;
2) echo "module $module not loaded because of blocking module: $errdetails";;
esac
fi
}
# Checks for module dependencies
#
# Reads the "depend" file for a module and tries to queue all dependencies for
# loading. If any fails, it returns 1;
#
# Parameters:
# 1: Path to module
#
mod_deps() {
modpath=$1
! [ -e $modpath/depend ] && return 0;
while read relation dep; do
mod_check_dep $modpath $relation $dep
done < "$modpath/depend"
return 0;
}
mod_check_dep() {
modpath=$1
relation=$2
dep=$3
#legacy entry compatibility
if [ -z "$dep" ]; then
dep="$relation"
relation="need"
fi
if in_array "$dep" "${(@)modqueue}" && [[ "$relation" != "block" ]]; then
return 0;
fi
case "$relation"; in
"need")
if ! mod_queue "$dep" is_dep ${modpath}; then
errdetails="$dep"
return 1;
fi;;
"after")
if [ -z "$ZMODLOAD_ONLY" ] \
|| in_array "$dep" "${(@)ZMODLOAD_ONLY}"; then
mod_queue "$dep" is_dep ${modpath};
fi ;;
"block")
if in_array "$dep" "${(@)ZMODLOAD_ONLY}" \
|| in_array "$dep" "${(@)modqueue}"; then
errdetails="$dep"
return 2
fi;;
esac
}
# Loads all queued modules
#
# After queueing all modules and dependency modules, this function calls their
# init-scripts, if existent (if not, the module is ignored for now)
#
mod_load() {
local MPATH
for module in "${(@)modqueue}"; do
MPATH="$ZMODPATH/$module"
[ -e "$ZMODPATH/$module/init" ] && . "$ZMODPATH/$module/init"
done
}
# Begins module loading procedure
#
# Queues all modules in the module directory or, if set, only modules listed in
# $ZMODLOAD_ONLY
mod_init() {
if [ -n "$ZMODLOAD_ONLY" ]; then
for module in "${(@)ZMODLOAD_ONLY}"; do
[ -d "$ZMODPATH/$module" ] && mod_queue "$module"
done
else
for module in $ZMODPATH/*(/N); do
if [ -z "$ZMODLOAD_BLACKLIST" ] \
|| ! in_array ${module:t} ${(@)ZMODLOAD_BLACKLIST}; then
mod_queue "${module:t}"
fi
done
fi
mod_load
}
# return 0 if all given modules were loaded (i.e. in the load queue)
mod_loaded() {
for i in "$@"; do
in_array $i ${(@)modqueue} || return 1
done
return 0
}
#################################################################################
# Utility functions for modules
#################################################################################
#
# Register hook functions
# see 'SPECIAL FUNCTIONS' section in zshmisc(1) for more information
#
precmd_hook() {
[[ -z $precmd_functions ]] && precmd_functions=()
precmd_functions=($precmd_functions $*)
}
chpwd_hook() {
[[ -z $chpwd_functions ]] && chpwd_functions=()
chpwd_functions=($chpwd_functions $*)
}
preexec_hook() {
[[ -z $preexec_functions ]] && preexec_functions=()
preexec_functions=($preexec_functions $*)
}
zshaddhistory_hook() {
[[ -z $zshaddhistory_functions ]] && zshaddhistory_functions=()
zshaddhistory_functions=($zshaddhistory_functions $*)
}
zshexit_hook() {
[[ -z $zshexit_functions ]] && zshexit_functions=()
zshexit_functions=($zshexit_functions $*)
}

4
modules/prompt/depend Normal file
View file

@ -0,0 +1,4 @@
need color
after vcs
after todo
after work

130
modules/prompt/init Normal file
View file

@ -0,0 +1,130 @@
#!/bin/zsh
autoload -U colors && colors
autoload -U promptinit
PROMPT_UNICODE=${PROMPT_UNICODE:-yes}
setopt prompt_subst
if [[ "$PROMPT_UNICODE" = "yes" ]]; then
PVPREFIX="╼╢"
PVSUFFIX="╟╾"
PR_HBAR='─'
PR_VBAR='│'
CORNER_LU='╭'
CORNER_LD='╰'
CORNER_RU='╮'
CORNER_RD='╯'
else
PVPREFIX="["
PVSUFFIX="]"
PR_HBAR='-'
PR_VBAR='|'
fi
# Show screen STY and tmux number
sty () {
local sty=$?
echo -n "${SIG_PROMPT_PREFIX}"
echo -n "${STY:+"SCREEN:"}${(S)STY/#*./}${STY+" - "}"
echo -n "${TMUX:+"TMUX:"}${TMUX/*,/}${TMUX+" - "}"
echo -n "%y${SIG_PROMPT_SUFFIX}"
}
# show number of attached and detached screens
screennum() {
local att
local det
local dead
if [ -x /usr/bin/screen ]; then
att=`screen -ls | grep -c Attached`
det=`screen -ls | grep -c Detached`
dead=`screen -ls | grep -c Dead `
echo "A:$att|D:$det|?:$dead"
fi
}
function prompt_precmd {
if mod_loaded vcs; then
vcs_info
fi
setprompt
RPS1='$usercolor◀%(?::$exitcolor${PVPREFIX})$(exitstatus)%(?::${PVSUFFIX})${stycolor}${PVPREFIX}$(sty)${rpscolor}${PVSUFFIX}${CORNER_RD}$reset'
}
precmd_hook prompt_precmd
# Executed after a command has been read and is to be executed.
function prompt_preexec {
# if running gnu screen, set the window name to the last run command
# FIXME any way to make this not change certain window titles (by window
# number or if a title isn't already set?)
if [[ "$TERM" =~ "screen" ]] \
&& [[ "$(tmux show -w au)" != "automatic-rename off" ]]; then
local CMD=${1[(wr)^(*=*|ssh|sudo|-*)]}
echo -ne "\ek$CMD\e\\"
fi
}
if mod_loaded todo; then
function todo_to_read_info() {
count=$(todo_count all ${TO_READ_FILE:-$HOME/.to_read})
if [ "$count" -gt 1 ]; then
echo -n "${PVPREFIX}${pathcolor}To read: $((count -1)) ${rpscolor}${PVSUFFIX}"
fi
}
fi
preexec_hook prompt_preexec
function setprompt() {
local -a lines infoline middleline
local x i filler i_width
infoline+=( "${rpscolor}${CORNER_LU}" )
### First, assemble the top line
# Current dir
[[ -w $PWD ]] && infoline+=( ${pathcolor} ) || infoline+=( ${ropathcolor} )
infoline+=( "${PVPREFIX} %(5~|%-1~/.../|)%3~ ${PVSUFFIX}${rpscolor}${PR_HBAR}" )
# Username & host
infoline+=( "%(1j.${PVPREFIX} ${gitdirty}Jobs: %j${rpscolor} ${PVSUFFIX}.)" )
mod_loaded todo && infoline+=( "$(todo_to_read_info)" )
[ -n "${WTF_REST}" ] && infoline+=( "${WTF_REST_FORMATTED}" )
infoline+=( "${PVPREFIX} ${usercolor}%n${reset}@${hostcolor}%m${rpscolor} ${PVSUFFIX}" )
i_width=${(S)infoline//\%\{*\%\}} # search-and-replace color escapes
i_width=${(%)i_width} # expand all escapes and count the chars
i_width=${#i_width} # expand all escapes and count the chars
if [[ "$PROMPT_UNICODE" = "yes" ]]; then
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width + 2))::─:)}"
else
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width + 2))::-:)}"
fi
infoline[3]=( "${infoline[3]}${PR_HBAR}${filler}${PR_HBAR}" )
infoline+=( "${rpscolor}${CORNER_RU}" )
#middle info line
if mod_loaded vcs; then
middleline+=( "${rpscolor}${PR_VBAR} $(vcs_char) ${vcs_info_msg_0_}${reset}" )
fi
i_width=${(S)middleline//\%\{*\%\}} # search-and-replace color escapes
i_width=${#${(%)i_width}} # expand all escapes and count the chars
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 2)):: :)}${reset}"
### Now, assemble all prompt lines
lines+=( ${(j::)infoline} )
[[ -n ${vcs_info_msg_0_} ]] && lines+=( "${middleline}${filler}${rpscolor}${PR_VBAR}" )
lines+=( "${CORNER_LD}${PVPREFIX} %(1j.${rpscolor}%j${reset} .)${usercolor}%#${reset} " )
### Finally, set the prompt
PROMPT=${(F)lines}
}

25
modules/ssh-agent/init Normal file
View file

@ -0,0 +1,25 @@
#!/bin/zsh
# start ssh-agent on first opened shell, retrieve information on all others from
# file
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi

12
modules/ssh/init Normal file
View file

@ -0,0 +1,12 @@
#!/bin/zsh
h=()
if [[ -r ~/.ssh/config ]]; then
h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
if [[ -r ~/.ssh/known_hosts ]]; then
h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
fi
if [[ $#h -gt 0 ]]; then
zstyle ':completion:*:ssh:*' hosts $h
zstyle ':completion:*:slogin:*' hosts $h
fi

10
modules/todo/init Normal file
View file

@ -0,0 +1,10 @@
#!/bin/zsh
todo_count() {
if [ -n "$2" ]; then
file="--database $2"
else
file="-G"
fi
todo ${=file} -f +${1:-high} | wc -l
}

View file

@ -0,0 +1 @@
/usr/src/linux-git

1
modules/vcs/filter/portage Symbolic link
View file

@ -0,0 +1 @@
/usr/portage

1
modules/vcs/filter/rmusic Symbolic link
View file

@ -0,0 +1 @@
/mnt/rmusic

1
modules/vcs/filter/rvideo Symbolic link
View file

@ -0,0 +1 @@
/mnt/rvideo

135
modules/vcs/init Normal file
View file

@ -0,0 +1,135 @@
#!/bin/zsh
# vcs-info config
#
# Partly based on Seth House's zsh promp
autoload -Uz vcs_info
# Set up VCS_INFO
zstyle ':vcs_info:*' enable git hg svn
zstyle ':vcs_info:(hg*|git*):*' get-revision true
zstyle ':vcs_info:(hg*|git*):*' check-for-changes true
zstyle ':vcs_info:hg*' formats "(%s)[%i%u %b %m]" # rev+changes branch misc
zstyle ':vcs_info:hg*' actionformats "(%s|${white}%a${rpscolor})[%i%u %b %m]"
zstyle ':vcs_info:hg*:netbeans' use-simple true
zstyle ':vcs_info:hg*:*' get-bookmarks true
zstyle ':vcs_info:hg*:*' get-mq true
zstyle ':vcs_info:hg*:*' get-unapplied true
zstyle ':vcs_info:hg*:*' patch-format "mq(%g):%n/%c %p"
zstyle ':vcs_info:hg*:*' nopatch-format "mq(%g):%n/%c %p"
zstyle ':vcs_info:hg*:*' hgrevformat "%r" # only show local rev.
zstyle ':vcs_info:hg*:*' branchformat "%b" # only show branch
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat "%b$vcs_revision:%f%r%f"
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:git*' formats "(%s) %12.12i %c%u %b%m" # hash changes branch misc
zstyle ':vcs_info:git*' actionformats "(%s|${white}%a${rpscolor}) %12.12i %c%u %b%m"
} else {
zstyle ':vcs_info:git*' formats "(%s) %12.12i %c%u${gituntracked} %b%m" # hash changes branch misc
zstyle ':vcs_info:git*' actionformats "(%s|${white}%a${rpscolor}) %12.12i %c%u %b%m"
}
zstyle ':vcs_info:*' stagedstr "$gitstaged●$rpscolor"
zstyle ':vcs_info:*' unstagedstr "$gitdirty●$rpscolor"
# zstyle ':vcs_info:hg:*:-all-' command fakehg
# zstyle ':vcs_info:*+*:*' debug true
zstyle ':vcs_info:hg*+set-hgrev-format:*' hooks hg-hashfallback
zstyle ':vcs_info:hg*+set-message:*' hooks mq-vcs
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
zstyle ':vcs_info:*+pre-get-data:*' hooks vcs-detect
disable_pattern=()
for i in $MPATH/filter/*; do
filter="$(readlink -f $i)(|/*)"
disable_pattern=("${disable_pattern[@]}" "$filter");
done
zstyle ':vcs_info:*' disable-patterns "${disable_pattern[@]}"
+vi-vcs-detect() {
export VCS_DETECTED=$vcs
}
function vcs_char {
case $VCS_DETECTED in
git)
echo '±';;
hg)
echo '☿';;
svn)
echo '☣';;
*)
echo '#';;
esac
}
exitstatus () {
local exitstatus=$?
if [ $exitstatus -ne 0 ] ; then
if [ $exitstatus -gt 128 -a $exitstatus -lt 163 ] ; then
echo "${SIG_PROMPT_PREFIX}SIG$signals[$exitstatus-127]${SIG_PROMPT_SUFFIX}"
else
echo "${SIG_PROMPT_PREFIX}${exitstatus}${SIG_PROMPT_SUFFIX}"
fi
fi
}
### Dynamically set hgrevformat based on if the local rev is available
# We don't always know the local revision, e.g. if use-simple is set
# Truncate long hash to 12-chars but also allow for multiple parents
function +vi-hg-hashfallback() {
if [[ -z ${hook_com[localrev]} ]] ; then
local -a parents
parents=( ${(s:+:)hook_com[hash]} )
parents=( ${(@r:12:)parents} )
hook_com[rev-replace]="${(j:+:)parents}"
ret=1
fi
}
# Show remote ref name and number of commits ahead-of or behind
function +vi-git-st() {
local ahead behind remote
local -a gitstatus
# Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name --abbrev-ref 2>/dev/null)}
if [[ -n ${remote} ]] ; then
# for git prior to 1.7
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "${gitstaged}+${ahead}${rpscolor}" )
# for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "${gitdirty}-${behind}${rpscolor}" )
hook_com[branch]="${hook_com[branch]} [ ${remote}${gitstatus:+ }${gitstatus} ]"
fi
}
# Show count of stashed changes
function +vi-git-stash() {
local -a stashes
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" (${stashes} stashed)"
fi
}

5
modules/work/init Normal file
View file

@ -0,0 +1,5 @@
#!/bin/zsh
if [ -n "$WTF_WORK_END" -a -e $HOME/.wtf ] && which wtf &>/dev/null; then
export WTF_REST=$(wtf raw -d $WTF_WORK_END diff);
export WTF_REST_FORMATTED="$(printf "%.2f days\n" $((WTF_REST/28800.0)))"
fi