# These names are case insensitive and underscores are ignored. For
# example, `allexport' is equivalent to `A__lleXP_ort'.

# Initialisation for new style completion.
if [[ "$ZSH_VERSION" == (3.1|4)* ]]; then
	autoload -U compinit
	compinit -C
else
	print "Advanced completion system not found; ignoring zstyle settings."
	function zstyle { }
fi

#--------------------------------------------------
# if [[ "$ZSH_VERSION" == 4.2.<0->* ]]; then
# 	# If you now paste a url it will be magically quoted!
# 	# But it only works on 4.2.0 and later.
# 	autoload -U url-quote-magic
# 	zle -N self-insert url-quote-magic
# fi
#-------------------------------------------------- 

# This tries to find wordcode files and automatically re-compile them if
# at least one of the original files is newer than the wordcode file.
  autoload zrecompile
# This is a multiple move based on zsh pattern matching (like "mmv").
# Read ``less ${^fpath}/zmv(N)'' for more details
  autoload zmv
# Edit small files with the command line editor.
  autoload -U zed
# Like xargs, but instead of reading lines of arguments from standard input,
# it takes them from the command line. This is possible/useful because,
# especially with recursive glob operators, zsh often can construct a command
# line for a shell function that is longer than can be accepted by an external
# command. This is what's often referred to as the "shitty Linux exec limit" ;)
# The limitation is on the number of characters or arguments.
#  $ =echo {1..30000}
#  zsh: argument list too long: /bin/echo
#  $ autoload -U zargs
#  $ zargs -- =echo {1..30000}
#  [ long list ;) ]
   autoload -U zargs
# This autoloadable function checks the folders specified as arguments
# for new mails.
#  autoload -U checkmail
# Edit the command line using your usual editor.
#  autoload -U edit-command-line

# This module should be automatically loaded if u use menu selection but
# to be sure we do it here
  zmodload -i zsh/complist
# Autoload zsh modules when they are referenced
# A builtin command interface to the stat system call
  zmodload -a zsh/stat stat
# A builtin that can clone a running shell onto another terminal.
  zmodload -e zsh/clone

# Watch for logins
watch=(notme)

# allow me to cd directly into a dir in $PORTS_DIR from anywhere
#  $ cd shells && pwd
#  /usr/ports/shells
if [ "${OS}" = OpenBSD ]; then
	cdpath=( ${PORTS_DIR} )
fi

# When listing options (by `setopt', `unsetopt', `set -o' or `set +o'),
# those turned on by default appear in the list prefixed with `no'.
# Hence (unless KSH_OPTION_PRINT is set), `setopt' shows all options
# whose settings are changed from the default.
#
# Report the status of background jobs immediately, rather than
# waiting until just before printing a prompt.
setopt notify 

# Allow comments even in interactive shells i. e.
# $ uname # This command prints system informations
# zsh: bad pattern: #
# $ setopt interactivecomments
# $ uname # This command prints system informations
# OpenBSD
setopt interactivecomments

# Send *not* a HUP signal to running jobs when the shell exits.
setopt nohup

# Print a carriage return just before printing a prompt in the line
# editor. For example:
#  $ echo foo
#  foo
#  $ echo -n foo
#  $ setopt nopromptcr
#  $ echo -n foo
#  foo$
#--------------------------------------------------
# setopt nopromptcr
#-------------------------------------------------- 

# Perform =filename access
#  $ setopt EQUALS
#  $ echo =ls
#  /bin/ls
#  $ unsetopt EQUALS
#  $ echo =ls 
#  =ls
setopt equals

# Beep on an ambiguous completion.  More accurately, this forces the
# completion widgets to return status 1 on an ambiguous completion, which
# causes the shell to beep if the option BEEP is also set; this may
# be modified if completion is called from a user-defined widget.
setopt nolistbeep

# Try to make the completion list smaller (occupying less lines) by
# printing the matches in columns with different widths.
setopt list_packed

# Do not exit on end-of-file.  Require the use of exit or logout instead.
# However, ten consecutive EOFs will cause the shell to exit anyway, to
# avoid the shell hanging if its tty goes away. Also, if this option is
# set and the Zsh Line Editor is used, widgets implemented by shell
# functions can be bound to EOF (normally Control-D) without printing
# the normal warning message.  This works only for normal widgets, not
# for completion widgets.
#setopt ignore_eof

# if the braces aren't in either of the above forms, expands single
# letters and ranges of letters, i. e.:
#  $ print 1{abw-z}2
#  $ 1a2 1b2 1w2 1x2 1y2 1z2
setopt braceccl

# Make the echo builtin compatible with the BSD man page echo(1)
# command.
#  $ echo "foo\bar\baz"
#  foaaz
#  $ unsetopt bsdecho
#  $ echo "foo\bar\baz"
#  foo\bar\baz
unsetopt bsdecho

# If the argument to a cd command (or an implied cd with the
# AUTO_CD option set) is not a directory, and does not begin with a
# slash, try to expand the expression as if it were preceded by a
# '~' (see section Filename Expansion).
setopt cdablevars

# Report the status of background and suspended jobs before exiting a shell
# with job control; a second attempt to exit the shell will succeed.
setopt checkjobs

# Make cd push the old directory onto the directory stack. 
setopt autopushd 

# change to directory without "cd"
setopt autocd

# Exchanges the meanings of `+' and `-' when used with a number to 
# specify a directory in the stack.      
setopt pushdminus

# If set, parameter expansion, command substitution and arithmetic 
# expansion are performed in prompts.   
setopt pushdsilent

# Treat the '#', '~' and '^' characters as part of patterns 
# for filename generation, etc. (An initial unquoted '~'
# always produces named directory expansion.)
# | $ grep word *~(*.gz|*.bz|*.bz2|*.zip|*.Z)
# searches for word not in compressed files
setopt extendedglob 

# Do query the user before executing 'rm *' or 'rm path/*'
# $ rm -rf *
# zsh: sure you want to delete all the files in /home/dope/foo [yn]?
setopt normstarsilent 

# If querying the user before executing `rm *' or `rm path/*',
# first wait ten seconds and ignore anything typed in that time.
# This avoids the problem of reflexively answering `yes' to the query
# when one didn't really mean it. The wait and query can always be
# avoided by expanding the `*' in ZLE (with tab).
setopt no_rm_star_wait

# Shut up ;)
setopt nobeep 

# Beep when an attempt is made to access a history entry which
# isn't there.
setopt histbeep

# When writing out the history file, older commands that duplicate newer ones
# are omitted.
setopt HISTSAVENODUPS

# When searching for history entries in the line editor, do not display
# duplicates of a line previously found, even if the duplicates are not
# contiguous.                       
setopt HISTFINDNODUPS

# If the internal history needs to be trimmed to add the current command line,
# setting this option will cause the oldest history event that has a duplicate
# to be lost before losing a unique event from the list.
# You should be sure to set the value of HISTSIZE to a larger number
# than SAVEHIST in order to give you some room for the duplicated
# events, otherwise this option will behave just like HIST_IGNORE_ALL_DUPS
# once the history fills up with unique events.
setopt hist_expire_dups_first

# If a new command line being added to the history list duplicates an
# older one, the older command is removed from the list (even if it is
# not the previous event).
setopt hist_ignore_all_dups

# Do not enter command lines into the history list
# if they are duplicates of the previous event.
setopt hist_ignore_dups

# Remove command lines from the history list when the first character on
# the line is a space, or when one of the expanded aliases contains a
# leading space.
# Note that the command lingers in the internal history until the next
# command is entered before it vanishes, allowing you to briefly reuse
# or edit the line.  If you want to make it vanish right away without
# entering another command, type a space and press return.
setopt hist_ignore_space

# HIST_REDUCE_BLANKS
# Remove superfluous blanks from each command line
# being added to the history list.
setopt hist_reduce_blanks

# Whenever the user enters a line with history expansion,
# don't execute the line directly; instead, perform
# history expansion and reload the line into the editing buffer.
setopt hist_verify

# Remove function definitions from the history list.
# Note that the function lingers in the internal history until the next
# command is entered before it vanishes, allowing you to briefly reuse
# or edit the definition.
#setopt hist_no_functions

# Remove the history (fc -l) command from the history list
# when invoked.
# Note that the command lingers in the internal history until the next
# command is entered before it vanishes, allowing you to briefly reuse
# or edit the line.
setopt hist_no_store

# If this is set, zsh sessions will append their history list to
# the history file, rather than overwrite it. Thus, multiple parallel
# zsh sessions will all have their history lists added to the
# history file, in the order they are killed
setopt appendhistory

# If unset, the cursor is set to the end of the word if completion is
# started. Otherwise it stays there and completion is done from both ends.
setopt completeinword 

#  When listing files that are possible completions, show the
# type of each file with a trailing identifying mark.
setopt list_types

#  Do not require a leading '.' in a filename to be matched explicitly.
setopt globdots

# Try to correct the spelling of all arguments in a line.
setopt correctall

# List jobs in the long format by default.
setopt longlistjobs 

# Print eight bit characters literally in completion lists, etc.
# This option is not necessary if your system correctly returns the
# printability of eight bit characters (see man page ctype(3)).
setopt printeightbit

# Don't push multiple copies of the same directory onto the directory
# stack
setopt pushdignoredups 

# This option both imports new commands from the history file, and also
# causes your typed commands to be appended to the history file (the
# latter is like specifying INC_APPEND_HISTORY).
# The history lines are also output with timestamps ala
# EXTENDED_HISTORY (which makes it easier to find the spot where
# we left off reading the file after it gets re-written).
setopt sharehistory 

# Try to correct the spelling of all arguments in a line.
# No .. not really .. it's make me crazy *g*
# setopt correctall

# Save each command's beginning timestamp (in seconds since the epoch)
# and the duration (in seconds) to the history file.  The format of
# this prefixed data is:
# ':<beginning time>:<elapsed seconds>;<command>'.
# i. e.:
#  : 1054961691:0;/usr/games/fortune -f
setopt EXTENDEDHISTORY

# Allow the short forms of for, select, if, and function constructs, i.
# e.: ``for i (*.o) rm $i'' instead of ``for i in *.o; do rm $i; done''
setopt shortloops

# Do *not* run all background jobs at a lower priority
  unsetopt bgnice 
# If this option is unset, output flow control via start/stop characters
# (usually assigned to ^S/^Q) disabled in the shell's editor.
  unsetopt flow_control
