From: martin f. krafft Date: Sun, 4 May 2008 23:08:54 +0000 (+0100) Subject: initial checkin X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/9a1960b5edade792e0d4d9a8c8e0630e774affc5 initial checkin --- 9a1960b5edade792e0d4d9a8c8e0630e774affc5 diff --git a/.zsh/.zlogin b/.zsh/.zlogin new file mode 120000 index 0000000..8eae6ef --- /dev/null +++ b/.zsh/.zlogin @@ -0,0 +1 @@ +rcsstub \ No newline at end of file diff --git a/.zsh/.zlogout b/.zsh/.zlogout new file mode 120000 index 0000000..8eae6ef --- /dev/null +++ b/.zsh/.zlogout @@ -0,0 +1 @@ +rcsstub \ No newline at end of file diff --git a/.zsh/.zprofile b/.zsh/.zprofile new file mode 120000 index 0000000..8eae6ef --- /dev/null +++ b/.zsh/.zprofile @@ -0,0 +1 @@ +rcsstub \ No newline at end of file diff --git a/.zsh/.zshenv b/.zsh/.zshenv new file mode 120000 index 0000000..8eae6ef --- /dev/null +++ b/.zsh/.zshenv @@ -0,0 +1 @@ +rcsstub \ No newline at end of file diff --git a/.zsh/.zshrc b/.zsh/.zshrc new file mode 120000 index 0000000..8eae6ef --- /dev/null +++ b/.zsh/.zshrc @@ -0,0 +1 @@ +rcsstub \ No newline at end of file diff --git a/.zsh/header b/.zsh/header new file mode 100644 index 0000000..74219d0 --- /dev/null +++ b/.zsh/header @@ -0,0 +1,11 @@ +# +# +# +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + + diff --git a/.zsh/logging b/.zsh/logging new file mode 100644 index 0000000..2cdf7d8 --- /dev/null +++ b/.zsh/logging @@ -0,0 +1,39 @@ +# logging +# +# Logging abilities for the shell initialisation scripts +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +__log() { + local level; level="$1"; shift + echo "${level}: $@" >&2 +} +__do_debug() { + [ -n "${ZDEBUG:-}" ] +} +error() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log E "$@" + [ "${__XTRACE:-}" ] && set -x +} +warn() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log W "$@" + [ "${__XTRACE:-}" ] && set -x +} +info() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __log I "$@" + [ "${__XTRACE:-}" ] && set -x +} +debug() { + [[ -o xtrace ]] && set +x && local __XTRACE=1 + __do_debug && __log D "$@" + [ "${__XTRACE:-}" ] && set -x +} + +# vim:ft=zsh diff --git a/.zsh/rcsstub b/.zsh/rcsstub new file mode 100644 index 0000000..b7c3f83 --- /dev/null +++ b/.zsh/rcsstub @@ -0,0 +1,24 @@ +# .zshenv +# +# Actual .zshenv file +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +. $ZDOTDIR/logging +. $ZDOTDIR/util + +if [[ -o rcs ]]; then + __do_debug && set -x + + file="$(print -P %1N)" + . $ZDOTDIR/sourcedir + sourcedir $ZDOTDIR/${file#.} + + __do_debug && set +x +fi + +# vim:ft=zsh diff --git a/.zsh/sourcedir b/.zsh/sourcedir new file mode 100644 index 0000000..582f255 --- /dev/null +++ b/.zsh/sourcedir @@ -0,0 +1,28 @@ +# sourcedir +# +# Defines helper function to source files in a directory +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +. $ZDOTDIR/logging + +sourcedir() { + if [ ! -d "$1" ]; then + error "no such directory: ${1#$ZDOTDIR/}" + return 1 + fi + debug "sourcing directory ${1#$ZDOTDIR/}" + for f in "$1"/*(.); do + case "$f" in + *~|*.bak|*.sw?|*.zwc|*.disabled) continue;; + esac + debug " sourcing file $f" + . "$f" + done +} + +# vim:ft=zsh diff --git a/.zsh/util b/.zsh/util new file mode 100644 index 0000000..6c8970a --- /dev/null +++ b/.zsh/util @@ -0,0 +1,15 @@ +# util +# +# Miscellaneous utility functions +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +is_root() { + test ${EUID:?} -eq 0 +} + +# vim:ft=zsh diff --git a/.zsh/xterm-title b/.zsh/xterm-title new file mode 100644 index 0000000..07755a6 --- /dev/null +++ b/.zsh/xterm-title @@ -0,0 +1,69 @@ +# zterm-title +# +# Fancy setting of the xterm title +# +# Copyright © 1994–2008 martin f. krafft +# 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() { + 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)" +} + +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)" + ) +} + +# vim:ft=zsh diff --git a/.zsh/zlogout/90_sudo b/.zsh/zlogout/90_sudo new file mode 100644 index 0000000..175677d --- /dev/null +++ b/.zsh/zlogout/90_sudo @@ -0,0 +1,13 @@ +# zlogout/90_sudo +# +# Invalidates any existing sudo sessions +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +sudo -K 2>/dev/null || : + +# vim:ft=zsh diff --git a/.zsh/zprofile/00_nocores b/.zsh/zprofile/00_nocores new file mode 100644 index 0000000..d295464 --- /dev/null +++ b/.zsh/zprofile/00_nocores @@ -0,0 +1,13 @@ +# zprofile/00_nocores +# +# Turns of core file generation +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +ulimit -c 0 + +# vim:ft=zsh diff --git a/.zsh/zshenv/00_fpath b/.zsh/zshenv/00_fpath new file mode 100644 index 0000000..d977983 --- /dev/null +++ b/.zsh/zshenv/00_fpath @@ -0,0 +1,13 @@ +# zshenv/00_fpath +# +# Adds local functions directory to $fpath +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +FPATH="$ZDOTDIR/func:$FPATH" + +# vim:ft=zsh diff --git a/.zsh/zshenv/00_rdirs b/.zsh/zshenv/00_rdirs new file mode 100644 index 0000000..062c011 --- /dev/null +++ b/.zsh/zshenv/00_rdirs @@ -0,0 +1,17 @@ +# zshenv/00_rdirs +# +# Assigns paths to related directories to a number of variables +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +export VAR_RELATIVE=.var +export VAR=$HOME/$VAR_RELATIVE +export ZVAR=$VAR/zsh +export BIN_RELATIVE=.bin +export BIN=$HOME/$BIN_RELATIVE + +# vim:ft=zsh diff --git a/.zsh/zshrc/00_TODO b/.zsh/zshrc/00_TODO new file mode 100644 index 0000000..577cd67 --- /dev/null +++ b/.zsh/zshrc/00_TODO @@ -0,0 +1,51 @@ +# zshrc/00_TODO +# +# All kinds of stuff not yet split to other files +# TEMPORARY +# +# Copyright © 1994–2008 martin f. krafft +# 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' + +# correct all arguments +setopt correctall + +# do not clobber files with > +setopt noclobber + +# automatically maintain a directory stack +setopt autopushd pushdminus pushdsilent pushdtohome + +# brace expansion +setopt braceccl + +# commands that take commands as arguments +compctl -c man nohup strace gdb + +# automatically remove duplicates from these arrays +typeset -gU path cdpath fpath manpath + +# http://xanana.ucsc.edu/~wgscott/wordpress_new/wordpress/?p=12 +typeset -ga preexec_functions +typeset -ga precmd_functions +typeset -ga chpwd_functions + +. $ZDOTDIR/xterm-title + +precmd_functions+=set_plain_xterm_title +preexec_functions+=set_cmd_xterm_title + +[ "$(umask)" = 022 ] && umask 0077 + +eval `lesspipe 2>/dev/null` + +: + +# vim:ft=zsh diff --git a/.zsh/zshrc/00_autoload b/.zsh/zshrc/00_autoload new file mode 100644 index 0000000..6098311 --- /dev/null +++ b/.zsh/zshrc/00_autoload @@ -0,0 +1,15 @@ +# zshrc/00_autoload +# +# Autoload available functions +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +# for p ($fpath) for fn ($p/**) autoload ${fn##*/} +autoload $^fpath/*(.xN:t) +autoload zargs + +# vim:ft=zsh diff --git a/.zsh/zshrc/25_tempfiles b/.zsh/zshrc/25_tempfiles new file mode 100644 index 0000000..1c1d551 --- /dev/null +++ b/.zsh/zshrc/25_tempfiles @@ -0,0 +1,23 @@ +# zshrc/25_tempfiles +# +# Helper functions to create temporary files and directories +# +# Copyright © 1994–2008 martin f. krafft +# 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 + echo $tmpfile +} + +# vim:ft=zsh diff --git a/.zsh/zshrc/30_aliases b/.zsh/zshrc/30_aliases new file mode 100644 index 0000000..7d78a1a --- /dev/null +++ b/.zsh/zshrc/30_aliases @@ -0,0 +1,25 @@ +# zshrc/30_aliases +# +# Defines command shortcuts +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +alias mv='nocorrect mv' # no spelling correction on mv +alias cp='nocorrect cp' # no spelling correction on cp +alias mkdir='nocorrect mkdir' # no spelling correction on mkdir +alias find='noglob find' # no globbing for find + +alias grep=egrep + +alias ls='ls --color=auto' +alias ll='ls -l' +alias la='ls -a' +alias lla='ls -la' +# List only directories and symbolic links that point to directories +alias lsd='ls -ld *(-/DN)' + +# vim:ft=zsh diff --git a/.zsh/zshrc/90_bindkeys b/.zsh/zshrc/90_bindkeys new file mode 100644 index 0000000..4c5ed7a --- /dev/null +++ b/.zsh/zshrc/90_bindkeys @@ -0,0 +1,15 @@ +# zshrc/90_bindkeys +# +# Defines key bindings +# +# Copyright © 1994–2008 martin f. krafft +# 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_compctl b/.zsh/zshrc/90_compctl new file mode 100644 index 0000000..cfdbed8 --- /dev/null +++ b/.zsh/zshrc/90_compctl @@ -0,0 +1,14 @@ +# zshrc/90_compctl +# +# Configures the completions system +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +# make tab completion work the way i like it +setopt autolist automenu recexact alwaystoend + +# vim:ft=zsh diff --git a/.zsh/zshrc/90_history b/.zsh/zshrc/90_history new file mode 100644 index 0000000..b4e49c6 --- /dev/null +++ b/.zsh/zshrc/90_history @@ -0,0 +1,40 @@ +# zshrc/90_history +# +# Set up command line history functions +# +# Copyright © 1994–2008 martin f. krafft +# 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 + +# do not treat ! specially like csh did +setopt no_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 +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 new file mode 100644 index 0000000..0abe132 --- /dev/null +++ b/.zsh/zshrc/90_prompt @@ -0,0 +1,16 @@ +# zshrc/90_prompt +# +# Formats the shell prompt +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +is_root && PS1_HL=U +PS1="%${PS1_HL:=B}%m%${(L)PS1_HL}:%25<..<%~%# " +unset PS1_HL +RPS1="#[%(0?..%?,)%!]%v" + +# vim:ft=zsh diff --git a/.zsh/zshrc/99_fortune b/.zsh/zshrc/99_fortune new file mode 100644 index 0000000..3e1fc2b --- /dev/null +++ b/.zsh/zshrc/99_fortune @@ -0,0 +1,13 @@ +# zshrc/99_fortune +# +# Prints a fortune cookie to each interactive shell +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +fortune 2>/dev/null || : + +# vim:ft=zsh diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..3a9c4b9 --- /dev/null +++ b/.zshenv @@ -0,0 +1,12 @@ +# .zshenv +# +# Base zshenv file which simply delegates to files in $ZDOTDIR +# +# Copyright © 1994–2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +ZDOTDIR=$HOME/.zsh +[ -f $ZDOTDIR/.zshenv ] && . $ZDOTDIR/.zshenv