[oclug] Zsh config file

Dan Cardamore dan at hld.ca
Tue Mar 5 00:28:02 EST 2002


There was some talk about shell's last week and zsh was mentioned.  I
always wanted to give it a go, so I finally made the leap from bash.

So far I've been very impressed.  It can do everything that I had bash
doing and a couple extras.  I've attached my .zshrc file in case anyone
else wants to try it out.

Some of the extra-nifty things it does are:
 - watches users log in and out of the system
 - watches for new mail in several different folders
 - colour prompt.  type 'prompt -l' to see other themes.

All in all, its a very nice shell.

Dan

__________________________________________________________________________
    Dan Cardamore        finger://dan@hld.ca         http://www.hld.ca     
You may be infinitely smaller than some things, but you're infinitely 
larger than others.
-------------- next part --------------
#!/bin/zsh

source /home/dan/.shell/aliases

hosts=(engsoc.org ebob.ca fnx.ca scaffidi-argentina.com jlcooke.ca
	   opag.sourceforge.net
)

#---------MODULES--------------------------
autoload -U promptinit
promptinit
prompt adam1

autoload predict-on
zle -N predict-on
zle -N predict-off
bindkey '^X^Z' predict-on
bindkey '^Z' predict-off

autoload sched
#---------MODULES--------------------------

#---------EXPORTS--------------------------
export MANPATH=$MANPATH:/var/qmail/man
export NNTPSERVER='nntp'
export PATH="$PATH:/usr/sbin"
export MANPAGER="col -b | vim -R -c 'set ft=man nomod nolist' -"
export MAILCHECK=60
export DIRSTACKSIZE=8
#export PROMPT='%m:%t %~> '
export HISTSIZE=5000
export HISTFILE=.zsh_history


if [ TERM="xterm" ]; then
    export TERM='xterm-color'
fi
#---------EXPORTS--------------------------
#  Cool things:
#  ls =who    =executable is just like `which executable`

# watch list
#watch=( all )         # watch users logging in
watch=notme
#WATCHFMT="%n is %a %l from %M"
WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
export MANPAGER="col -b | vim -R -c 'set ft=man nomod nolist' -"
export MAIL="/home/dan/.mail/inbox"

#------------Aliases----------------------
alias l='ls -h --color=auto'
alias ls='ls -h --color=auto'
alias ll='ls -h --color=auto -la'
alias df='df -h'
alias du='du -h'
alias ftp='ncftp'
alias talk='ytalk'
alias vi='vim'

# typos
alias sl='ls'
alias cd..='cd ..'


alias j='jobs -l'
alias gps='ps -ef | grep '
# to see directories
alias dh='dirs -v'
#------------Aliases----------------------

#------------MAIL-------------------------
# check the mail folders
mailpref=/home/dan/.Mail
mailpath=(
$mailpref/inbox'?New email -> $_'
$mailpref/ateam'?New email -> $_'
$mailpref/innomod'?New email -> $_'
$mailpref/opag'?New email -> $_'
$mailpref/oclug'?New email -> $_'
$mailpref/hldfilter'?New email -> $_'
$mailpref/news'?New email -> $_'
$mailpref/shp'?New email -> $_'
$mailpref/system'?New email -> $_'
)
#------------MAIL-------------------------

#--------Options Start--------------------
setopt cshjunkiequotes   # don't let unmatched ' go
setopt histignoredups

#Automatically push directories
setopt autopushd pushdminus pushdsilent pushdtohome
#--------Options End----------------------


#-------Hostname Completion---------------
# how to get the hosts out of /etc/hosts for completion
: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
# then call it with a "$_etc_hosts[@]" in the hostnames array # hostname completion
hostnames=(\
$_etc_hosts[@] \
opag.sourceforge.net \
fnx.ca \
ebob.ca \
scaffidi-argentina
)
# what progs can use the hostname completion
compctl -k hostnames ping telnet ftp nslookup ssh traceroute mtr scp ncftp
#-------Hostname Completion---------------


#-------Functions-------------------------
# csh compatible setenv function
setenv() { export $1=$2 }

# Update config
cpall () {
cp ~/.zshrc ~/dotfiles/.zshrc
cp ~/.bashrc ~/dotfiles/.bashrc
cp ~/.vimrc ~/dotfiles/.vimrc
cp ~/.screenrc ~/dotfiles/.screenrc
chmod 600 ~/dotfiles/.*
}
#-------Functions-------------------------


#-------Completions----------------------
##
## Enable the way cool bells and whistles.
## # General completion technique
#zstyle ':completion:*' completer _complete _correct _approximate _prefix
zstyle ':completion:*' completer _complete _prefix
zstyle ':completion::prefix-1:*' completer _complete
zstyle ':completion:incremental:*' completer _complete _correct
zstyle ':completion:predict:*' completer _complete # Completion caching
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST # Expand partial paths
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-slashes 'yes' # Include non-hidden directories in globbed file completions
# for certain commands
#zstyle ':completion::complete:*' \
#  tag-order 'globbed-files directories' all-files
#zstyle ':completion::complete:*:tar:directories' file-patterns '*~.*(-/)' # Don't complete backup files as executables
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~' # Separate matches into groups
zstyle ':completion:*:matches' group 'yes' # Describe each match group.
zstyle ':completion:*:descriptions' format "%B---- %d%b" # Messages/warnings format
zstyle ':completion:*:messages' format '%B%U---- %d%u%b'
zstyle ':completion:*:warnings' format '%B%U---- no match for: %d%u%b' # Describe options in full
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
#-------Completions----------------------


More information about the OCLUG mailing list