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

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
aliases/local
*.zwc

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "modules/highlight/zsh-syntax-highlighting"]
path = modules/highlight/zsh-syntax-highlighting
url = git://github.com/zsh-users/zsh-syntax-highlighting.git

63
aliases/calendar Normal file
View file

@ -0,0 +1,63 @@
#!/bin/zsh
padd() {
local calendar desc date sel calfile i
zparseopts -E -D c:=calendar -cal:=calendar \
d:=date -date:=date
if [ -z "$date" ]; then
echo -n "Enter date: ";
read date;
fi
if [ -z "$calendar" ]; then
if [ -z "$sel" -o "$sel" -eq 0 ]; then
i=1
list=()
for calfile in ~/.pal/*.pal; do
echo \($i\)${calfile:t:r}
list+=($calfile)
((i=$i+1))
done;
echo -n "select calendar: "
read sel
if [ -z $sel -o $sel -eq 0 ]; then
echo "Invalid selection! Try again:"
fi
fi
calendar=${list[$sel]}
fi
if [ -z "$*" ]; then
echo "Enter description: ";
read desc;
else
desc=$*;
fi
echo ${date[2]} $desc >> $calendar
}
ptda() {
local prio sel calfile i
zparseopts -E -D p:=prio -priority:=prio \
if [ -z "$prio" ]; then
if [ -z "$sel" -o "$sel" -eq 0 ]; then
i=1
list=()
for calfile in ~/.pal/todo*.pal; do
echo \($i\)${${calfile:t:r}/todo_/}
list+=($calfile)
((i=$i+1))
done;
echo -n "select priority: "
read sel
if [ -z $sel -o $sel -eq 0 ]; then
echo "Invalid selection! Try again:"
fi
fi
prio=${list[$sel]}
fi
padd -d TODO -c $prio $*
}

244
aliases/functions Normal file
View file

@ -0,0 +1,244 @@
#!/bin/zsh
#################################################################################
# daily use aliases
##############################################################################{{{
alias ls="ls --color=auto"
alias ll="ls -hl --group-directories-first"
alias lll="ls -hla"
alias ds="du -sh"
alias :q="exit"
alias rget="rsync -avP --rsh=ssh --append-verify --inplace"
alias 7zu="7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on"
alias S='sudo $(history -n -1)'
alias rm="rm -I"
gg() {
paragrep "$@" -- **/*
}
fork() {
( $* &>/dev/null & )
}
#}}}
#################################################################################
# zsh stuff
##############################################################################{{{
alias histoff="HISTFILE=/dev/null"
alias histon="HISTFILE=$HOME/.histfile"
alias E="exec zsh"
# edit and refresh aliases
aliases() {
sudo vim /etc/zsh/aliases/${1:-functions}
. /etc/zsh/aliases/*
}
# per directory configuration
cd(){
if [ -e ".zout" ]; then
. ".zout"
fi
builtin cd $*
if [ -e ".zin" ]; then
. ".zin"
fi
todo
}
#}}}
#################################################################################
# administration and init scripts
##############################################################################{{{
toggle() {
if [ -z $2 ]; then
/etc/init.d/$1 status |
grep started &&
sudo /etc/init.d/$1 stop ||
sudo /etc/init.d/$1 start
else
sudo /etc/init.d/$1 $2
fi
}
#}}}
#################################################################################
# filesystem stuff
##############################################################################{{{
alias mkinitramfs='find . -print0 | cpio --null -ov --format=newc | gzip -9'
# bidirectional rsync
brsync() {
rsync -ur --progress $1 $2/..
rsync -ur --progress $2 $1/..
}
# count files in current or given directory
count() {
if [ -z $1 ]; then
ls ./**/*(.) | wc -l
else
ls $1/**/*(.) | wc -l
fi
}
pumount() {
params=()
while [[ "${1[1]}" == "-" ]]; do
params+="$1"
shift
done
if [[ "${1[1]}" == "/" ]]; then
=pumount "${params[@]}" "$1"
else
=pumount "${params[@]}" "/media/$1"
fi
}
#}}}
#################################################################################
# filename manipulation
##############################################################################{{{
alias cleanspaces="renamexm -s/\ /_/g -R"
# prefix all given files with first argument to this function
prefix() {
pre=$1;shift
for i in $*; do mv $i $pre$i;done
}
# prefix all given files with consecutive numbers, starting with 1
# or with number given by -s switch (must be first argument)
prenumbering() {
if [[ "$1" == "-s" ]]; then
n=${2};
shift 2
else
n=1
fi
for i in "$@"; do
mv $i ${(l:2::0:)n}_$i;
((n++));
done
}
# appends given suffix (first argument)
suffix() {
suf=$1;shift
for i in $*; do mv $i $i$suf;done
}
#}}}
#################################################################################
# wrappers
##############################################################################{{{
lesswrap() {
out=$("$@")
((lim=$LINES-1))
numlines=$(echo $out | wc -l)
if (( $numlines > $lim )); then
echo $out | less
else
echo $out
fi
}
#}}}
#################################################################################
# audio video photo
##############################################################################{{{
alias exifcopy="exiftool -tagsFromFile"
#}}}
#################################################################################
# programming
##############################################################################{{{
# cd for /code/projects dir with completion
pp(){
if [ -d /code/projects/$* ]; then
cd /code/projects/$*
else
vim /code/projects/$*
fi
};
# watch latex file for changes and rebuild
latexwatch() {
maindoc=$1
while : ; do
inotifywait -e modify $*; pdflatex -halt-on-error $maindoc
done
}
#}}}
#################################################################################
# noglobs
##############################################################################{{{
alias ri=noglob\ ri
alias wcalc="noglob wcalc"
#}}}
#################################################################################
# tmux
##############################################################################{{{
tdetachprep() {
env -i tmux new-session -d -s detached &>/dev/null
}
alias :u="tmux select-pane -U"
alias :d="tmux select-pane -D"
alias :l="tmux select-pane -L"
alias :r="tmux select-pane -R"
alias :split="tmux splitw -v"
alias :vsplit="tmux splitw -h"
alias :detachw="tdetachprep; tmux movew -t detached: -s"
alias :attachw="tdetachprep; tmux movew -t : -s"
#}}}
#################################################################################
# global and suffix aliases
##############################################################################{{{
# mplayer dvd drives
alias -g DSR1="-dvd-device /dev/sr1"
alias -g DSR0="-dvd-device /dev/sr0"
alias -g SR1="/dev/sr1"
alias -g SR0="/dev/sr0"
# mplayer activate softvol
alias -g SOFTVOL="-softvol -softvol-max 1000"
# lazy shortcuts
alias -g G="| grep"
alias -g L="| less"
alias -g T="| tail"
# xclipboard
alias -g XS='$(xclip -o -selection primary)'
alias -g XC='$(xclip -o -selection clipboard)'
alias -s log=vimpager
#}}}
# vim: foldmethod=marker

29
aliases/git Normal file
View file

@ -0,0 +1,29 @@
#!/bin/zsh
ginit() {
git init;
git add ${*:-"."};
git commit -a -m "Initial Commit"
}
gst() {
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
hg status "$@"
else
git status "$@"
fi
}
gpl() {
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
hg pull "$@"
else
git pull "$@"
fi
}
alias gca="git commit -a"
alias gcm="git commit"
alias gco="git checkout"
alias ga="git add"
alias gap="git add --patch"
alias gpu="git push"

56
aliases/portage Normal file
View file

@ -0,0 +1,56 @@
#!/bin/zsh
alias eud="emerge -vabuDN -j4 --keep-going world"
alias fetchlog="tail -f /var/log/emerge-fetch.log"
alias emerge="sudo emerge"
nolto() {
pkgenvconf $1 nolto nolto
}
notmpfs() {
pkgenvconf $1 notmpfs notmpfs
}
noaggressive() {
pkgenvconf $1 noaggressive noaggressive
}
nographite() {
pkgenvconf $1 nographite nographite
}
onlysafe() {
pkgenvconf $1 onlysafe onlysafe
}
cflags_reset() {
if [ -n "$1" ]; then
for i in \
/etc/portage/package.env/noaggressive \
/etc/portage/package.env/nographite \
/etc/portage/package.env/nolto; do
sed -i "/$1/d" $i;
done
fi
}
pkgenvconf() {
ltoline="$1 $2.conf"
echo -e '\e[1mInsert following line into package.env/'$2'?\e[0m'
echo "$ltoline"
echo "Looking for matching lines..."
grep $1 /etc/portage/package.env/$3
echo -e -n '\e[1m[y/n] \e[0m'
read answer
case "$answer" in
yes|y|YES|Yes|Really|"why not")
echo "$ltoline" | sudo tee -a /etc/portage/package.env/$3
;;
*) ;;
esac
}
alias eix="lesswrap /usr/bin/eix -F"

33
aliases/todo Normal file
View file

@ -0,0 +1,33 @@
TODOGIT="$HOME/.git/"
.todo-git() {
if [[ "${PWD}" == "${HOME}" ]]; then
git --git-dir=$TODOGIT stash save todohomegit
fi
$*
if [[ "${PWD}" == "${HOME}" ]]; then
git --git-dir=$TODOGIT add .todo
git --git-dir=$TODOGIT commit -m todo
git --git-dir=$TODOGIT stash pop `git --git-dir=$TODOGIT stash list \
| grep todohomegit | grep -oe "^[^:]*"`
fi
}
tda() {
.todo-git =tda $*
}
tde() {
.todo-git =tde $*
}
tdr() {
.todo-git =tdr $*
}
tdd() {
.todo-git =tdd $*
}

3
compdef/_aliases Normal file
View file

@ -0,0 +1,3 @@
#compdef aliases
_files -W /etc/zsh/aliases/

12
compdef/_awpman Normal file
View file

@ -0,0 +1,12 @@
#compdef awpman
typeset -A opt_args
local context state line
confpath=${WPMANSETS:-~/.config/wpman}
_arguments \
"1:Action:(load save)"\
"2:Setting File:_files -W $confpath"
# "load:Setting File:_files -W $confpath" \
# "save:Setting File:_files -W $confpath" \

103
compdef/_cryptsetup Normal file
View file

@ -0,0 +1,103 @@
#compdef cryptsetup
## completion for cryptsetup 1.3.0, based on cryptsetup(1)
function _cryptsetup_action {
typeset -a actions
actions=(
'create:create a mapping'
'remove:remove an existing mapping'
'status:report mapping status'
'resize:resize an active mapping'
'luksFormat:Initialize a LUKS partition'
'luksOpen:Open LUKS partition'
'luksClose:remove an existing mapping'
'luksSuspend:suspend active device'
'luksResume:resume suspended device'
'luksAddKey:add a new key'
'luksRemoveKey:remove a key'
'luksChangeKey:change a key'
'luksKillSlot:wipe key from slot'
'luksUUID:print/change device UUID'
'isLuks:check if device is a LUKS partition'
'luksDump:dump header information'
'luksHeaderBackup:store binary backup of headers'
'luksHeaderRestore:restore header backup'
)
_describe action actions
}
function _cryptsetup_device {
typeset expl
_wanted file expl device \
_files
}
function _cryptsetup_mapping {
typeset expl
_wanted file expl 'mapping name' \
_path_files -W /dev/mapper
}
function _cryptsetup_arguments {
case ${words[1]} in
create)
_arguments ':mapping:_cryptsetup_mapping' ':device:_cryptsetup_device'
;;
remove|status|resize|luksClose|luksSuspend|luksResume)
_arguments ': :_cryptsetup_mapping'
;;
luks(AddKey|RemoveKey|DelKey|UUID|Dump)|isLuks)
_arguments ': :_cryptsetup_device'
;;
luks(Format|AddKey|RemoveKey|ChangeKey))
_arguments ': :_cryptsetup_device' ':key file:_files'
;;
luksKillSlot)
_arguments ': :_cryptsetup_device' ':key slot number'
;;
luksOpen)
_arguments ': :_cryptsetup_device' ': :_cryptsetup_mapping'
;;
esac
}
function _cryptsetup {
_arguments \
'(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \
'--debug[enable debug mode]' \
'(-h --hash)'{-h,--hash}'[hash algorithm]:hash algorithm' \
'(-c --cipher)'{-c,--cipher}'[set cipher]:cipher specification' \
'(-y --verify-passphrase)'{-y,--verify-passphrase}'[query for password twice]' \
'(-d --key-file)'{-d,--key-file}'[set keyfile]:key file:_files' \
'(-l --keyfile-size)'{-l,--keyfile-size}'[set keyfile size]:bytes' \
'--new-keyfile-size[set new keyfile size (luksAddKey)]:bytes' \
'--master-key-file[set master key]:key file:_files' \
'--dump-master-key[dump luks master key]' \
'(--use-urandom)--use-random[use /dev/random to generate volume key]' \
'(--use-random)--use-urandom[use /dev/urandom to generate volume key]' \
'(-S --key-slot)'{-S,--key-slot}'[select key slot]:key slot' \
'(-s --key-size)'{-s,--key-size}'[set key size]:bits' \
'(-b --size)'{-b,--size}'[force device size]:sectors' \
'(-o --offset)'{-o,--offset}'[set start offset]:sectors' \
'(-p --skip)'{-p,--skip}'[data to skip at beginning]:sectors' \
'--readonly[set up read-only mapping]' \
'(-i --iter-time)'{-i,--iter-time}'[set password processing duration]:milliseconds' \
'(-q --batch-mode)'{-q,--batch-mode}'[do not ask for confirmation]' \
'(-t --timeout)'{-t,--timeout}'[set password prompt timeout]:seconds' \
'(-T --tries)'{-T,--tries}'[set maximum number of retries]:maximum retries' \
'--align-payload[set payload alignment]:sectors' \
'--uuid[set device UUID]:uuid' \
'--version[show version information]' \
':action:_cryptsetup_action' \
'*::arguments:_cryptsetup_arguments'
}
_cryptsetup "$@"

3
compdef/_games Normal file
View file

@ -0,0 +1,3 @@
#compdef game
_files -W $HOME/games/bin/

70
compdef/_jpptodo Normal file
View file

@ -0,0 +1,70 @@
#compdef jpptodo
typeset -A opt_args
local context state line
_jpp_find_todo_path() {
local todopath=$PWD
while true; do
[ -e "$todopath/TODO" ] && break;
[ "$todopath" = "/" ] && todopath=$PWD && break;
todopath=$(realpath "$todopath/..")
done
echo $todopath
}
_jpp_snums() {
local todopath=$(_jpp_find_todo_path)
[ -e "$todopath/TODO" ] || return;
_values -w 'S-Nummern' \
$(awk "$1"'{ printf "%s ", $1 }' $todopath/TODO)
}
_jpp_done() {
case "$state" in
arg2)
_values -w -s ' ' 'Aufgaben' \
'1[Model]' \
'2[Verwaltung]' \
'3[Import Export]' \
'4[Generierung]' \
'5[GUI]' \
'(1 2 3 4 5)all[Alle]'
;;
*)
_jpp_snums "/\s0\s/"
;;
esac
}
_jpptodo() {
_arguments "1:Commands:->commands" \
"2: :->arg1" \
"*: :->arg2" \
case "$state" in
commands)
_arguments '1:Commands:(new done todo lock run unlock)'\
'-o[offline mode]' \
'-d[debug]'
;;
*)
case $words[2] in
lock)
_jpp_snums "/open$/"
;;
unlock)
_jpp_snums "!/open$/"
;;
done)
_jpp_done
;;
run)
_jpp_snums
;;
esac
;;
esac
}
_jpptodo "$@"

3
compdef/_pl Normal file
View file

@ -0,0 +1,3 @@
#compdef pl
_files -W /code/lib/php/

3
compdef/_pp Normal file
View file

@ -0,0 +1,3 @@
#compdef pp
_files -W /code/projects

3
compdef/_ppsh Normal file
View file

@ -0,0 +1,3 @@
#compdef pp
_files -W /code/projects/shell/ -/

3
compdef/_pumount Normal file
View file

@ -0,0 +1,3 @@
#compdef pumount
_files -W /media

3
compdef/_pw Normal file
View file

@ -0,0 +1,3 @@
#compdef pw
_files -W /www/ -/

3
compdef/_py Normal file
View file

@ -0,0 +1,3 @@
#compdef py
_files -W /code/projects/php/

3
compdef/_ser Normal file
View file

@ -0,0 +1,3 @@
#compdef ser
_path_files -/ -W /mm/video/series

3
compdef/_toggle Normal file
View file

@ -0,0 +1,3 @@
#compdef toggle
_files -W /etc/init.d

25
compdef/_vcs Normal file
View file

@ -0,0 +1,25 @@
#compdef gpl gst
_gpl() {
if [[ "$VCS_DETECTED" == "hg" ]]; then
words=( hg pull "${(@)nw}"); (( CURRENT++ )); _hg
elif [[ "$VCS_DETECTED" == "hg" ]]; then
words=( svn update "${(@)nw}"); (( CURRENT++ )); _svn
else
words=( git pull "${(@)nw}"); (( CURRENT++ )); service=git; _git
fi
}
_gst() {
words=( git status "${(@)nw}"); (( CURRENT++ )); service=git; _git
}
nw=("${(@)words[2,$]}")
case "$service" in
gpl)
_gpl "$@" && return 0
;;
gst)
_gst "$@" && return 0
;;
esac

12
compdef/_wpman Normal file
View file

@ -0,0 +1,12 @@
#compdef wpman
typeset -A opt_args
local context state line
confpath=${WPMANSETS:-~/.config/wpman}
_arguments \
"1:Action:(load save)"\
"2:Setting File:_files -W $confpath"
# "load:Setting File:_files -W $confpath" \
# "save:Setting File:_files -W $confpath" \

3
compdef/_wvv Normal file
View file

@ -0,0 +1,3 @@
#compdef wvv
_files -W ~/.config/wvv

9
functions/imagepush Normal file
View file

@ -0,0 +1,9 @@
autoload -U zfinit && zfinit
imagepush() {
zfopen "crater2150.de" "ftp33701-crimages" \\
"$(gpg -d $HOME/.passwords/imagepush)"
zfcd /
zfput $* && echo "Transfer succesful"
zfclose
}

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

301
prompt Normal file
View file

@ -0,0 +1,301 @@
#!/bin/zsh
# Best Goddamn zsh prompt in the whole world.
# Author: Seth House <seth@eseth.com>
PROMPT_UNICODE=${PROMPT_UNICODE:-yes}
setopt prompt_subst
autoload -U colors && colors
autoload -U promptinit
autoload -Uz vcs_info
local reset
reset="%{${reset_color}%}"
#=================================================================256-color-term
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 ucnum
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
ucnum=196
else
ucnum=47
fi
if [ ! -z $SSH_CLIENT ]; then
ucnum=$((ucnum + 3))
hostcolor="%{${FG[226]}%}"
else
hostcolor=$gitclean
fi
usercolor="%{${FX[bold]}${FG[$ucnum]}%}"
#===================================================================8-color-term
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
fi
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
# 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 "${GIT_PROMPT_PREFIX}(%s) %12.12i %c%u %b%m${GIT_PROMPT_SUFFIX}" # 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 "${GIT_PROMPT_PREFIX}(%s) %12.12i %c%u${gituntracked} %b%m${GIT_PROMPT_SUFFIX}" # 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
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
svn info >/dev/null 2>/dev/null && echo '☣' && return
echo '%#'
}
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 screen STY and tmux number
sty () {
local sty=$?
if [ ! -z "$STY" ] || [ ! -z "$TMUX" ] ; then
echo "${SIG_PROMPT_PREFIX}${STY:+"SCREEN:"}${(S)STY/#*./}${STY+${TMUX+" - "}}${TMUX:+"TMUX:"}${TMUX/*,/}${SIG_PROMPT_SUFFIX}"
fi
}
screennum() {
local att
local det
local dead
if [ -x /usr/bin/screen ]; then
att=`screen -ls | grep Attached | wc -l`
det=`screen -ls | grep Detached | wc -l`
dead=`screen -ls | grep Dead | wc -l`
echo "A:$att|D:$det|?:$dead"
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
}
STYINFO=$(sty)
# Executed before each prompt
function precmd {
vcs_info
setprompt
RPS1='$usercolor◀%(?::$exitcolor${PVPREFIX})$(exitstatus)%(?::${PVSUFFIX})${stycolor}${PVPREFIX}$(sty)${rpscolor}${PVSUFFIX}${CORNER_RD}$reset'
}
# Executed after a command has been read and is to be executed.
function 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" ]]; then
local CMD=${1[(wr)^(*=*|ssh|sudo|-*)]}
echo -ne "\ek$CMD\e\\"
fi
}
function setprompt() {
local -a lines infoline
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} %~ ${PVSUFFIX}${rpscolor}${PR_HBAR}" )
# Username & host
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
if [[ "$PROMPT_UNICODE" = "yes" ]]; then
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 1))::─:)}"
else
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 1))::-:)}"
fi
infoline[3]=( "${infoline[3]}${PR_HBAR}${filler}${PR_HBAR}" )
infoline+=( "${rpscolor}${CORNER_RU}" )
### Now, assemble all prompt lines
lines+=( ${(j::)infoline} )
scmline="${rpscolor}${PR_VBAR} ${vcs_info_msg_0_}${reset}"
i_width=${(S)scmline//\%\{*\%\}} # search-and-replace color escapes
i_width=${#${(%)i_width}} # expand all escapes and count the chars
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 2)):: :)}${reset}"
[[ -n ${vcs_info_msg_0_} ]] && lines+=( "${scmline}${filler}${rpscolor}${PR_VBAR}" )
lines+=( "${CORNER_LD}${PVPREFIX} %(1j.${rpscolor}%j${reset} .)${usercolor}%%${reset} " )
### Finally, set the prompt
PROMPT=${(F)lines}
}
venv_rprompt () {
if [[ -n $VIRTUAL_ENV ]]; then
RPROMPT="${rpscolor} venv:$(basename $VIRTUAL_ENV)${reset}"
else
RPROMPT=""
fi
}
# function zle-keymap-select {
# VIMODE="${${KEYMAP/vicmd/ M:command}/(main|viins)/}"
# zle reset-prompt
# }
# zle -N zle-keymap-select
#
########## Or this one?:
# function zle-line-init zle-keymap-select {
# RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
# RPS2=$RPS1
# zle reset-prompt
# }
# zle -N zle-line-init
# zle -N zle-keymap-select

View file

@ -0,0 +1,18 @@
ECLHEIGHT=${ECLHEIGHT:-5}
edit-command-line-tmux() {
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" >$tmpfile
exec </dev/tty
if [ -n "$TMUX" ] && [ "$UID" -ne 0 ]; then
tmux splitw -v -l $ECLHEIGHT "vim -c 'set laststatus=0 showtabline=0 ft=zsh' $tmpfile"
pid=$(ps -ef | awk "/[0-9] vim.*${tmpfile:t}/ { print \$2 }")
wait_on_pid $pid
else
${=${VISUAL:-${EDITOR:-vi}}} $tmpfile
fi
print -Rz - "$(<$tmpfile)"
command rm -f $tmpfile
zle send-break # Force reload from the buffer stack
}

7
widgets/rationalise-dot Normal file
View file

@ -0,0 +1,7 @@
rationalise-dot() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+=/..
else
LBUFFER+=.
fi
}

3
zlogin Normal file
View file

@ -0,0 +1,3 @@
#fortune -c -s
#pal -r 7
todo

43
zprofile Normal file
View file

@ -0,0 +1,43 @@
# /etc/zsh/zprofile
# $Header: /var/cvsroot/gentoo-x86/app-shells/zsh/files/zprofile-1,v 1.1 2010/08/15 12:21:56 tove Exp $
# Load environment settings from profile.env, which is created by
# env-update from the files in /etc/env.d
if [ -e /etc/profile.env ] ; then
. /etc/profile.env
fi
# You should override these in your ~/.zprofile (or equivalent) for per-user
# settings. For system defaults, you can add a new file in /etc/profile.d/.
export EDITOR=${EDITOR:-/usr/bin/vim}
export PAGER=${PAGER:-/usr/bin/less}
export XDG_CONFIG_HOME="$HOME/.config"
# 077 would be more secure, but 022 is generally quite realistic
umask 022
# Set up PATH depending on whether we're root or a normal user.
# There's no real reason to exclude sbin paths from the normal user,
# but it can make tab-completion easier when they aren't in the
# user's PATH to pollute the executable namespace.
#
# It is intentional in the following line to use || instead of -o.
# This way the evaluation can be short-circuited and calling whoami is
# avoided.
#if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}:$PATH"
#else
# PATH="$HOME/.bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
#fi
PATH="/usr/lib/colorgcc/bin/:${PATH}"
export PATH
unset ROOTPATH
shopts=$-
setopt nullglob
for sh in /etc/profile.d/*.sh ; do
[ -r "$sh" ] && . "$sh"
done
unsetopt nullglob
set -$shopts
unset sh shopts

40
zshrc Normal file
View file

@ -0,0 +1,40 @@
HISTFILE=~/.histfile
HISTSIZE=100000
SAVEHIST=100000
setopt autocd extendedglob notify correct autonamedirs
setopt list_ambiguous autopushd pushd_ignore_dups
setopt hist_ignore_all_dups hist_ignore_space share_history
setopt no_auto_remove_slash auto_param_slash
setopt completeinword
setopt chase_links
setopt short_loops
setopt cdable_vars
# autoload completions
fpath+=( "${zcpath:-/etc/zsh}/compdef" )
autoload -U ${zcpath:-/etc/zsh}/compdef/*(:t)
bindkey -v
autoload -Uz compinit && compinit
autoload -Uz zmv
zmodload zsh/zftp
for i in ${zcpath:-/etc/zsh}/aliases/*~${zcpath:-/etc/zsh}/aliases/*.zwc; do
. $i
done
stty -ixon
. ${zcpath:-/etc/zsh}/modules/loader.zsh && mod_init
echo $PATH | grep -q 'local' || . /etc/zsh/zprofile
echo $PATH | grep -q 'sbin' || . /etc/zsh/zprofile
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format %B%d%b
zstyle ':completion:*:messages' format %d
zstyle ':completion:*:warnings' format No matches for: %d