]> git.donarmstrong.com Git - zsh.git/commitdiff
reordering of zshrc files
authormartin f. krafft <madduck@madduck.net>
Wed, 7 May 2008 10:32:27 +0000 (11:32 +0100)
committermartin f. krafft <madduck@madduck.net>
Wed, 7 May 2008 10:32:31 +0000 (11:32 +0100)
24 files changed:
.zsh/zshrc/00_TODO [deleted file]
.zsh/zshrc/19_dircolors [new file with mode: 0644]
.zsh/zshrc/25_tempfuncs [deleted file]
.zsh/zshrc/40_tempfuncs [new file with mode: 0644]
.zsh/zshrc/60_vcsprompt [new file with mode: 0644]
.zsh/zshrc/70_termfonts [deleted file]
.zsh/zshrc/80_bindkeys [new file with mode: 0644]
.zsh/zshrc/80_history [new file with mode: 0644]
.zsh/zshrc/80_prompt [new file with mode: 0644]
.zsh/zshrc/80_termfonts [new file with mode: 0644]
.zsh/zshrc/80_xtermtitle [new file with mode: 0644]
.zsh/zshrc/85_vcs_prompt [deleted file]
.zsh/zshrc/89_dircolors [deleted file]
.zsh/zshrc/90_bindkeys [deleted file]
.zsh/zshrc/90_history [deleted file]
.zsh/zshrc/90_prompt [deleted file]
.zsh/zshrc/90_xterm_title [deleted file]
.zsh/zshrc/95_fortune.disabled [new file with mode: 0644]
.zsh/zshrc/95_watch [new file with mode: 0644]
.zsh/zshrc/98_watch [deleted file]
.zsh/zshrc/99_TODO [new file with mode: 0644]
.zsh/zshrc/99_fortune.disabled [deleted file]
.zsh/zshrc/99_hook_functions [deleted file]
.zsh/zshrc/99_hookfunctions [new file with mode: 0644]

diff --git a/.zsh/zshrc/00_TODO b/.zsh/zshrc/00_TODO
deleted file mode 100644 (file)
index dc1294b..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-# zshrc/00_TODO
-#
-# All kinds of stuff not yet split to other files
-# TEMPORARY
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-ldir() { eval $1="$PWD" ; : ~$1 }
-
-alias Q='exec zsh'
-alias ozsh='ZDOTDIR=$HOME/.etc/zsh exec zsh'
-
-# do not clobber files with >
-setopt noclobber
-
-# automatically maintain a directory stack
-setopt autopushd pushdminus pushdsilent pushdtohome
-
-# brace expansion
-setopt braceccl
-
-# print backgrounded jobs when they finish
-setopt notify
-# bg-processes should not be nice
-unsetopt bgnice
-# send no HUP signal to running jobs when the shell exits
-setopt nohup
-# don't bother me with running jobs (only wize with setopt nohup)
-unsetopt checkjobs
-
-# disable backslashed escape sequences unless -e is given to echo 
-setopt bsd_echo
-
-[ "$(umask)" = 022 ] && umask 0077
-
-eval `lesspipe 2>/dev/null`
-
-WORDCHARS="*?_-.[]~/&;!#$%^(){}<>"
-
-# report time stats when command takes longer than 5 seconds
-REPORTTIME=5
-
-MAILCHECK=0
-
-# http://grml.org/zsh/zsh-lovers.html
-rationalise-dot() {
-  if [[ $LBUFFER = *.. ]]; then
-    LBUFFER+=/..
-  else
-    LBUFFER+=.
-  fi
-}
-zle -N rationalise-dot
-bindkey . rationalise-dot
-
-:
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/19_dircolors b/.zsh/zshrc/19_dircolors
new file mode 100644 (file)
index 0000000..d084875
--- /dev/null
@@ -0,0 +1,33 @@
+# zshrc/90_dircolors
+#
+# Load dircolors database
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+eval $(dircolors $ZDOTDIR/dircolors) 2>/dev/null || :
+
+if [ -n "$LS_COLORS" ]; then
+  # uniquify LS_COLORS due to #479544
+
+  typeset -A pairs
+  for pair in ${(s.:.)LS_COLORS}; do
+    [ -z "${pair%%\=*}" ] && continue
+    pairs["${pair%%\=*}"]="${pair#*=}"
+  done
+
+  typeset -a items
+  for key in ${(k)pairs}; do
+    [ "$pairs[$key]" = 00 ] && continue #removes styles handled by normal
+    items+="${(Q)key}=$pairs[$key]"
+  done
+  LS_COLORS="${(j.:.)items}:"
+else
+  # fallback
+  LS_COLORS="di=01;30:ln=target:ex=00;34:no=00:fi=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tbz2=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00:*.jpeg=00:*.gif=00:*.bmp=00:*.pbm=00:*.pgm=00:*.ppm=00:*.tga=00:*.xbm=00:*.xpm=00:*.tif=00:*.tiff=00:*.png=00:*.svg=00:*.mng=00:*.pcx=00:*.mov=00:*.mpg=00:*.mpeg=00:*.m2v=00:*.mkv=00:*.ogm=00:*.mp4=00:*.m4v=00:*.mp4v=00:*.vob=00:*.qt=00:*.nuv=00:*.wmv=00:*.asf=00:*.rm=00:*.rmvb=00:*.flc=00:*.avi=00:*.fli=00:*.gl=00:*.dl=00:*.xcf=00:*.xwd=00:*.yuv=00:*.aac=00:*.au=00:*.flac=00:*.mid=00:*.midi=00:*.mka=00:*.mp3=00:*.mpc=00:*.ogg=00:*.ra=00:*.wav=00"
+fi
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/25_tempfuncs b/.zsh/zshrc/25_tempfuncs
deleted file mode 100644 (file)
index 1c1d551..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# zshrc/25_tempfiles
-#
-# Helper functions to create temporary files and directories
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-cdt () {
-  cd $(mktemp -td cdt.XXXXXXXX)
-  pwd
-}
-
-vit () {
-  local tmpfile=$(mktemp -t vit.XXXXXXXX)
-  [ "$1" = '-' ] && cat >| $tmpfile
-  sensible-editor $tmpfile </dev/tty >/dev/tty
-  echo $tmpfile
-}
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/40_tempfuncs b/.zsh/zshrc/40_tempfuncs
new file mode 100644 (file)
index 0000000..1c1d551
--- /dev/null
@@ -0,0 +1,23 @@
+# zshrc/25_tempfiles
+#
+# Helper functions to create temporary files and directories
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+cdt () {
+  cd $(mktemp -td cdt.XXXXXXXX)
+  pwd
+}
+
+vit () {
+  local tmpfile=$(mktemp -t vit.XXXXXXXX)
+  [ "$1" = '-' ] && cat >| $tmpfile
+  sensible-editor $tmpfile </dev/tty >/dev/tty
+  echo $tmpfile
+}
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/60_vcsprompt b/.zsh/zshrc/60_vcsprompt
new file mode 100644 (file)
index 0000000..a99ca18
--- /dev/null
@@ -0,0 +1,199 @@
+# zshrc/85_git_prompt
+#
+# Make git information available to the prompt
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+# Shamelessly based on http://glandium.org/blog/?p=170
+#
+
+__git_get_reporoot()
+{
+  # return the full path to the root of the current git repository
+  local relroot
+  relroot="$(git rev-parse --show-cdup 2>/dev/null)" || return 1
+  if [ -n "$relroot" ]; then
+    readlink -f "$relroot"
+  else
+    echo $PWD
+  fi
+}
+
+__git_get_branch()
+{
+  # return the name of the git branch we're on
+  local ref
+  ref=$(git symbolic-ref -q HEAD 2>/dev/null \
+     || git-name-rev --name-only HEAD 2>/dev/null) || return 1
+  echo "${ref#refs/heads/}"
+}
+
+__hg_get_reporoot()
+{
+  hg root
+}
+
+__hg_get_branch()
+{
+  echo "hg:$(hg branch)"
+}
+
+__bzr_get_reporoot()
+{
+  local reporoot
+  reporoot="$(bzr info | sed -rne 's, *branch root: ,,p')"
+  case "$reporoot" in
+    .) echo "$PWD";;
+    *) echo "$reporoot";;
+  esac
+}
+
+__bzr_get_branch()
+{
+  local branch revno
+  bzr version-info | while read i j; do
+      case "$i" in
+        revno:) revno="$j";;
+        branch-nick:) branch="$j";;
+      esac
+    done
+  echo "bzr:${branch}@$revno"
+}
+
+__vcs_get_repo_type()
+{
+  # return the type of the closest repository in the path hierarchy
+  local dir
+  while true; do
+    [ -d ${dir}.git ] && echo git && break
+    [ -d ${dir}.bzr ] && echo bzr && break
+    [ -d ${dir}.hg ] && echo hg && break
+    [ "$(readlink -f ${dir:-.})" = / ] && echo NONE && break
+    dir="../$dir"
+  done
+}
+
+__vcs_get_prompt_path_components()
+{
+  # return formatted path components (prefix branch postfix) given
+  # the repository root and the branch.
+
+  # shortcut: if there are no arguments, return a default prompt
+  if [ -z "${1:-}" ]; then
+    pwdnamed="%${_PROMPT_PATH_MAXLEN}<..<%~%<<"
+    pwdnamed="${(%)pwdnamed}"
+    echo "$pwdnamed"
+    return
+  fi
+
+  local reporoot branch
+  reporoot="${1%%/}"
+  branch="$2"
+
+  # replace named directories in the PWD, we need thi for the proper component
+  # count later
+  local pwdnamed="%~"
+  pwdnamed="${(%)pwdnamed}"
+
+  # store paths in arrays for component count calculation
+  typeset -la apwd apwdnamed areporoot
+  apwd=(${(s:/:)PWD})
+  apwdnamed=(${(s:/:)pwdnamed})
+  areporoot=(${(s:/:)reporoot})
+
+  # get the number of leading and trailing path components. Since we're using
+  # %~ later and then /home/madduck suddenly becomes ~, which is 1, not
+  # 2 components, we calculate the leading component count by using the named
+  # path and the number of post components
+  local precomps postcomps
+  postcomps=$(($#apwd - $#areporoot))
+  precomps=$(($#apwdnamed - $postcomps))
+
+  local postfix
+  if (( $postcomps > 0 )); then
+    postfix="%${postcomps}~"
+    postfix="${(%)postfix}"
+  fi
+
+  # we don't want the prompt to get too long, so keep the total prompt length
+  # under $_PROMPT_PATH_MAXLEN (25), but ensure that the prefix is not shorter
+  # than $_PROMPT_PATH_MINLEN (10), no matter what
+  local prelen minlen prefix
+  prelen=$((${_PROMPT_PATH_MAXLEN:-25} - $#branch - $#postfix))
+  minlen=${_PROMPT_PATH_MINLEN:-10}
+  (( $prelen < $minlen )) && prelen=$minlen
+  prefix="%${prelen}<..<%-${precomps}~%<<"
+  prefix="${(%)prefix}"
+
+  echo "$prefix" "$branch" "$postfix"
+}
+
+__vcs_set_prompt_variables()
+{
+  # set psvar[1..3] depending on repo type, or just psvar[1] if no repo found
+  local reporoot branch repotype
+  repotype="${1:-$(__vcs_get_repo_type)}"
+
+  case "$repotype" in
+    git)
+      reporoot="$(__git_get_reporoot)" ||
+        { error "could not determine git repository root"; return 1 }
+      branch="$(__git_get_branch)" ||
+        { error "could not determine git branch"; return 1 }
+      ;;
+    hg)
+      reporoot="$(__hg_get_reporoot)" ||
+        { error "could not determine hg repository root"; return 1 }
+      branch="$(__hg_get_branch)" ||
+        { error "could not determine hg branch"; return 1 }
+      ;;
+    bzr)
+      reporoot="$(__bzr_get_reporoot)" ||
+        { error "could not determine bzr repository root"; return 1 }
+      branch="$(__bzr_get_branch)" ||
+        { error "could not determine bzr branch"; return 1 }
+      ;;
+    *)
+      case "$repotype" in
+        NONE) :;;
+        *) warn "$repotype repositories not (yet) supported in the prompt";;
+      esac
+      local p="%${MAXLEN}<..<%~%<<"
+      #TODO find a better way so we don't have to nuke $psvar, but since the
+      #     %(nv.true.false) check for prompts checks element count, not
+      #     content, that's all we get for now
+      psvar=("${(%)p}")
+      return
+  esac
+
+  set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch")
+  psvar[1]="$1"
+  psvar[2]="$2"
+  psvar[3]="$3"
+}
+
+if ! is_root; then
+  # too dangerous to be run as root
+
+  _update_vcs_prompt_vars_if_vcs_ran() {
+    local vcs="$(__vcs_get_repo_type)"
+    case "$(history $(($HISTCMD - 1)))" in
+      # $vcs appeared in last command, so be sure to update
+      *${vcs}*) __vcs_set_prompt_variables "$vcs"
+    esac
+  }
+  precmd_functions+=_update_vcs_prompt_vars_if_vcs_ran
+
+  _update_vcs_prompt_vars() {
+    __vcs_set_prompt_variables
+  }
+  chpwd_functions+=_update_vcs_prompt_vars
+
+  # call it once
+  _update_vcs_prompt_vars
+fi
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/70_termfonts b/.zsh/zshrc/70_termfonts
deleted file mode 100644 (file)
index 8fe04f6..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# zshrc/70_termfonts
-#
-# provide helper methods to increase/decrease fonts from the command line
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-typeset -ga _XTERM_FONTS
-_XTERM_FONTS+='-misc-fixed-medium-r-semicondensed-*-13-*-*-*-*-*-iso10646-1'
-_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-13-120-75-75-c-80-iso10646-1'
-_XTERM_FONTS+='-misc-fixed-medium-*-*-*-15-*-*-*-*-*-iso10646-1'
-_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-18-*-*-*-*-*-iso10646-1'
-_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-20-200-75-75-c-100-iso10646-1'
-_XTERM_FONT=${_XTERM_FONT:=1}
-
-_set_xterm_font() {
-  if [ $1 -lt 1 ]; then
-    warn "no smaller font available"
-    _XTERM_FONT=1
-    return 1
-  elif [ $1 -gt $#_XTERM_FONTS ]; then
-    warn "no larger font available"
-    _XTERM_FONT=$#_XTERM_FONTS
-    return 1
-  fi
-  _XTERM_FONT=$1
-  info "selecting font: $_XTERM_FONTS[$_XTERM_FONT]"
-  echo -en "\033]50;$_XTERM_FONTS[$1]\007"
-}
-#_set_xterm_font $_XTERM_FONT 2>/dev/null
-
-f++() { _set_xterm_font $((_XTERM_FONT + 1)) }
-f--() { _set_xterm_font $((_XTERM_FONT - 1)) }
-f0() { _set_xterm_font 1 }
-fx() { _set_xterm_font $#_XTERM_FONTS }
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/80_bindkeys b/.zsh/zshrc/80_bindkeys
new file mode 100644 (file)
index 0000000..4c5ed7a
--- /dev/null
@@ -0,0 +1,15 @@
+# zshrc/90_bindkeys
+#
+# Defines key bindings
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+bindkey -e
+# history expansion on pressing space
+bindkey ' ' magic-space
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/80_history b/.zsh/zshrc/80_history
new file mode 100644 (file)
index 0000000..48a161a
--- /dev/null
@@ -0,0 +1,43 @@
+# zshrc/90_history
+#
+# Set up command line history functions
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+DEFAULT_HISTFILE=$ZVAR/history
+HISTFILE=$DEFAULT_HISTFILE
+HISTSIZE=10000
+SAVEHIST=$HISTSIZE
+LISTMAX=1000
+
+# treat ! specially like csh did
+setopt bang_hist
+
+# ignore duplicates in the history
+setopt hist_ignore_dups
+
+# save timestamp and duration with each event
+setopt extended_history
+
+# properly lock the file on write
+autoload -U is-at-least
+# actually ignores the -dev-* stuff, but so be it
+is-at-least 4.3.6-dev-0+0417 && setopt hist_fcntl_lock
+
+# skip over non-contiguous duplicates when searching history
+setopt hist_find_no_dups
+
+# don't store commands starting with a space in the history file
+setopt hist_ignore_space
+
+# don't store history/fc -l invocations
+setopt hist_no_store
+
+# remove superfluous blanks from each command line
+setopt hist_reduce_blanks
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/80_prompt b/.zsh/zshrc/80_prompt
new file mode 100644 (file)
index 0000000..cdde4da
--- /dev/null
@@ -0,0 +1,22 @@
+# zshrc/90_prompt
+#
+# Formats the shell prompt
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+_MIDDLE="%1v%(2v.|%B%2v%b|.)%(3v.%3v.)"
+if is_root; then
+  _MIDDLE="%25<..<%~%<<"
+  _PS1_HL=U
+fi
+PS1="%${_PS1_HL:=B}%m%${(L)_PS1_HL}:${_MIDDLE}%# "
+unset _PS1_HL
+unset _MIDDLE
+
+RPS1="#%(0?..%?,)%!"
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/80_termfonts b/.zsh/zshrc/80_termfonts
new file mode 100644 (file)
index 0000000..8fe04f6
--- /dev/null
@@ -0,0 +1,40 @@
+# zshrc/70_termfonts
+#
+# provide helper methods to increase/decrease fonts from the command line
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+typeset -ga _XTERM_FONTS
+_XTERM_FONTS+='-misc-fixed-medium-r-semicondensed-*-13-*-*-*-*-*-iso10646-1'
+_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-13-120-75-75-c-80-iso10646-1'
+_XTERM_FONTS+='-misc-fixed-medium-*-*-*-15-*-*-*-*-*-iso10646-1'
+_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-18-*-*-*-*-*-iso10646-1'
+_XTERM_FONTS+='-misc-fixed-medium-r-normal-*-20-200-75-75-c-100-iso10646-1'
+_XTERM_FONT=${_XTERM_FONT:=1}
+
+_set_xterm_font() {
+  if [ $1 -lt 1 ]; then
+    warn "no smaller font available"
+    _XTERM_FONT=1
+    return 1
+  elif [ $1 -gt $#_XTERM_FONTS ]; then
+    warn "no larger font available"
+    _XTERM_FONT=$#_XTERM_FONTS
+    return 1
+  fi
+  _XTERM_FONT=$1
+  info "selecting font: $_XTERM_FONTS[$_XTERM_FONT]"
+  echo -en "\033]50;$_XTERM_FONTS[$1]\007"
+}
+#_set_xterm_font $_XTERM_FONT 2>/dev/null
+
+f++() { _set_xterm_font $((_XTERM_FONT + 1)) }
+f--() { _set_xterm_font $((_XTERM_FONT - 1)) }
+f0() { _set_xterm_font 1 }
+fx() { _set_xterm_font $#_XTERM_FONTS }
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/80_xtermtitle b/.zsh/zshrc/80_xtermtitle
new file mode 100644 (file)
index 0000000..e700aa1
--- /dev/null
@@ -0,0 +1,72 @@
+# zterm-title
+#
+# Fancy setting of the xterm title
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+# Based on http://www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
+#
+
+__set_xterm_title() {
+  case $TERM in
+    screen)
+      print -nR $'\033k'$1$'\033'\\ 
+      print -nR $'\033]0;'$2$'\a'
+      ;;
+    xterm|rxvt*)
+      print -nR $'\033]0;'$*$'\a'
+      ;;
+  esac
+}
+
+__get_session_flags() {
+  [ -n "$SSH_CONNECTION" ] || return
+  local flags; flags=
+  [ -n "$DISPLAY" ] && flags="${flags}x"
+  [ -n "$SSH_AUTH_SOCK" ] && flags="${flags}a"
+  [ -n "$flags" ] && echo "[${flags}]"
+}
+
+__get_standard_prompt() {
+  print -P "%m%#%25\<..\<%~ $(__get_session_flags)"
+}
+
+_set_plain_xterm_title() {
+  __set_xterm_title "$(__get_standard_prompt)"
+}
+precmd_functions+=_set_plain_xterm_title
+
+_set_cmd_xterm_title () {
+    local -a cmd; cmd=(${(z)1})             # Re-parse the command line
+
+    # Construct a command that will output the desired job number.
+    case $cmd[1] in
+        fg) if (( $#cmd == 1 )); then
+                # No arguments, must find the current job
+                cmd=(builtin jobs -l %+)
+            else
+                # Replace the command name, ignore extra args.
+                cmd=(builtin jobs -l ${(Q)cmd[2]})
+            fi;;
+        %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
+        *) # Not resuming a job,
+            __set_xterm_title $cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
+            return;;                        # so we're all done
+    esac
+
+    local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
+
+    # Run the command, read its output, and look up the jobtext.
+    # Could parse $rest here, but $jobtexts (via $jt) is easier.
+    $cmd >>(
+              read num rest
+              cmd=(${(z)${(e):-\$jt$num}})
+              __set_xterm_title $leader$cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
+           )
+}
+preexec_functions+=_set_cmd_xterm_title
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/85_vcs_prompt b/.zsh/zshrc/85_vcs_prompt
deleted file mode 100644 (file)
index a99ca18..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-# zshrc/85_git_prompt
-#
-# Make git information available to the prompt
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-# Shamelessly based on http://glandium.org/blog/?p=170
-#
-
-__git_get_reporoot()
-{
-  # return the full path to the root of the current git repository
-  local relroot
-  relroot="$(git rev-parse --show-cdup 2>/dev/null)" || return 1
-  if [ -n "$relroot" ]; then
-    readlink -f "$relroot"
-  else
-    echo $PWD
-  fi
-}
-
-__git_get_branch()
-{
-  # return the name of the git branch we're on
-  local ref
-  ref=$(git symbolic-ref -q HEAD 2>/dev/null \
-     || git-name-rev --name-only HEAD 2>/dev/null) || return 1
-  echo "${ref#refs/heads/}"
-}
-
-__hg_get_reporoot()
-{
-  hg root
-}
-
-__hg_get_branch()
-{
-  echo "hg:$(hg branch)"
-}
-
-__bzr_get_reporoot()
-{
-  local reporoot
-  reporoot="$(bzr info | sed -rne 's, *branch root: ,,p')"
-  case "$reporoot" in
-    .) echo "$PWD";;
-    *) echo "$reporoot";;
-  esac
-}
-
-__bzr_get_branch()
-{
-  local branch revno
-  bzr version-info | while read i j; do
-      case "$i" in
-        revno:) revno="$j";;
-        branch-nick:) branch="$j";;
-      esac
-    done
-  echo "bzr:${branch}@$revno"
-}
-
-__vcs_get_repo_type()
-{
-  # return the type of the closest repository in the path hierarchy
-  local dir
-  while true; do
-    [ -d ${dir}.git ] && echo git && break
-    [ -d ${dir}.bzr ] && echo bzr && break
-    [ -d ${dir}.hg ] && echo hg && break
-    [ "$(readlink -f ${dir:-.})" = / ] && echo NONE && break
-    dir="../$dir"
-  done
-}
-
-__vcs_get_prompt_path_components()
-{
-  # return formatted path components (prefix branch postfix) given
-  # the repository root and the branch.
-
-  # shortcut: if there are no arguments, return a default prompt
-  if [ -z "${1:-}" ]; then
-    pwdnamed="%${_PROMPT_PATH_MAXLEN}<..<%~%<<"
-    pwdnamed="${(%)pwdnamed}"
-    echo "$pwdnamed"
-    return
-  fi
-
-  local reporoot branch
-  reporoot="${1%%/}"
-  branch="$2"
-
-  # replace named directories in the PWD, we need thi for the proper component
-  # count later
-  local pwdnamed="%~"
-  pwdnamed="${(%)pwdnamed}"
-
-  # store paths in arrays for component count calculation
-  typeset -la apwd apwdnamed areporoot
-  apwd=(${(s:/:)PWD})
-  apwdnamed=(${(s:/:)pwdnamed})
-  areporoot=(${(s:/:)reporoot})
-
-  # get the number of leading and trailing path components. Since we're using
-  # %~ later and then /home/madduck suddenly becomes ~, which is 1, not
-  # 2 components, we calculate the leading component count by using the named
-  # path and the number of post components
-  local precomps postcomps
-  postcomps=$(($#apwd - $#areporoot))
-  precomps=$(($#apwdnamed - $postcomps))
-
-  local postfix
-  if (( $postcomps > 0 )); then
-    postfix="%${postcomps}~"
-    postfix="${(%)postfix}"
-  fi
-
-  # we don't want the prompt to get too long, so keep the total prompt length
-  # under $_PROMPT_PATH_MAXLEN (25), but ensure that the prefix is not shorter
-  # than $_PROMPT_PATH_MINLEN (10), no matter what
-  local prelen minlen prefix
-  prelen=$((${_PROMPT_PATH_MAXLEN:-25} - $#branch - $#postfix))
-  minlen=${_PROMPT_PATH_MINLEN:-10}
-  (( $prelen < $minlen )) && prelen=$minlen
-  prefix="%${prelen}<..<%-${precomps}~%<<"
-  prefix="${(%)prefix}"
-
-  echo "$prefix" "$branch" "$postfix"
-}
-
-__vcs_set_prompt_variables()
-{
-  # set psvar[1..3] depending on repo type, or just psvar[1] if no repo found
-  local reporoot branch repotype
-  repotype="${1:-$(__vcs_get_repo_type)}"
-
-  case "$repotype" in
-    git)
-      reporoot="$(__git_get_reporoot)" ||
-        { error "could not determine git repository root"; return 1 }
-      branch="$(__git_get_branch)" ||
-        { error "could not determine git branch"; return 1 }
-      ;;
-    hg)
-      reporoot="$(__hg_get_reporoot)" ||
-        { error "could not determine hg repository root"; return 1 }
-      branch="$(__hg_get_branch)" ||
-        { error "could not determine hg branch"; return 1 }
-      ;;
-    bzr)
-      reporoot="$(__bzr_get_reporoot)" ||
-        { error "could not determine bzr repository root"; return 1 }
-      branch="$(__bzr_get_branch)" ||
-        { error "could not determine bzr branch"; return 1 }
-      ;;
-    *)
-      case "$repotype" in
-        NONE) :;;
-        *) warn "$repotype repositories not (yet) supported in the prompt";;
-      esac
-      local p="%${MAXLEN}<..<%~%<<"
-      #TODO find a better way so we don't have to nuke $psvar, but since the
-      #     %(nv.true.false) check for prompts checks element count, not
-      #     content, that's all we get for now
-      psvar=("${(%)p}")
-      return
-  esac
-
-  set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch")
-  psvar[1]="$1"
-  psvar[2]="$2"
-  psvar[3]="$3"
-}
-
-if ! is_root; then
-  # too dangerous to be run as root
-
-  _update_vcs_prompt_vars_if_vcs_ran() {
-    local vcs="$(__vcs_get_repo_type)"
-    case "$(history $(($HISTCMD - 1)))" in
-      # $vcs appeared in last command, so be sure to update
-      *${vcs}*) __vcs_set_prompt_variables "$vcs"
-    esac
-  }
-  precmd_functions+=_update_vcs_prompt_vars_if_vcs_ran
-
-  _update_vcs_prompt_vars() {
-    __vcs_set_prompt_variables
-  }
-  chpwd_functions+=_update_vcs_prompt_vars
-
-  # call it once
-  _update_vcs_prompt_vars
-fi
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/89_dircolors b/.zsh/zshrc/89_dircolors
deleted file mode 100644 (file)
index d084875..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# zshrc/90_dircolors
-#
-# Load dircolors database
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-eval $(dircolors $ZDOTDIR/dircolors) 2>/dev/null || :
-
-if [ -n "$LS_COLORS" ]; then
-  # uniquify LS_COLORS due to #479544
-
-  typeset -A pairs
-  for pair in ${(s.:.)LS_COLORS}; do
-    [ -z "${pair%%\=*}" ] && continue
-    pairs["${pair%%\=*}"]="${pair#*=}"
-  done
-
-  typeset -a items
-  for key in ${(k)pairs}; do
-    [ "$pairs[$key]" = 00 ] && continue #removes styles handled by normal
-    items+="${(Q)key}=$pairs[$key]"
-  done
-  LS_COLORS="${(j.:.)items}:"
-else
-  # fallback
-  LS_COLORS="di=01;30:ln=target:ex=00;34:no=00:fi=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tbz2=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00:*.jpeg=00:*.gif=00:*.bmp=00:*.pbm=00:*.pgm=00:*.ppm=00:*.tga=00:*.xbm=00:*.xpm=00:*.tif=00:*.tiff=00:*.png=00:*.svg=00:*.mng=00:*.pcx=00:*.mov=00:*.mpg=00:*.mpeg=00:*.m2v=00:*.mkv=00:*.ogm=00:*.mp4=00:*.m4v=00:*.mp4v=00:*.vob=00:*.qt=00:*.nuv=00:*.wmv=00:*.asf=00:*.rm=00:*.rmvb=00:*.flc=00:*.avi=00:*.fli=00:*.gl=00:*.dl=00:*.xcf=00:*.xwd=00:*.yuv=00:*.aac=00:*.au=00:*.flac=00:*.mid=00:*.midi=00:*.mka=00:*.mp3=00:*.mpc=00:*.ogg=00:*.ra=00:*.wav=00"
-fi
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/90_bindkeys b/.zsh/zshrc/90_bindkeys
deleted file mode 100644 (file)
index 4c5ed7a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# zshrc/90_bindkeys
-#
-# Defines key bindings
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-bindkey -e
-# history expansion on pressing space
-bindkey ' ' magic-space
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/90_history b/.zsh/zshrc/90_history
deleted file mode 100644 (file)
index 48a161a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# zshrc/90_history
-#
-# Set up command line history functions
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-DEFAULT_HISTFILE=$ZVAR/history
-HISTFILE=$DEFAULT_HISTFILE
-HISTSIZE=10000
-SAVEHIST=$HISTSIZE
-LISTMAX=1000
-
-# treat ! specially like csh did
-setopt bang_hist
-
-# ignore duplicates in the history
-setopt hist_ignore_dups
-
-# save timestamp and duration with each event
-setopt extended_history
-
-# properly lock the file on write
-autoload -U is-at-least
-# actually ignores the -dev-* stuff, but so be it
-is-at-least 4.3.6-dev-0+0417 && setopt hist_fcntl_lock
-
-# skip over non-contiguous duplicates when searching history
-setopt hist_find_no_dups
-
-# don't store commands starting with a space in the history file
-setopt hist_ignore_space
-
-# don't store history/fc -l invocations
-setopt hist_no_store
-
-# remove superfluous blanks from each command line
-setopt hist_reduce_blanks
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/90_prompt b/.zsh/zshrc/90_prompt
deleted file mode 100644 (file)
index cdde4da..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# zshrc/90_prompt
-#
-# Formats the shell prompt
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-_MIDDLE="%1v%(2v.|%B%2v%b|.)%(3v.%3v.)"
-if is_root; then
-  _MIDDLE="%25<..<%~%<<"
-  _PS1_HL=U
-fi
-PS1="%${_PS1_HL:=B}%m%${(L)_PS1_HL}:${_MIDDLE}%# "
-unset _PS1_HL
-unset _MIDDLE
-
-RPS1="#%(0?..%?,)%!"
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/90_xterm_title b/.zsh/zshrc/90_xterm_title
deleted file mode 100644 (file)
index e700aa1..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-# zterm-title
-#
-# Fancy setting of the xterm title
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-# Based on http://www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
-#
-
-__set_xterm_title() {
-  case $TERM in
-    screen)
-      print -nR $'\033k'$1$'\033'\\ 
-      print -nR $'\033]0;'$2$'\a'
-      ;;
-    xterm|rxvt*)
-      print -nR $'\033]0;'$*$'\a'
-      ;;
-  esac
-}
-
-__get_session_flags() {
-  [ -n "$SSH_CONNECTION" ] || return
-  local flags; flags=
-  [ -n "$DISPLAY" ] && flags="${flags}x"
-  [ -n "$SSH_AUTH_SOCK" ] && flags="${flags}a"
-  [ -n "$flags" ] && echo "[${flags}]"
-}
-
-__get_standard_prompt() {
-  print -P "%m%#%25\<..\<%~ $(__get_session_flags)"
-}
-
-_set_plain_xterm_title() {
-  __set_xterm_title "$(__get_standard_prompt)"
-}
-precmd_functions+=_set_plain_xterm_title
-
-_set_cmd_xterm_title () {
-    local -a cmd; cmd=(${(z)1})             # Re-parse the command line
-
-    # Construct a command that will output the desired job number.
-    case $cmd[1] in
-        fg) if (( $#cmd == 1 )); then
-                # No arguments, must find the current job
-                cmd=(builtin jobs -l %+)
-            else
-                # Replace the command name, ignore extra args.
-                cmd=(builtin jobs -l ${(Q)cmd[2]})
-            fi;;
-        %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
-        *) # Not resuming a job,
-            __set_xterm_title $cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
-            return;;                        # so we're all done
-    esac
-
-    local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
-
-    # Run the command, read its output, and look up the jobtext.
-    # Could parse $rest here, but $jobtexts (via $jt) is easier.
-    $cmd >>(
-              read num rest
-              cmd=(${(z)${(e):-\$jt$num}})
-              __set_xterm_title $leader$cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
-           )
-}
-preexec_functions+=_set_cmd_xterm_title
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/95_fortune.disabled b/.zsh/zshrc/95_fortune.disabled
new file mode 100644 (file)
index 0000000..11d843b
--- /dev/null
@@ -0,0 +1,13 @@
+# zshrc/99_fortune
+#
+# Prints a fortune cookie to each interactive shell
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+fortune -a 2>/dev/null || :
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/95_watch b/.zsh/zshrc/95_watch
new file mode 100644 (file)
index 0000000..29e2d97
--- /dev/null
@@ -0,0 +1,14 @@
+# zshrc/98_watch
+#
+# watch activity of other users
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+watch=(notme)
+LOGCHECK=120
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/98_watch b/.zsh/zshrc/98_watch
deleted file mode 100644 (file)
index 29e2d97..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# zshrc/98_watch
-#
-# watch activity of other users
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-watch=(notme)
-LOGCHECK=120
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/99_TODO b/.zsh/zshrc/99_TODO
new file mode 100644 (file)
index 0000000..dc1294b
--- /dev/null
@@ -0,0 +1,62 @@
+# zshrc/00_TODO
+#
+# All kinds of stuff not yet split to other files
+# TEMPORARY
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+ldir() { eval $1="$PWD" ; : ~$1 }
+
+alias Q='exec zsh'
+alias ozsh='ZDOTDIR=$HOME/.etc/zsh exec zsh'
+
+# do not clobber files with >
+setopt noclobber
+
+# automatically maintain a directory stack
+setopt autopushd pushdminus pushdsilent pushdtohome
+
+# brace expansion
+setopt braceccl
+
+# print backgrounded jobs when they finish
+setopt notify
+# bg-processes should not be nice
+unsetopt bgnice
+# send no HUP signal to running jobs when the shell exits
+setopt nohup
+# don't bother me with running jobs (only wize with setopt nohup)
+unsetopt checkjobs
+
+# disable backslashed escape sequences unless -e is given to echo 
+setopt bsd_echo
+
+[ "$(umask)" = 022 ] && umask 0077
+
+eval `lesspipe 2>/dev/null`
+
+WORDCHARS="*?_-.[]~/&;!#$%^(){}<>"
+
+# report time stats when command takes longer than 5 seconds
+REPORTTIME=5
+
+MAILCHECK=0
+
+# http://grml.org/zsh/zsh-lovers.html
+rationalise-dot() {
+  if [[ $LBUFFER = *.. ]]; then
+    LBUFFER+=/..
+  else
+    LBUFFER+=.
+  fi
+}
+zle -N rationalise-dot
+bindkey . rationalise-dot
+
+:
+
+# vim:ft=zsh
diff --git a/.zsh/zshrc/99_fortune.disabled b/.zsh/zshrc/99_fortune.disabled
deleted file mode 100644 (file)
index 11d843b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# zshrc/99_fortune
-#
-# Prints a fortune cookie to each interactive shell
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-fortune -a 2>/dev/null || :
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/99_hook_functions b/.zsh/zshrc/99_hook_functions
deleted file mode 100644 (file)
index 34abb0e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# zshrc/99_hook_functions
-#
-# define hook functions in case the *_functions arrays are not honoured
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-
-autoload -U is-at-least
-if ! is-at-least 4.3.6; then
-  for i in precmd preexec chpwd periodic; do
-    if [ -n "$functions[$i]" ]; then
-      warn "$i function already defined"
-      continue
-    fi
-    eval "${i}() { for fn (\$${i}_functions) \$fn \"\$@\" }"
-  done
-fi
-
-# vim:ft=zsh
diff --git a/.zsh/zshrc/99_hookfunctions b/.zsh/zshrc/99_hookfunctions
new file mode 100644 (file)
index 0000000..34abb0e
--- /dev/null
@@ -0,0 +1,22 @@
+# zshrc/99_hook_functions
+#
+# define hook functions in case the *_functions arrays are not honoured
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+autoload -U is-at-least
+if ! is-at-least 4.3.6; then
+  for i in precmd preexec chpwd periodic; do
+    if [ -n "$functions[$i]" ]; then
+      warn "$i function already defined"
+      continue
+    fi
+    eval "${i}() { for fn (\$${i}_functions) \$fn \"\$@\" }"
+  done
+fi
+
+# vim:ft=zsh